Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change compiler in CMAKE sub_directory CMakeLists.txt file

Tags:

cmake

I would like to change CMAKE_C_COMPILER and CMAKE_CXX_COMPILER in an inner sub_directory being compiled as part of a bigger project.

changing from GNU to intel compiler. however, outside of this directory nothing has to chagne.

is that possible?

Thanks

like image 204
sramij Avatar asked Feb 01 '11 17:02

sramij


People also ask

What does Add_subdirectory do in CMake?

Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.


1 Answers

Instead of using add_subdirectory consider making the subdirectory a self-contained CMake project, which can be configured and built independently of the bigger project. You can then add the subdirectory to your bigger project as an external project by using the ExternalProject_Add command.

like image 149
sakra Avatar answered Oct 12 '22 08:10

sakra