change compiler in CMAKE sub_directory CMakeLists.txt file

我的未来我决定 提交于 2020-05-23 08:54:40

问题


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


回答1:


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.




回答2:


It depends, how you organize your project. If it is not single CMakeLists.txt for whole project, but one per each sub folder - just try to change CMAKE_C_COMPILER before project() definition. It should affect only this project definition.



来源:https://stackoverflow.com/questions/4865852/change-compiler-in-cmake-sub-directory-cmakelists-txt-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!