About multiple toolchains support in big project

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

About multiple toolchains support in big project

刘松

Hi CMake experts,

I want to use CMake build system for large projects, which will uses different toolchains.

Let’s take one simple example:

There are two project, one is using the arm cross toolchain, another one is using the dsp toolchain.


cmake_projects/
├── CMakeLists.txt
├── arm_project
│   └── CMakeLists.txt
├── arm_project2
│   └── CMakeLists.txt
├── dsp_project
│   └── CMakeLists.txt
└── dsp_project2
    └── CMakeLists.txt

Inside the cmake_projects/CMakeLists.txt:

add_subdirectory(arm_project)

add_subdirectory(arm_project2)

add_subdirectory(dsp_project)

add_subdirectory(dsp_project2)

Then, I want to build it:

mkdir build
cd build && cmake -DCMAKE_TOOLCHAIN_FILE=<which_toolchain> ../

You know that the CMAKE_TOOLCHAIN_FILE needs to be specified along with cmake command line, so in above example what’s the <which_toolchain> should be ?

Yes, there might be another solution:


cmake_projects/
├── CMakeLists.txt
├── arm
│   └── CMakeLists.txt
├── dsp
│   └── CMakeLists.txt

├── arm_project
│   └── CMakeLists.txt
├── arm_project2
│   └── CMakeLists.txt
├── dsp_project
│   └── CMakeLists.txt
└── dsp_project2
    └── CMakeLists.txt

so that inside arm/CMakeLists.txt


add_subdirectory(arm_project)
add_subdirectory(arm_project2)

and inside dsp/CMakeLists.txt


add_subdirectory(dsp_project)
add_subdirectory(dsp_project2)

Then, build it with

mkdir build_arm
cd build_arm && cmake -DCMAKE_TOOLCHAIN_FILE=<arm_toolchain_now> ../arm

mkdir build_dsp
cd build_dsp && cmake -DCMAKE_TOOLCHAIN_FILE=<dsp_toolchain_now> ../dsp

But this way I need to sperate the arm and dsp build folder structure, but logically I need to keep the build folder structure as same as source code.

Or, let developer don’t be aware of the toolchain difference it’s just choosing the right one…

But if it’s supporting specifying the CMAKE_TOOLCHAIN_FILE inside the CMakeLists.txt, it might solving this problem.

Any suggestions or ideas ? Thanks in advanced.

Thanks,
Song


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake