Change compiler in CMAKE sub_directory CMakeLists.txt file

I would like to change CMAKE_C_COMPILER and CMAKE_CXX_COMPILER in the sub_directory internal directory, which compiles as part of a larger project.

Transition from GNU to Intel Compiler. however outside of this directory nothing is needed to chagne.

perhaps?

thanks

+4
source share
2 answers

Instead of using add_subdirectory consider creating a subdirectory of a stand-alone CMake project that you can configure independently of a larger project. You can then add this subdirectory to your large project as an external project using the ExternalProject_Add command.

+4
source

It depends on how you organize your project. If it is not the only CMakeLists.txt for the entire project, but one for each subfolder - just try changing the definition of CMAKE_C_COMPILER before the project (). He should influence only this definition of the project.

+1
source

Source: https://habr.com/ru/post/1337986/


All Articles