Skip to content

Commit

Permalink
CMakeLists.txt: Generate and install package version information.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1917604 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Ivan Zhakov committed May 9, 2024
1 parent c8af964 commit dea097b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ IF(APR_MODULAR_DSO)
SET(apr_have_modular_dso_10 1)
ENDIF()

# Read current version.
FILE(STRINGS include/apr_version.h VERSION_STRINGS REGEX "#define (APR_MAJOR_VERSION|APR_MINOR_VERSION|APR_PATCH_VERSION)")

STRING(REGEX REPLACE ".*#define APR_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" APR_MAJOR_VERSION ${VERSION_STRINGS})
STRING(REGEX REPLACE ".*#define APR_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" APR_MINOR_VERSION ${VERSION_STRINGS})
STRING(REGEX REPLACE ".*#define APR_PATCH_VERSION[ \t]+([0-9]+).*" "\\1" APR_PATCH_VERSION ${VERSION_STRINGS})

CONFIGURE_FILE(include/apr.hwc
${PROJECT_BINARY_DIR}/apr.h)
# "COPYONLY" just because anything else isn't implemented ;)
Expand Down Expand Up @@ -754,8 +761,15 @@ IF(APR_BUILD_TESTAPR)
ENDIF (APR_BUILD_TESTAPR)

# Installation
INCLUDE(CMakePackageConfigHelpers)

string(TOLOWER "${PROJECT_NAME}" project_name_lower)

write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${project_name_lower}-config-version.cmake"
VERSION ${APR_MAJOR_VERSION}.${APR_MINOR_VERSION}.${APR_PATCH_VERSION}
COMPATIBILITY SameMajorVersion
)

INSTALL(TARGETS ${install_targets} EXPORT apr-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Expand All @@ -768,6 +782,10 @@ INSTALL(EXPORT apr-config
FILE "${project_name_lower}-config.cmake"
)

INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${project_name_lower}-config-version.cmake"
DESTINATION "lib/cmake/${project_name_lower}"
)

# For DSO modules, install only binaries
INSTALL(FILES ${install_modules}
DESTINATION bin)
Expand Down

0 comments on commit dea097b

Please sign in to comment.