You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ri...@apache.org on 2025/06/10 22:00:42 UTC

svn commit: r1926349 - in /subversion/trunk: CMakeLists.txt build/cmake/FindAPR.cmake build/cmake/FindSerf.cmake

Author: rinrab
Date: Tue Jun 10 22:00:42 2025
New Revision: 1926349

URL: http://svn.apache.org/viewvc?rev=1926349&view=rev
Log:
cmake: Support apr-2.

* build/cmake/FindAPR.cmake
  (APR_INCLUDE_DIR): Also check apr-2 directory.
  (version): Read it just after include dir and default it to 1.0.0 version
   file not found.
  (APR_LIBRARY_SHARED, APR_LIBRARY_STATIC, APR_DLL): Use APR_MAJOR_VERSION
   to determine suffix.
* build/cmake/FindSerf.cmake: Look for apr-util only if apr version is not '2'.
* CMakeLists.txt
  (APR): Merge apr and apr-util sections, support apr-2 (which also ignores
   apr-util library). In pkg-config branch we check for different names of
   the config, while module branch adds apr-util only if apr version is
   not '2'.

Modified:
    subversion/trunk/CMakeLists.txt
    subversion/trunk/build/cmake/FindAPR.cmake
    subversion/trunk/build/cmake/FindSerf.cmake

Modified: subversion/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/subversion/trunk/CMakeLists.txt?rev=1926349&r1=1926348&r2=1926349&view=diff
==============================================================================
--- subversion/trunk/CMakeLists.txt (original)
+++ subversion/trunk/CMakeLists.txt Tue Jun 10 22:00:42 2025
@@ -260,24 +260,33 @@ if(SVN_USE_PKG_CONFIG)
   find_package(PkgConfig REQUIRED)
 endif()
 
-### APR
+### APR and APR-Util
 
 if(SVN_USE_PKG_CONFIG)
-  pkg_check_modules(apr-1 REQUIRED IMPORTED_TARGET apr-1)
-  add_library(external-apr ALIAS PkgConfig::apr-1)
+  pkg_check_modules(apr IMPORTED_TARGET apr-1)
+
+  if(apr_FOUND)
+    # apr-1
+    add_library(external-apr ALIAS PkgConfig::apr)
+
+    pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
+    add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
+  else()
+    # apr-2
+    pkg_check_modules(apr REQUIRED IMPORTED_TARGET apr-2)
+    add_library(external-apr ALIAS PkgConfig::apr)
+    add_library(external-aprutil ALIAS PkgConfig::apr)
+  endif()
 else()
   find_package(APR REQUIRED)
   add_library(external-apr ALIAS apr::apr)
-endif()
 
-### APR-Util
-
-if(SVN_USE_PKG_CONFIG)
-  pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
-  add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
-else()
-  find_package(APRUtil REQUIRED)
-  add_library(external-aprutil ALIAS apr::aprutil)
+  if(APR_MAJOR_VERSION EQUAL 2)
+    add_library(external-aprutil ALIAS apr::apr)
+  else()
+    find_package(APRUtil REQUIRED)
+    add_library(external-aprutil ALIAS apr::aprutil)
+  endif()
 endif()
 
 ### ZLIB

Modified: subversion/trunk/build/cmake/FindAPR.cmake
URL: http://svn.apache.org/viewvc/subversion/trunk/build/cmake/FindAPR.cmake?rev=1926349&r1=1926348&r2=1926349&view=diff
==============================================================================
--- subversion/trunk/build/cmake/FindAPR.cmake (original)
+++ subversion/trunk/build/cmake/FindAPR.cmake Tue Jun 10 22:00:42 2025
@@ -25,20 +25,40 @@ find_path(APR_INCLUDE_DIR
     include
     include/apr-1
     include/apr-1.0
+    include/apr-2
+    include/apr-2.0
 )
 
+if (APR_INCLUDE_DIR AND EXISTS ${APR_INCLUDE_DIR}/apr_version.h)
+  file(
+    STRINGS "${APR_INCLUDE_DIR}/apr_version.h" VERSION_STRINGS
+    REGEX "#define (APR_MAJOR_VERSION|APR_MINOR_VERSION|APR_PATCH_VERSION)"
+  )
+
+  string(REGEX REPLACE ".*APR_MAJOR_VERSION +([0-9]+).*" "\\1" APR_MAJOR_VERSION ${VERSION_STRINGS})
+  string(REGEX REPLACE ".*APR_MINOR_VERSION +([0-9]+).*" "\\1" APR_MINOR_VERSION ${VERSION_STRINGS})
+  string(REGEX REPLACE ".*APR_PATCH_VERSION +([0-9]+).*" "\\1" APR_PATCH_VERSION ${VERSION_STRINGS})
+else()
+  # Default version to 1.0.0 if not found.
+  set(APR_MAJOR_VERSION 1)
+  set(APR_MINOR_VERSION 0)
+  set(APR_PATCH_VERSION 0)
+endif()
+
+set(APR_VERSION "${APR_MAJOR_VERSION}.${APR_MINOR_VERSION}.${APR_PATCH_VERSION}")
+
 find_library(APR_LIBRARY_SHARED
-  NAMES libapr-1
+  NAMES libapr-${APR_MAJOR_VERSION}
   PATH_SUFFIXES lib
 )
 
 find_library(APR_LIBRARY_STATIC
-  NAMES apr-1
+  NAMES apr-${APR_MAJOR_VERSION}
   PATH_SUFFIXES lib
 )
 
 find_file(APR_DLL
-  NAMES libapr-1.dll
+  NAMES libapr-${APR_MAJOR_VERSION}.dll
   PATH_SUFFIXES bin
 )
 
@@ -55,19 +75,6 @@ elseif(APR_LIBRARY_STATIC)
   set(APR_LIBRARY ${APR_LIBRARY_STATIC})
 endif()
 
-if (APR_INCLUDE_DIR AND EXISTS ${APR_INCLUDE_DIR}/apr_version.h)
-  file(
-    STRINGS "${APR_INCLUDE_DIR}/apr_version.h" VERSION_STRINGS
-    REGEX "#define (APR_MAJOR_VERSION|APR_MINOR_VERSION|APR_PATCH_VERSION)"
-  )
-
-  string(REGEX REPLACE ".*APR_MAJOR_VERSION +([0-9]+).*" "\\1" APR_MAJOR_VERSION ${VERSION_STRINGS})
-  string(REGEX REPLACE ".*APR_MINOR_VERSION +([0-9]+).*" "\\1" APR_MINOR_VERSION ${VERSION_STRINGS})
-  string(REGEX REPLACE ".*APR_PATCH_VERSION +([0-9]+).*" "\\1" APR_PATCH_VERSION ${VERSION_STRINGS})
-
-  set(APR_VERSION "${APR_MAJOR_VERSION}.${APR_MINOR_VERSION}.${APR_PATCH_VERSION}")
-endif()
-
 include(FindPackageHandleStandardArgs)
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(

Modified: subversion/trunk/build/cmake/FindSerf.cmake
URL: http://svn.apache.org/viewvc/subversion/trunk/build/cmake/FindSerf.cmake?rev=1926349&r1=1926348&r2=1926349&view=diff
==============================================================================
--- subversion/trunk/build/cmake/FindSerf.cmake (original)
+++ subversion/trunk/build/cmake/FindSerf.cmake Tue Jun 10 22:00:42 2025
@@ -77,16 +77,19 @@ set_target_properties(Serf::Serf PROPERT
 
 find_package(OpenSSL REQUIRED)
 find_package(APR REQUIRED)
-find_package(APRUtil REQUIRED)
 find_package(ZLIB REQUIRED)
 
 target_link_libraries(Serf::Serf INTERFACE
   apr::apr
-  apr::aprutil
   OpenSSL::SSL
   ZLIB::ZLIB
 )
 
+if(NOT APR_MAJOR_VERSION EQUAL 2)
+  find_package(APRUtil REQUIRED)
+  target_link_libraries(Serf::Serf INTERFACE apr::aprutil)
+endif()
+
 if (WIN32)
   target_link_libraries(Serf::Serf INTERFACE
     crypt32.lib



Re: svn commit: r1926349 - in /subversion/trunk: CMakeLists.txt build/cmake/FindAPR.cmake build/cmake/FindSerf.cmake

Posted by Timofei Zhakov <ti...@chemodax.net>.
On Wed, Jun 11, 2025 at 12:29 AM Branko Čibej <br...@apache.org> wrote:

> On 11. 6. 25 00:00, rinrab@apache.org wrote:
>
> Author: rinrab
> Date: Tue Jun 10 22:00:42 2025
> New Revision: 1926349
>
> URL: http://svn.apache.org/viewvc?rev=1926349&view=rev
> Log:
> cmake: Support apr-2.
>
> * build/cmake/FindAPR.cmake
>   (APR_INCLUDE_DIR): Also check apr-2 directory.
>   (version): Read it just after include dir and default it to 1.0.0 version
>    file not found.
>   (APR_LIBRARY_SHARED, APR_LIBRARY_STATIC, APR_DLL): Use APR_MAJOR_VERSION
>    to determine suffix.
> * build/cmake/FindSerf.cmake: Look for apr-util only if apr version is not '2'.
> * CMakeLists.txt
>   (APR): Merge apr and apr-util sections, support apr-2 (which also ignores
>    apr-util library). In pkg-config branch we check for different names of
>    the config, while module branch adds apr-util only if apr version is
>    not '2'.
>
> Modified:
>     subversion/trunk/CMakeLists.txt
>     subversion/trunk/build/cmake/FindAPR.cmake
>     subversion/trunk/build/cmake/FindSerf.cmake
>
> Modified: subversion/trunk/CMakeLists.txt
> URL: http://svn.apache.org/viewvc/subversion/trunk/CMakeLists.txt?rev=1926349&r1=1926348&r2=1926349&view=diff
> ==============================================================================
> --- subversion/trunk/CMakeLists.txt (original)
> +++ subversion/trunk/CMakeLists.txt Tue Jun 10 22:00:42 2025
> @@ -260,24 +260,33 @@ if(SVN_USE_PKG_CONFIG)
>    find_package(PkgConfig REQUIRED)
>  endif()
>
> -### APR
> +### APR and APR-Util
>
>  if(SVN_USE_PKG_CONFIG)
> -  pkg_check_modules(apr-1 REQUIRED IMPORTED_TARGET apr-1)
> -  add_library(external-apr ALIAS PkgConfig::apr-1)
> +  pkg_check_modules(apr IMPORTED_TARGET apr-1)
> +
> +  if(apr_FOUND)
> +    # apr-1
> +    add_library(external-apr ALIAS PkgConfig::apr)
> +
> +    pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
> +    add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
> +  else()
> +    # apr-2
> +    pkg_check_modules(apr REQUIRED IMPORTED_TARGET apr-2)
> +    add_library(external-apr ALIAS PkgConfig::apr)
> +    add_library(external-aprutil ALIAS PkgConfig::apr)
> +  endif()
>  else()
>    find_package(APR REQUIRED)
>    add_library(external-apr ALIAS apr::apr)
> -endif()
>
> -### APR-Util
> -
> -if(SVN_USE_PKG_CONFIG)
> -  pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
> -  add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
> -else()
> -  find_package(APRUtil REQUIRED)
> -  add_library(external-aprutil ALIAS apr::aprutil)
> +  if(APR_MAJOR_VERSION EQUAL 2)
> +    add_library(external-aprutil ALIAS apr::apr)
>
>
>
> Should be "major version greater than 1"
>
>
Even better to use VERSION_LESS: r1926351.


>
> [...]
>
> The more I look at this, the more I'm convinced that if we use serf, we
> should also use the same apr and apr-util as Serf does. It's an edge case,
> though.
>
>
Yay! *See?*

-- 
Timofei Zhakov

Re: svn commit: r1926349 - in /subversion/trunk: CMakeLists.txt build/cmake/FindAPR.cmake build/cmake/FindSerf.cmake

Posted by Timofei Zhakov <ti...@chemodax.net>.
On Wed, Jun 11, 2025 at 12:29 AM Branko Čibej <br...@apache.org> wrote:

> On 11. 6. 25 00:00, rinrab@apache.org wrote:
>
> Author: rinrab
> Date: Tue Jun 10 22:00:42 2025
> New Revision: 1926349
>
> URL: http://svn.apache.org/viewvc?rev=1926349&view=rev
> Log:
> cmake: Support apr-2.
>
> * build/cmake/FindAPR.cmake
>   (APR_INCLUDE_DIR): Also check apr-2 directory.
>   (version): Read it just after include dir and default it to 1.0.0 version
>    file not found.
>   (APR_LIBRARY_SHARED, APR_LIBRARY_STATIC, APR_DLL): Use APR_MAJOR_VERSION
>    to determine suffix.
> * build/cmake/FindSerf.cmake: Look for apr-util only if apr version is not '2'.
> * CMakeLists.txt
>   (APR): Merge apr and apr-util sections, support apr-2 (which also ignores
>    apr-util library). In pkg-config branch we check for different names of
>    the config, while module branch adds apr-util only if apr version is
>    not '2'.
>
> Modified:
>     subversion/trunk/CMakeLists.txt
>     subversion/trunk/build/cmake/FindAPR.cmake
>     subversion/trunk/build/cmake/FindSerf.cmake
>
> Modified: subversion/trunk/CMakeLists.txt
> URL: http://svn.apache.org/viewvc/subversion/trunk/CMakeLists.txt?rev=1926349&r1=1926348&r2=1926349&view=diff
> ==============================================================================
> --- subversion/trunk/CMakeLists.txt (original)
> +++ subversion/trunk/CMakeLists.txt Tue Jun 10 22:00:42 2025
> @@ -260,24 +260,33 @@ if(SVN_USE_PKG_CONFIG)
>    find_package(PkgConfig REQUIRED)
>  endif()
>
> -### APR
> +### APR and APR-Util
>
>  if(SVN_USE_PKG_CONFIG)
> -  pkg_check_modules(apr-1 REQUIRED IMPORTED_TARGET apr-1)
> -  add_library(external-apr ALIAS PkgConfig::apr-1)
> +  pkg_check_modules(apr IMPORTED_TARGET apr-1)
> +
> +  if(apr_FOUND)
> +    # apr-1
> +    add_library(external-apr ALIAS PkgConfig::apr)
> +
> +    pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
> +    add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
> +  else()
> +    # apr-2
> +    pkg_check_modules(apr REQUIRED IMPORTED_TARGET apr-2)
> +    add_library(external-apr ALIAS PkgConfig::apr)
> +    add_library(external-aprutil ALIAS PkgConfig::apr)
> +  endif()
>  else()
>    find_package(APR REQUIRED)
>    add_library(external-apr ALIAS apr::apr)
> -endif()
>
> -### APR-Util
> -
> -if(SVN_USE_PKG_CONFIG)
> -  pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
> -  add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
> -else()
> -  find_package(APRUtil REQUIRED)
> -  add_library(external-aprutil ALIAS apr::aprutil)
> +  if(APR_MAJOR_VERSION EQUAL 2)
> +    add_library(external-aprutil ALIAS apr::apr)
>
>
>
> Should be "major version greater than 1"
>
>
Even better to use VERSION_LESS: r1926351.


>
> [...]
>
> The more I look at this, the more I'm convinced that if we use serf, we
> should also use the same apr and apr-util as Serf does. It's an edge case,
> though.
>
>
Yay! *See?*

-- 
Timofei Zhakov

Re: svn commit: r1926349 - in /subversion/trunk: CMakeLists.txt build/cmake/FindAPR.cmake build/cmake/FindSerf.cmake

Posted by Branko Čibej <br...@apache.org>.
On 11. 6. 25 00:00, rinrab@apache.org wrote:
> Author: rinrab
> Date: Tue Jun 10 22:00:42 2025
> New Revision: 1926349
>
> URL:http://svn.apache.org/viewvc?rev=1926349&view=rev
> Log:
> cmake: Support apr-2.
>
> * build/cmake/FindAPR.cmake
>    (APR_INCLUDE_DIR): Also check apr-2 directory.
>    (version): Read it just after include dir and default it to 1.0.0 version
>     file not found.
>    (APR_LIBRARY_SHARED, APR_LIBRARY_STATIC, APR_DLL): Use APR_MAJOR_VERSION
>     to determine suffix.
> * build/cmake/FindSerf.cmake: Look for apr-util only if apr version is not '2'.
> * CMakeLists.txt
>    (APR): Merge apr and apr-util sections, support apr-2 (which also ignores
>     apr-util library). In pkg-config branch we check for different names of
>     the config, while module branch adds apr-util only if apr version is
>     not '2'.
>
> Modified:
>      subversion/trunk/CMakeLists.txt
>      subversion/trunk/build/cmake/FindAPR.cmake
>      subversion/trunk/build/cmake/FindSerf.cmake
>
> Modified: subversion/trunk/CMakeLists.txt
> URL:http://svn.apache.org/viewvc/subversion/trunk/CMakeLists.txt?rev=1926349&r1=1926348&r2=1926349&view=diff
> ==============================================================================
> --- subversion/trunk/CMakeLists.txt (original)
> +++ subversion/trunk/CMakeLists.txt Tue Jun 10 22:00:42 2025
> @@ -260,24 +260,33 @@ if(SVN_USE_PKG_CONFIG)
>     find_package(PkgConfig REQUIRED)
>   endif()
>   
> -### APR
> +### APR and APR-Util
>   
>   if(SVN_USE_PKG_CONFIG)
> -  pkg_check_modules(apr-1 REQUIRED IMPORTED_TARGET apr-1)
> -  add_library(external-apr ALIAS PkgConfig::apr-1)
> +  pkg_check_modules(apr IMPORTED_TARGET apr-1)
> +
> +  if(apr_FOUND)
> +    # apr-1
> +    add_library(external-apr ALIAS PkgConfig::apr)
> +
> +    pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
> +    add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
> +  else()
> +    # apr-2
> +    pkg_check_modules(apr REQUIRED IMPORTED_TARGET apr-2)
> +    add_library(external-apr ALIAS PkgConfig::apr)
> +    add_library(external-aprutil ALIAS PkgConfig::apr)
> +  endif()
>   else()
>     find_package(APR REQUIRED)
>     add_library(external-apr ALIAS apr::apr)
> -endif()
>   
> -### APR-Util
> -
> -if(SVN_USE_PKG_CONFIG)
> -  pkg_check_modules(aprutil-1 REQUIRED IMPORTED_TARGET apr-util-1)
> -  add_library(external-aprutil ALIAS PkgConfig::aprutil-1)
> -else()
> -  find_package(APRUtil REQUIRED)
> -  add_library(external-aprutil ALIAS apr::aprutil)
> +  if(APR_MAJOR_VERSION EQUAL 2)
> +    add_library(external-aprutil ALIAS apr::apr)


Should be "major version greater than 1"


[...]

The more I look at this, the more I'm convinced that if we use serf, we 
should also use the same apr and apr-util as Serf does. It's an edge 
case, though.

-- Brane