[waffle] [Patch v2] cmake: Add cmake PackageConfig files
Dylan Baker
baker.dylan.c at gmail.com
Tue Dec 23 10:58:51 PST 2014
This creates and installs a package version file and a package config
file. These are used by find_package with the CONFIG option, and are
roughly equivalent to pkgconfig, but is cmake specific rather than linux
specific.
v2: - Use configure_package_config_file() instead of config_file(),
which generates helper macros and resolves relative paths allowing
the entire install to be moved.
- Update WaffleConfig.cmake.in to take advantage of
configure_package_config_file()
- Use SameMajorVersion instead of AnyNewerVersion for version
compatibility. Since waffle uses apache's numbering scheme 2.0.0
should not fulfill a requirement of 1.5.0 and vice versa.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
I stumbled onto some more documentation that suggested some useful
changes to this patch looking into something else. Hopefully this will
makes waffle's cmake ConfigModule more versatile.
CMakeLists.txt | 30 ++++++++++++++++++++++++++++++
cmake/Modules/.gitignore | 2 ++
cmake/Modules/WaffleConfig.cmake.in | 12 ++++++++++++
3 files changed, 44 insertions(+)
create mode 100644 cmake/Modules/.gitignore
create mode 100644 cmake/Modules/WaffleConfig.cmake.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bde8096..250dbc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -158,6 +158,36 @@ install(
COMPONENT coredocs
)
+
+# ------------------------------------------------------------------------------
+# Create Package config and version files
+# ------------------------------------------------------------------------------
+
+set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/Waffle")
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "cmake/Modules/WaffleConfigVersion.cmake"
+ VERSION "${waffle_version}"
+ COMPATIBILITY SameMajorVersion
+)
+
+configure_package_config_file(
+ cmake/Modules/WaffleConfig.cmake.in
+ cmake/Modules/WaffleConfig.cmake
+ INSTALL_DESTINATION "${ConfigPackageLocation}"
+ PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
+)
+
+
+install(
+ FILES
+ "cmake/Modules/WaffleConfigVersion.cmake"
+ "cmake/Modules/WaffleConfig.cmake"
+ DESTINATION "${ConfigPackageLocation}"
+ COMPONENT devel
+)
+
# ------------------------------------------------------------------------------
include(WafflePrintConfigurationSummary)
diff --git a/cmake/Modules/.gitignore b/cmake/Modules/.gitignore
new file mode 100644
index 0000000..9742f46
--- /dev/null
+++ b/cmake/Modules/.gitignore
@@ -0,0 +1,2 @@
+WaffleConfigVersion.cmake
+WaffleConfig.cmake
diff --git a/cmake/Modules/WaffleConfig.cmake.in b/cmake/Modules/WaffleConfig.cmake.in
new file mode 100644
index 0000000..b60b470
--- /dev/null
+++ b/cmake/Modules/WaffleConfig.cmake.in
@@ -0,0 +1,12 @@
+# Config module for Waffle
+#
+# Provides the following variables
+# Waffle_INCLUDE_DIRS - Directories to include
+# Waffle_LIBRARIES - Libraries to link
+# Waffle_LIBRARY_DIRS - Library directories to search for link libraries
+
+ at PACKAGE_INIT@
+
+set_and_check(Waffle_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@/@waffle_libname@")
+set_and_check(Waffle_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
+set(Waffle_LIBRARIES "@waffle_libname@")
--
2.2.1
More information about the waffle
mailing list