Skip to content

Commit

Permalink
cmake: restore GrokConfig.cmake file
Browse files Browse the repository at this point in the history
  • Loading branch information
Grok Compression committed Jan 11, 2025
1 parent a677efc commit d1aa7bd
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 8 deletions.
28 changes: 22 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ 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
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}"
)
#######################################
Expand Down Expand Up @@ -212,10 +212,26 @@ if(BUILD_TESTING AND GRK_BUILD_CODEC)
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})
if (NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten)
# 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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/GrokCPack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
54 changes: 54 additions & 0 deletions cmake/GrokConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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}")
2 changes: 1 addition & 1 deletion src/lib/core/grk_config.h.cmake.in
Original file line number Diff line number Diff line change
@@ -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@

0 comments on commit d1aa7bd

Please sign in to comment.