# 当前target需要包含的头文件目录 target_include_directories(my_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/public INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/interface ) # 链接另一个库,并使用其头文件 target_link_libraries(my_lib PUBLIC other_l...
target_include_directories()支持 PRIVATE , PUBLIC 和 INTERFACE 限定符。 它相当于g++命令的-L选项的作用,也相当于环境变量中增加LD_LIBRARY_PATH的路径的作用 link_directories / target_link_libraries 含义应该是同上的 嵌套头文件的引用问题。 在子项目中,include的用法可以帮助当前环境找到头文件,但在外部的项...
set( leveldb_INCLUDE_DIR"${CMAKE_CURRENT_SOURCE_DIR}/include")set( leveldb_INCLUDE_DIRS"${CMAKE_CURRENT_SOURCE_DIR}/include")ADD_LIBRARY(leveldb STATIC IMPORTED GLOBAL)set_property(TARGET leveldb PROPERTYINTERFACE_INCLUDE_DIRECTORIES${leveldb_INCLUDE_DIRS}) add_library(basiccache STATIC${srcs}...
target_link_libraries(useSophus ${Sophus_LIBRARIES}) 我们怎么知道要连接Sophus_INCLUDE_DIRS,Sophus_LIBRARIES,而不是SOPHUS_INCLUDE_DIRS,SOPHUS_LIBRARIES或其他,其实 find_package主要是找到.cmake文件,然后这些变量在.cmake 里面定义了,我们看Sophus/SophusConfig.cmake: # Sophus source dir set( Sophus_SOURCE...
In short, the libraries inopencv_LIBSlikely each specified their public headers (those thatyouwill#includeas a user of the library) viatarget_include_directories, so that they would automatically be added to the include path when linked against. It's one of the nice things about...
include(Module-Conf) target_link_libraries(${PROJECT_NAME} mymodule) Will CMake append the include_directories property to the include path? Right now I cannot see the path so it seems that I have to do it by myself by using get_target_property? Question: Can I do...
导入库为类似于target_link_libraries命令中引用它提供了便利。关于导入库细节可以通过指定那些以IMPORTED_的属性设置来指定。其中最重要的属性是IMPORTED_LOCATION(以及它的具体配置版本,IMPORTED_LOCATION_<CONFIG>),它指定了主库文件在磁盘上的位置。查阅IMPORTED_*属性的文档获取更多的信息。