Skip to content

Commit

Permalink
On '1.7.x' branch: Merge r1917604 from trunk:
Browse files Browse the repository at this point in the history
  CMakeLists.txt: Generate and install package version information.

git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1917612 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Ivan Zhakov committed May 9, 2024
1 parent ab4273d commit b4c4b51
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 @@ -74,6 +74,13 @@ ELSE()
SET(win32_winnt_str ${MIN_WINDOWS_VER})
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)

Expand Down Expand Up @@ -449,8 +456,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 @@ -463,6 +477,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}"
)

IF(INSTALL_PDB)
INSTALL(FILES ${install_bin_pdb}
DESTINATION bin
Expand Down

0 comments on commit b4c4b51

Please sign in to comment.