From 1d49a63827ae9d9180d8c6d95cb2e2b548d39880 Mon Sep 17 00:00:00 2001 From: Daniel Bermond Date: Sun, 3 Oct 2021 13:52:50 -0300 Subject: [PATCH] CMake: add package version config file (#57) By adding this file, client applications can have proper version checking support when calling 'find_package()'. --- .github/workflows/build.yml | 3 +++ CMakeLists.txt | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0467049..6dc6312 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,9 @@ on: - "releases/**" paths-ignore: - "**.md" + pull_request: + paths-ignore: + - "**.md" jobs: build: diff --git a/CMakeLists.txt b/CMakeLists.txt index fe49287..b5c1131 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) -project(qhotkey VERSION 1.2.2 LANGUAGES CXX) +project(qhotkey VERSION 1.4.2 LANGUAGES CXX) option(QHOTKEY_EXAMPLES "Build examples" OFF) option(QHOTKEY_INSTALL "Enable install rule" ON) @@ -52,9 +52,18 @@ target_include_directories(qhotkey $ $) +include(CMakePackageConfigHelpers) + set_target_properties(qhotkey PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION}) + VERSION ${PROJECT_VERSION} + INTERFACE_QHotkey_MAJOR_VERSION ${PROJECT_VERSION_MAJOR} + COMPATIBLE_INTERFACE_STRING QHotkey_MAJOR_VERSION) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/QHotkeyConfigVersion.cmake + VERSION "${PROJECT_VERSION}" + COMPATIBILITY AnyNewerVersion) if(QHOTKEY_EXAMPLES) add_subdirectory(HotkeyTest) @@ -72,6 +81,9 @@ if(QHOTKEY_INSTALL) ${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/qhotkey.h ${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/QHotkey DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/QHotkeyConfigVersion.cmake + DESTINATION ${INSTALL_CONFIGDIR}) install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR}) export(TARGETS qhotkey FILE QHotkeyConfig.cmake)