[waffle] [PATCH 2/4] cmake: Add cmake PackageConfig files
Dylan Baker
baker.dylan.c at gmail.com
Mon Dec 22 14:36:06 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.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
CMakeLists.txt | 24 ++++++++++++++++++++++++
cmake/Modules/.gitignore | 2 ++
cmake/Modules/WaffleConfig.cmake.in | 13 +++++++++++++
3 files changed, 39 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..729ebc1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -158,6 +158,30 @@ install(
COMPONENT coredocs
)
+
+# ------------------------------------------------------------------------------
+# Create Package config and version files
+# ------------------------------------------------------------------------------
+
+set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/Waffle")
+configure_file(cmake/Modules/WaffleConfig.cmake.in
+ cmake/Modules/WaffleConfig.cmake @ONLY)
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "cmake/Modules/WaffleConfigVersion.cmake"
+ VERSION "${waffle_version}"
+ COMPATIBILITY AnyNewerVersion
+)
+
+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..50544f2
--- /dev/null
+++ b/cmake/Modules/WaffleConfig.cmake.in
@@ -0,0 +1,13 @@
+# 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
+
+get_filename_component(PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+set(Waffle_FOUND 1)
+set(Waffle_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@waffle_libname@")
+set(Waffle_LIBRARIES "@waffle_libname@")
+set(Waffle_LIBRARY_DIRS "${PREFIX}/@CMAKE_INSTALL_LIBDIR@")
--
2.2.1
More information about the waffle
mailing list