-
add_definitions
CMake文档描述Adds definitions to the compiler command line for targets in the current directory and below (whether added before or after this command is invoked)
影响范围大( targets in the current directory and below ),会污染其他cmake文件。可以使用set_target_properties给编译目标添加编译选项
比如增加编译选项-g, 编译出带符号的版本add_definitions("-Wall -g") // bad set_target_properties(log_example PROPERTIES COMPILE_FLAGS "-Wall -g") // good
-
使用BUILD_SHARED_LIBS标记整个add_library属性
CMake文档描述Global flag to cause add_library() to create shared libraries if on.
If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library. This variable is often added to projects as an option() so that each user of a project can decide if they want to build the project using shared or static libraries.
若该目录下的生成库的属性统一,可以使用CMake全局FLAG
-
PRIVATE INTERFACE PUBLIC
C++代码review问题<二>:CMakeLists编写的一些规范
最新推荐文章于 2024-12-03 00:07:27 发布