add_library(<name> INTERFACE [IMPORTED [GLOBAL]]) 这类库有属性,能install(),export和imported,但可能没有build过程。像纯头文件库或完全针对target的设计(这条参见interface libraries) 所有INTERFACE _*属性从如下几个方法中设置 set_property()、target_link_libraries(INTERFACE)、target_link_options(INTERFACE)...
add_library(ffmpeg INTERFACE IMPORTED GLOBAL) #设置接口库指向哪些预编译库 set_target_properties(ffmpeg PROPERTIES INTERFACE_LINK_LIBRARIES"${FFMPEG_LIBS}") #设置接口库包含的头文件 set_target_properties(ffmpeg PROPERTIES INTERFACE_INCLUDE_DIRECTORIES"${PROJECT_SOURCE_DIR}/external/ffmpeg/prebuild/include"...
add_library中的第二个参数 STATIC 表示是静态库,如果不加STATIC的话比如 add_library(xlog xlog.cpp) 就是默认编译动态库,如果要编译静态库再通过cmake的预制变量来控制。 STATIC 替换为SHARED 就是指定编译为动态库,例如:add_library(xlog SHARED xlog.cpp) 。 如果是Linux动态库代码不需要调整,Windows动态库需...
Imported Libraries add_library( ]]> IMPORTED [GLOBAL]) ObjectLibraries add_library(]]> OBJECT …) Alias Libraries add_library( ALIAS ]]>) Interface Libraries add_library(]]> INTERFACE [IMPORTED [GLOBAL]]) 2.find_library find_library ( name1 [path1 path2 …]) find_library ( name | NAM...
CMake 还允许一些特殊的库,比如由.o 文件组成的 OBJECT 库(主要为了节约编译时间),或者仅仅由头文件组成的 INTERFACE 库(header-only),见下文 注: add_library可以缺省STATIC|SHARED参数,此时默认为STATIC全部生成静态库,但是也可以通过指定BUILD_SHARED_LIBS为真,修改默认值为SHARED全部生成动态库 ...
#add_library(leveldbSTATIC"") # 生成静态链接目标(默认静态) #add_executable(leveldb "") # 生成可执行文件 # 指定生成目标,所使用的源码文件列表 #target_sources(<target> # <INTERFACE|PUBLIC|PRIVATE> [items1...] # [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) ...
add_library(global-libs INTERFACE) include (cmake/fuzzer.cmake) include (cmake/sanitize.cmake) option(ENABLE_COLORED_BUILD "Enable colors in compiler output" ON) set (CMAKE_COLOR_MAKEFILE ${ENABLE_COLORED_BUILD}) # works only for the makefile generator if (ENABLE_COLORED_BUILD AND...
在对add_library或add_executable的调用中,只有cpp文件被显式引用,并通过以下方式查找头文件, target_include_directories(my_target PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) 2.3 添加依赖 有两种方法可以将包与新的依赖项链接起来。 方法1:ament_target_...
add_library( ${TARGET} ${CPPS} ${INLS} ${HPPS} ) target_include_directories( ${TARGET} PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/libELL/include" "${SOURCE_PATH}" ) target_include_directories( ${TARGET} PUBLIC $<BUILD_INTERFACE:${INCLUDE_PATH}> $<INSTALL_INTERFACE:include/> ) if( NO...
add_library(ascendcl_headers INTERFACE) target_include_directories(ascendcl_headers INTERFACE $<BUILD_INTERFACE:${BASE_DIR}/inc> $<BUILD_INTERFACE:${BASE_DIR}/inc/external> $<BUILD_INTERFACE:${BASE_DIR}/inc/external/acl> $<BUILD_INTERFACE:${BASE_DIR}/inc/external/acl/error_codes> ...