المشاريع
عرض على GitHub
forexample/package-example
حول
CMake: config mode of find_package command (examples)
التعلّم والتعليمالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- ٠
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلInstall Foo
Install project Foo in Debug and Release variants (Makefile generator):
> cmake -HFoo -B_builds/Foo-debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX="`pwd`/_install"
> cmake --build _builds/Foo-debug --target install
...
Install the project...
-- Install configuration: "Debug"
-- Installing: /.../_install/lib/libbard.a
-- Installing: /.../_install/lib/libbazd.a
-- Installing: /.../_install/include/foo
-- Installing: /.../_install/include/foo/Bar.hpp
-- Installing: /.../_install/include/foo/Baz.hpp
-- Installing: /.../_install/include/foo/BAR_EXPORT.h
-- Installing: /.../_install/include/foo/BAZ_EXPORT.h
-- Installing: /.../_install/lib/cmake/Foo/FooConfig.cmake
-- Installing: /.../_install/lib/cmake/Foo/FooConfigVersion.cmake
-- Installing: /.../_install/lib/cmake/Foo/FooTargets.cmake
-- Installing: /.../_install/lib/cmake/Foo/FooTargets-debug.cmake
> cmake -HFoo -B_builds/Foo-release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="`pwd`/_install"
> cmake --build _builds/Foo-release --target install
...
Install the project...
-- Install configuration: "Release"
-- Installing: /.../_install/lib/libbar.a
-- Installing: /.../_install/lib/libbaz.a
-- Up-to-date: /.../_install/include/foo
-- Up-to-date: /.../_install/include/foo/Bar.hpp
-- Up-to-date: /.../_install/include/foo/Baz.hpp
-- Installing: /.../_install/include/foo/BAR_EXPORT.h
-- Installing: /.../_install/include/foo/BAZ_EXPORT.h
-- Installing: /.../_install/lib/cmake/Foo/FooConfig.cmake
-- Installing: /.../_install/lib/cmake/Foo/FooConfigVersion.cmake
-- Installing: /.../_install/lib/cmake/Foo/FooTargets.cmake
-- Installing: /.../_install/lib/cmake/Foo/FooTargets-release.cmake
Note that:
- library target
barfor different build types has different names:libbar.aandlibbard.a - header files is equal for both variants
- cmake-config files
FooConfig.cmake,FooConfigVersion.cmakeandFooTargets.cmakeis equal for both variants FooTargets-release.cmakesetReleaseimported target properties, e.g.IMPORTED_LOCATION_RELEASEFooTargets-debug.cmakesetDebugimported target properties, e.g.IMPORTED_LOCATION_DEBUG
Note:
Boo (use installed Foo)
Easiest way to find and include FooConfig.cmake file is to set CMAKE_INSTALL_PREFIX:
> cmake -HBoo -B_builds/Boo -DCMAKE_INSTALL_PREFIX="`pwd`/_install"
Also CMAKE_PREFIX_PATH and Foo_DIR can be used (do not forget to remove _builds/Boo directory
before every configure):
> cmake -HBoo -B_builds/Boo -DCMAKE_PREFIX_PATH="`pwd`/_install"
> cmake -HBoo -B_builds/Boo -DFoo_DIR="`pwd`/_install/lib/cmake/Foo"
find_package config-mode command will include FooConfig.cmake file and import new target Foo::bar:
> cat Boo/CMakeLists.txt
find_package(Foo CONFIG REQUIRED)
add_executable(boo boo.cpp)
target_link_libraries(boo Foo::bar)
Note that:
- definition
FOO_BAR_DEBUGwill be added automatically - include directory for target
Foo::barwill be added automatically - in
Debug-mode macroFOO_BAR_DEBUGwill be1and linker will uselibbard.alibrary - in
Release-mode macroFOO_BAR_DEBUGwill be0and linker will uselibbar.alibrary - if
find_packagecommand specify library version thenFooConfigVersion.cmakemodule will check compatibility:
> grep find_package Boo/CMakeLists.txt
find_package(Foo 2.0 CONFIG REQUIRED)
> cmake -HBoo -B_builds/Boo -DCMAKE_INSTALL_PREFIX="`pwd`/_install"
CMake Error at CMakeLists.txt:8 (find_package):
Could not find a configuration file for package "Foo" that is compatible
with requested version "2.0".
The following configuration files were considered but not accepted:
/.../_install/lib/cmake/Foo/FooConfig.cmake, version: 1.2.3
Script
See jenkins.py script for automatic testing + options --install-boo/--shared and --monolithic.
UML sequence diagram

More
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…