@PACKAGE_INIT@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") # find_dependency(OtherLib REQUIRED) check_required_components("@PROJECT_NAME@") 文件放在跟install script的CMakeList.txt同级目录下 如何集成到项目中 find_package(xxx 1.0.0 CONFIG REQUIRED) target_link_libraries(ma...
CMakeLists.txt内容: 1cmake_minimum_required(VERSION3.5FATAL_ERROR)2project(CmakeTest LANGUAGES CXX)34set(CMAKE_CXX_STANDARD11)5set(CMAKE_CXX_EXTENSIONS OFF)6set(CMAKE_CXX_STANDARD_REQUIRED ON)78find_package(PythonInterp REQUIRED)9find_package(Python COMPONENTS Interpreter Development REQUIRED)1011m...
[CMakeLists.txt] - 包含要运行的 CMake 命令 cmake_minimum_required(VERSION 3.5) # Set the project name project (third_party_include) # find a boost install with the libraries filesystem and system find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system) # check if boost was found ...
a. 通过默认的FindPackage find_package(GFlags REQUIRED) 这个时候可以通过PATHS指定某个目录去寻找,避免多个版本链接出错。 find_package(GFlags PATHS /workspace/xxx/gflags-2.2.2/out/lib/cmake/gflags REQUIRED NO_DEFAULT_PATH) 如果安装的第三方库使用源码编译安装,并且作者没有编写.cmake文件供find_package使用。
COMPONENTS,components:可选字段,表示查找的包中必须要找到的组件(components),如果有任何一个找不到就算失败,类似于REQUIRED,导致cmake停止执行。 Module模式下需要查找到名为FindPackageName.cmake的文件。 先在CMAKE_MODULE_PATH变量对应的路径中查找。如果路径为空,或者路径中查找失败,则在cmake module directory(c...
function(find_required_package pkg_name) find_package(${pkg_name}) if(NOT${pkg_name}_FOUND) message(FATAL_ERROR"Required package${pkg_name}not found, \ please install the package and try building MindSpore again.") endif() endfunction() ...
+include(CMakeFindDependencyMacro) + +find_dependency(ZeroMQ) + +if (@CZMQ_WITH_LIBCURL@ AND @LIBCURL_FOUND@) + find_dependency(OpenSSL) + find_dependency(ZLIB) +endif () + + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@"...
find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system) #这是第三方库,而不是自己生成的静态动态库 # check if boost was found if(Boost_FOUND) message ("boost found") else() message (FATAL_ERROR "Cannot find Boost") endif() ...
FIND_PACKAGE(<name> [version] [EXACT] [QUIET] [NO_MODULE] [ [ REQUIRED | COMPONENTS ] [ componets... ] ] ) 5.1查找*.cmake的顺序 1、find_package(<Name>)命令首先会在模块路径中寻找Find<name>.cmake 这是查找库的一个典型方式,具体查找路径依次为CMake: ...
find_package(Boost 1.54 REQUIRED COMPONENTS unit_test_framework) add_executable(cpp_test test.cpp) target_link_libraries(cpp_test PRIVATE sum_integers Boost::unit_test_framework ) # avoid undefined reference to "main" in test.cpp target_compile_definitions(cpp_test ...