如何使用cmake向单个翻译单元添加编译器标志(我想将其附加,而不是覆盖其他标记)?
我试过了
set_source_files_properties(MyFile.cpp PROPERTIES CMAKE_CXX_FLAGS "-msse4.1")
Run Code Online (Sandbox Code Playgroud)
但它没有工作..有关如何做的任何建议?
我们CMakeList.txt有一个target_include_directories在蠕动.它打破了我们的下级客户端,如Ubuntu LTS,CentOS的和Solaris.
我知道我可以用以下内容来保护它(感谢ZW),但我需要Cmake版本2.8.11及更早版本(???)的内容.
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
...
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
target_include_directories(...)
else()
???
endif()
Run Code Online (Sandbox Code Playgroud)
我们的目录结构非常简单.有一个目录中包含头文件,同一目录中包含源文件.这是设计使用户在调试器下没有麻烦.
给出我们的配置可以使用以下内容(如果@steveire答案适用于我们,我不清楚):
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
target_include_directories(...)
else()
include_directories("${ROOT_SOURCE_DIR}")
endif()
Run Code Online (Sandbox Code Playgroud)
如果没有,应该用什么代替target_include_directories2.8.11及更早版本?