You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2024/05/09 10:25:07 UTC
svn commit: r1917604 - /apr/apr/trunk/CMakeLists.txt
Author: ivan
Date: Thu May 9 10:25:07 2024
New Revision: 1917604
URL: http://svn.apache.org/viewvc?rev=1917604&view=rev
Log:
CMakeLists.txt: Generate and install package version information.
Modified:
apr/apr/trunk/CMakeLists.txt
Modified: apr/apr/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CMakeLists.txt?rev=1917604&r1=1917603&r2=1917604&view=diff
==============================================================================
--- apr/apr/trunk/CMakeLists.txt (original)
+++ apr/apr/trunk/CMakeLists.txt Thu May 9 10:25:07 2024
@@ -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 ;)
@@ -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
@@ -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)