Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake multiple toolchains and target platforms

I am changing from plain make to CMake as a build system for a project. The project is supposed to run on different embedded Linux systems each with its own toolchain and also has quite a few different configuration options per target (e.g. different preprocessor definitions and some sources included/excluded). It is also supposed to work on desktop Linux and some GUI modules have to run on Windows.

Now, CMake has its CMAKE_TOOLCHAIN_FILE option that can be used to factor out the toolchain and compiler specific stuff of each embedded platform (desktop Linux and Windows should not need one).

I guess putting stuff other than the one listed on the CMake Wiki inside the toolchain file is not a good idea.

I am thinking about creating some CMake variables that can be edited by the cmake gui tool and then simply using if/elseif to determine the right setup.

Does anyone have a better or more elegant suggestion?

like image 262
trenki Avatar asked Apr 08 '11 07:04

trenki


1 Answers

I figured instead of using long if/elseif/else blocks I could simply have

include(flags-${CONFIGURATION_NAME}.cmake)

in my CMakeLists.txt and the specific flags for each configuration would then simply be listed on the appropriate flags file.

like image 177
trenki Avatar answered Oct 01 '22 20:10

trenki