CMakeLists.txt实例 find_package(Protobuf REQUIRED)include_directories(${PROTOBUF_INCLUDE_DIR})add_executable(main src/main.cpp)target_link_libraries(main ${PROTOBUF_LIBRARIES}) find_package从默认目录中寻找Protobuf,找到后将头文件目录设置为${PROTOBUF_INCLUDE_DIR},库文件位置设置为${PROTOBUF_LIBRARIE...
add_executable(my_bin src/my_bin.cpp)find_package(OpenCV REQUIRED)include_directories(${OpenCV_INCLUDE_DIRS})target_link_libraries(my_bin, ${OpenCV_LIBS}) 工作流程如下: find_package在一些目录中查找OpenCV的配置文件。 找到后,find_package会将头文件目录设置到${OpenCV_INCLUDE_DIRS}中,将链接库设置...
find_package将先到module路径下查找Find<name>.cmake。首先它搜索${CMAKE_MODULE_PATH}中的所有路径,然后搜索/usr/share/cmake-3.5/Modules。比如find_package(Boost)搜索的文件是/usr/share/cmake-3.5/Modules/FindBoost.cmake。 采用list APPEND 不会改变原来的变量,只是在list中新增。 # set(CMAKE_MODULE_...
find_package(CURL REQUIRED) include_directories($CURL_INCLUDE_DIR) target_link_libraries(myprogram path/curl.so) 1. 2. 3. 那么cmake是怎么查找的呢? find_package()命令首先会在模块路径中寻找Find.cmake,这是查找库的一个典型方式。具体查找路径依次为CMake:变量${CMAKE_MODULE_PATH}中的所有目录。如...
include_directories(${OpenCV_INCLUDE_DIRS}) target_link_libraries(my_bin, ${OpenCV_LIBS}) 工作流程如下: find_package在一些目录中查找OpenCV的配置文件。 找到后,find_package会将头文件目录设置到${OpenCV_INCLUDE_DIRS}中,将链接库设置到${OpenCV_LIBS}中。
include_directories(${OpenCV_INCLUDE_DIRS}) add_executable(main src/main.cpp) target_link_libraries(main ${OpenCV_LIBRARIES}) 1. 2. 3. 4. 5. 6. 上面的配置中,find_package从目录中寻找OpenCV,找到后将头文件目录设置为${OpenCV_INCLUDE_DIRS},库文件设为${OpenCV_LIBRARIES},然后在工程中包含OpenCV...
现在,当我尝试使用 FIND_PACKAGE 时,CMAKE 会发现我的操作系统使用的旧版本的 openssl。我目前在我的 CMakeLists.txt 中使用它 SET(OPENSSL_LIB_DIR /usr/local/Cellar/openssl/1.0.2f/lib) INCLUDE_DIRECTORIES(/usr/local/Cellar/openssl/1.0.2f/include) TARGET_LINK_LIBRARIES(mangaMe ${OPENSSL_LIB_DIR...
XXX_FOUND代表库是否查找成功XXX_INCLUDE_DIRS代表头文件的路径XXX_LIBRARIES代表库文件的路径 比如,cmake 可以很轻松引入 bzip2 代码语言:javascript 复制 find_package(BZip2)if(BZIP2_FOUND)include_directories(${BZIP_INCLUDE_DIRS})target_link_libraries(test ${BZIP2_LIBRARIES})endif(BZIP2_FOUND) ...
find_package(mymath CONFIG REQUIRED COMPONENTS test PATHS ./mymath/mymath ) if(mymath_FOUND) message("Find mymath: ${mymath_INCLUDE_DIR}; ${mymath_LIBRARY};") endif() # 执行cmake . cmake . # 输出为 test Find comp test Find mymath: /XXX/mymath; /XXX/mymath/libmymath.a; ...
include_directories(${OpenCV_INCLUDE_DIRS}) target_link_libraries(my_bin, ${OpenCV_LIBS}) 工作流程如下: find_package在一些目录中查找OpenCV的配置文件。 找到后,find_package会将头文件目录设置到${OpenCV_INCLUDE_DIRS}中,将链接库设置到${OpenCV_LIBS}中。