欢迎来到天天文库
浏览记录
ID:40532705
大小:41.50 KB
页数:3页
时间:2019-08-04
《CMake学习笔记5》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、cmake学习笔记(五)在cmake学习笔记(三)中简单学习了find_package的model模式,在cmake学习笔记(四)中了解一个CMakeCache相关的东西。但靠这些知识还是不能看懂PySide使用CMakeLists文件,接下来继续学习find_package的config模式及packageconfigure文件相关知识find_package的config模式当CMakeLists.txt中使用find_package命令时,首先启用的是module模式:按照CMAKE_MODULE_PATH路径和cmake的安
2、装路径去搜索finder文件Find.cmake如果finder未找到,则开始config模式:将在下列路径下查找配置文件Config.cmake或-config.cmake/(W)/(cmake
3、CMake)/(W)/*/(W)/*/(cmake
4、CMake)/(W)/(share
5、lib)/cmake/*/(U)/(share
6、lib)
7、/*/(U)/(share
8、lib)/*/(cmake
9、CMake)/(U)·find_package参数及规则见manualConfig.cmake该文件至少需提供头文件路径和库文件信息。比如ApiExtractorConfig.cmake在Windows下一个例子:#-trytofindAPIEXTRACTOR#APIEXTRACTOR_INCLUDE_DIR-DirectoriestoincludetouseAPIEXTRACTOR#APIEXTRACTOR_LIBRARIE
10、S-FilestolinkagainsttouseAPIEXTRACTORSET(APIEXTRACTOR_INCLUDE_DIR"D:/shiboken/dist/include/apiextractor")if(MSVC)SET(APIEXTRACTOR_LIBRARY"D:/shiboken/dist/lib/apiextractor.lib")elseif(WIN32)SET(APIEXTRACTOR_LIBRARY"D:/shiboken/dist/bin/apiextractor.dll")else()SET(APIEX
11、TRACTOR_LIBRARY"D:/shiboken/dist/lib/apiextractor.dll")endif()该文件是通过configure_file机制生成的,我们看看ApiExtractorConfig.cmake.in文件:SET(APIEXTRACTOR_INCLUDE_DIR"@CMAKE_INSTALL_PREFIX@/include/apiextractor@apiextractor_SUFFIX@")if(MSVC)SET(APIEXTRACTOR_LIBRARY"@LIB_INSTALL_DIR@/@
12、CMAKE_SHARED_LIBRARY_PREFIX@apiextractor@apiextractor_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@.lib")elseif(WIN32)SET(APIEXTRACTOR_LIBRARY"@CMAKE_INSTALL_PREFIX@/bin/@CMAKE_SHARED_LIBRARY_PREFIX@apiextractor@apiextractor_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@
13、")else()SET(APIEXTRACTOR_LIBRARY"@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@apiextractor@apiextractor_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")endif()对应的命令(变量的定义略过)configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ApiExtractorConfig.cmake.in""${CMAKE_
14、CURRENT_BINARY_DIR}/ApiExtractorConfig.cmake"@ONLY)ConfigVersion.cmake该文件用来比对版本是否匹配,看看ApiExtractorConfigVersion
此文档下载收益归作者所有