我用 CMake 和 CPack 来配置和包装我的库。 我写了自己的查找模块 : < code> findnMyLib. cMake 。
我如何告诉 CMake/ CPack 将此文件添加到 CMake 模块目录, 这样未来的开发者可以简单地指定 < code> FIND_ PACKAGE (MyLib) code > 来使用我的库?
我用 CMake 和 CPack 来配置和包装我的库。 我写了自己的查找模块 : < code> findnMyLib. cMake 。
我如何告诉 CMake/ CPack 将此文件添加到 CMake 模块目录, 这样未来的开发者可以简单地指定 < code> FIND_ PACKAGE (MyLib) code > 来使用我的库?
您可以设置 CMAKE_MODULE_PATH
并用您的工程分发您的自定义 FindFoo.cmake
。 例如 :
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
CMake 模块目录是 CMake 本身安装树的一部分, 因此您不应该尝试添加任何内容 。
CMake 模块目录包含由 Kitware 撰写或至少经过 Kitware 审阅的模块, 添加您自己的模块会给项目用户留下一个印象, 即您的项目也是这样 。
您最好在 find_package
所搜索的地方之一安装 FindMyLib. cmake:
<prefix>/ (Windows) <prefix>/(cmake|CMake)/ (Windows) <prefix>/<name>*/ (Windows) <prefix>/<name>*/(cmake|CMake)/ (Windows) <prefix>/(lib/<arch>|lib|share)/cmake/<name>*/ (Unix) <prefix>/(lib/<arch>|lib|share)/<name>*/ (Unix) <prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/ (Unix) <prefix>/<name>.framework/Resources/ (Apple) <prefix>/<name>.framework/Resources/CMake/ (Apple) <prefix>/<name>.framework/Versions/*/Resources/ (Apple) <prefix>/<name>.framework/Versions/*/Resources/CMake/ (Apple) <prefix>/<name>.app/Contents/Resources/ (Apple) <prefix>/<name>.app/Contents/Resources/CMake/ (Apple)
见find_package /a>文件
find_package
搜索的完整细节。此外,”https://gitlab.kitware.com/cmake/communion/wikis/doc/tutors/Packagages' rel=“noreferrer” >CMake包装辅导 对本案有用。
A. 允许
未来开发者可以简单地指定 FFD_ PackAGE (MyLib) 来使用我的库
is to write a package config file (-config.cmake) , not a Find module. The package config file should then be installed in one of the folders where the FindPackage module looks for (something like /lib/package/ or /lib/cmake/package the second being preferred)
FindPackage 模块将自动装入配置文件, 如果它可以在那里找到它 。
CMakewiki在https://gitlab.kitware.com/cmake/com/community/wikis/doc/tutoments/Packing 上有更详细的指示。
How do I write a CMakeLists.txt file so that cmake generates a Makefile with functionality equivalent to all: proj debug: CXXFLAGS += -DDEBUG -g -Og debug: proj proj: $(CXX) $(CXXFLAGS) main....
My setup: Windows 10 Pro 22H2 (19045.2965) CLion 2020.1.3 (JetBrains) WSL2 with Ubuntu 22.04.2 LTS gcc 11.3.0 cmake 3.22.1 gdb 12.1 gmake 4.3 CMakeLists.txt cmake_minimum_required(VERSION 3.22)...
We build several private frameworks that get copied into our application bundle during our Xcode build process. I m moving the whole build process to CMake, and this is one area that I haven t been ...
I am trying to use CMake to compile a C++ application that uses the C library GStreamer. My main.cpp file looks like this: extern "C" { #include <gst/gst.h> #include <glib.h> } int main(...
I m trying to add the item <key>UIStatusBarHidden</key><true/> to my plist that s auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; ...
Let s assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let s assume that main.cpp ...
On a Windows 7 machine I cannot read any registry values that contain a semicolon. For example if you have 7-zip, running the following SET(MYPATH [HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip;Path]) ...
I am using the macports version of python on a Snow Leopard computer, and using cmake to build a cross-platform extension to it. I search for the python interpreter and libraries on the system using ...