diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e4e84ed3..af22ae929 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,11 +6,11 @@ project(GROK) # GROK version set(GROK_VERSION_MAJOR 14) set(GROK_VERSION_MINOR 2) -set(GROK_VERSION_BUILD 0) +set(GROK_VERSION_PATCH 0) set(GROK_VERSION - "${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_BUILD}") + "${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_PATCH}") set(PACKAGE_VERSION - "${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_BUILD}") + "${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_PATCH}") # As autotools does not support X.Y notation for SOVERSION, we have to use # two different versions, one for Grok itself and one for its .so @@ -18,7 +18,7 @@ if(NOT GROK_SOVERSION) set(GROK_SOVERSION 1) endif(NOT GROK_SOVERSION) set(GROK_LIBRARY_PROPERTIES - VERSION "${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_BUILD}" + VERSION "${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_PATCH}" SOVERSION "${GROK_SOVERSION}" ) ####################################### @@ -213,9 +213,25 @@ endif() # install all targets referenced as GrokTargets if (BUILD_SHARED_LIBS AND NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten) -install(EXPORT GrokTargets DESTINATION ${GROK_INSTALL_PACKAGE_DIR}) + # Install the GrokTargets file + install(EXPORT GrokTargets + DESTINATION ${GROK_INSTALL_PACKAGE_DIR} + NAMESPACE GROK::) + + # Generate the GrokConfig.cmake file + include(CMakePackageConfigHelpers) + configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/GrokConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/GrokConfig.cmake + INSTALL_DESTINATION ${GROK_INSTALL_PACKAGE_DIR} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR) + + # Install the GrokConfig.cmake file + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GrokConfig.cmake + DESTINATION ${GROK_INSTALL_PACKAGE_DIR}) endif() + if(GRK_BUILD_DOC) install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) endif() diff --git a/cmake/GrokCPack.cmake b/cmake/GrokCPack.cmake index 8ba9997ac..149f1616e 100644 --- a/cmake/GrokCPack.cmake +++ b/cmake/GrokCPack.cmake @@ -19,7 +19,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") set(CPACK_PACKAGE_VERSION_MAJOR "${GROK_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${GROK_VERSION_MINOR}") - set(CPACK_PACKAGE_VERSION_PATCH "${GROK_VERSION_BUILD}") + set(CPACK_PACKAGE_VERSION_PATCH "${GROK_VERSION_PATCH}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "Grok ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "Grok-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") diff --git a/cmake/GrokConfig.cmake.in b/cmake/GrokConfig.cmake.in new file mode 100644 index 000000000..26e822a6d --- /dev/null +++ b/cmake/GrokConfig.cmake.in @@ -0,0 +1,54 @@ +#----------------------------------------------------------------------------- +# +# GrokConfig.cmake - CMake configuration file for external projects. +# +# This file is configured by Grok and used to load Grok's settings for external projects. +@PACKAGE_INIT@ + +# The Grok version number +set(Grok_MAJOR_VERSION "@GROK_VERSION_MAJOR@") +set(Grok_MINOR_VERSION "@GROK_VERSION_MINOR@") +set(Grok_PATCH_VERSION "@GROK_VERSION_PATCH@") +set(Grok_VERSION "@GROK_VERSION_MAJOR@.@GROK_VERSION_MINOR@.@GROK_VERSION_PATCH@") + +# The libraries +set(Grok_LIBRARIES "GROK::@GROK_CORE_NAME@" "GROK::@GROK_CODEC_NAME@") + +# CMake macros directory +set(Grok_CMAKE_DIR "@GROK_INSTALL_PACKAGE_DIR@") + +# Configuration options +set(Grok_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@") + +# Determine the prefix directory +set(PACKAGE_PREFIX_DIR "@CMAKE_INSTALL_PREFIX@") + +# Detect install or build tree +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +if(EXISTS "${SELF_DIR}/GrokTargets.cmake") + # Install tree + include("${SELF_DIR}/GrokTargets.cmake") + + # Include directories + set(Grok_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@/@GROK_INSTALL_SUBDIR@") + +elseif(EXISTS "${SELF_DIR}/GrokExports.cmake") + # Build tree + include("${SELF_DIR}/GrokExports.cmake") + + # Include directories for build tree + set(Grok_INCLUDE_DIRS "@GROK_INCLUDE_PATH@") + +else() + # Error if neither install nor build tree targets are found + message(FATAL_ERROR + "Could not find GrokTargets.cmake (install tree) or GrokExports.cmake (build tree). " + "Ensure Grok is built and installed correctly.") +endif() + +# Backward compatibility variables +set(Grok_FOUND TRUE) +set(Grok_INCLUDE_DIR "${Grok_INCLUDE_DIRS}") +set(Grok_VERSION_MAJOR "${Grok_MAJOR_VERSION}") +set(Grok_VERSION_MINOR "${Grok_MINOR_VERSION}") +set(Grok_VERSION_PATCH "${Grok_PATCH_VERSION}") diff --git a/src/lib/core/grk_config.h.cmake.in b/src/lib/core/grk_config.h.cmake.in index c51706260..a7d830704 100644 --- a/src/lib/core/grk_config.h.cmake.in +++ b/src/lib/core/grk_config.h.cmake.in @@ -1,4 +1,4 @@ /* Grok Version */ #define GRK_VERSION_MAJOR @GROK_VERSION_MAJOR@ #define GRK_VERSION_MINOR @GROK_VERSION_MINOR@ -#define GRK_VERSION_BUILD @GROK_VERSION_BUILD@ +#define GRK_VERSION_BUILD @GROK_VERSION_PATCH@