CMake rich chains and target platforms

I am moving from simple make to CMake as the build system for the project. It is assumed that the project will run on different embedded Linux systems, each with its own toolchain, and also has quite a few different configuration parameters for each purpose (for example, various preprocessor definitions and some sources are included / excluded). It should also work on desktop Linux, and some graphics modules should work on Windows.

CMake now has an option CMAKE_TOOLCHAIN_FILEthat can be used to separate the toolchain and compiler specifications of each embedded platform (desktop Linux and Windows should not be like that). A.

I believe that information different from it, different from what is indicated in the CMake Wiki inside the toolchain file, is not a good idea.

I am thinking of creating some CMake variables that can be edited with the cmake gui tool, and then just using them if/elseifto determine the correct setting.

Does anyone have a better or more elegant offer?

+5
source share
1 answer

I decided instead of using long blocks if/elseif/elseI could just have

include(flags-${CONFIGURATION_NAME}.cmake)

in my CMakeLists.txt, and the specific flags for each configuration will simply be listed in the corresponding flags file.

+5
source

All Articles