Author: rinrab
Date: Fri Jun 28 21:31:18 2024
New Revision: 1918736
URL: http://svn.apache.org/viewvc?rev=1918736&view=rev
Log:
On the 'cmake' branch: Link against FS and RA modules.
This is done by first adding the modules to SVN_FS_MODULES or SVN_RA_MODULES
CMake variables. After, when declaring dependencies of a target, `fs-lib`
or `ra-libs` dependencies from build.conf will be replaced to
${SVN_FS_MODULES} or ${SVN_RA_MODULES}. After that, they would be expanded
by CMake.
This makes it possible to disable a specific RA or FS modules, because it
just would not be added to a group, so a library would not link with it.
This feature is not currently implemented.
The `gen_cmake.py` file declares the `group` field in the cmake_target class
and then passes it to the CMakeLists.txt.ezt template file, which generates
a `list(APPEND)` [1] command for the SVN_**_MODULES variables.
It is not required to declare these variable before, because CMake guaranties
that `If no variable named <list> exists [...] the elements are appended to
that empty list` [1].
* build/generator/gen_cmake.py
(cmake_target): Add a `group` field to the class.
(Generator.write): Initialize the `group` variable to pass it to the
cmake_target class.
(Generator.write, dependencies loop): If `ra-libs` or `fs-libs` are met,
add ${SVN_**_MODULES} to the libs list.
* build/generator/templates/CMakeLists.txt.ezt
(): If `group` exists, generate a `list(APPEND)` command, to add target
name to the specific by that field group.
References:
[1] https://cmake.org/cmake/help/latest/command/list.html#append
Modified:
subversion/branches/cmake/build/generator/gen_cmake.py
subversion/branches/cmake/build/generator/templates/CMakeLists.txt.ezt
Modified: subversion/branches/cmake/build/generator/gen_cmake.py
URL:
http://svn.apache.org/viewvc/subversion/branches/cmake/build/generator/gen_cmake.py?rev=1918736&r1=1918735&r2=1918736&view=diff
==============================================================================
--- subversion/branches/cmake/build/generator/gen_cmake.py (original)
+++ subversion/branches/cmake/build/generator/gen_cmake.py Fri Jun 28 21:31:18
2024
@@ -29,7 +29,9 @@ class _eztdata(object):
vars(self).update(kw)
class cmake_target():
- def __init__(self, name: str, type: str, sources, libs, msvc_libs,
msvc_objects):
+ def __init__(self, name: str, type: str, sources,
+ libs, msvc_libs, msvc_objects,
+ group: str):
self.name = name
self.type = type
self.sources = sources
@@ -38,6 +40,8 @@ class cmake_target():
self.msvc_libs = msvc_libs
self.msvc_objects = msvc_objects
+ self.group = group
+
self.has_msvc_libs = ezt.boolean(len(msvc_libs) > 0)
self.has_msvc_objects = ezt.boolean(len(msvc_objects) > 0)
@@ -85,6 +89,7 @@ class Generator(gen_base.GeneratorBase):
for target in self.get_install_sources():
target: gen_base.Target
+ group = None
if isinstance(target, gen_base.TargetScript):
# there is nothing to build
@@ -97,9 +102,9 @@ class Generator(gen_base.GeneratorBase):
else:
pass
elif isinstance(target, gen_base.TargetRaModule):
- pass
+ group = "SVN_RA_MODULES"
elif isinstance(target, gen_base.TargetFsModule):
- pass
+ group = "SVN_FS_MODULES"
elif isinstance(target, gen_base.TargetApacheMod):
pass
elif isinstance(target, gen_base.TargetLib):
@@ -112,11 +117,9 @@ class Generator(gen_base.GeneratorBase):
if isinstance(dep, gen_base.TargetLinked):
if dep.external_lib:
if dep.name == "ra-libs":
- # TODO
- pass
+ libs.append("${SVN_RA_MODULES}")
elif dep.name == "fs-libs":
- # TODO
- pass
+ libs.append("${SVN_FS_MODULES}")
elif dep.name in ["apriconv",
"apr_memcache",
"magic",
@@ -157,6 +160,7 @@ class Generator(gen_base.GeneratorBase):
libs = libs,
msvc_libs = msvc_libs,
msvc_objects = msvc_objects,
+ group = group
)
if isinstance(target, gen_base.TargetExe):
Modified: subversion/branches/cmake/build/generator/templates/CMakeLists.txt.ezt
URL:
http://svn.apache.org/viewvc/subversion/branches/cmake/build/generator/templates/CMakeLists.txt.ezt?rev=1918736&r1=1918735&r2=1918736&view=diff
==============================================================================
--- subversion/branches/cmake/build/generator/templates/CMakeLists.txt.ezt
(original)
+++ subversion/branches/cmake/build/generator/templates/CMakeLists.txt.ezt Fri
Jun 28 21:31:18 2024
@@ -46,7 +46,8 @@ endif()
add_library([targets.name][for targets.sources]
[targets.sources][end]
)
-target_include_directories([targets.name] PUBLIC ${SVN_INCLUDE_DIRECTORIES})
+target_include_directories([targets.name] PUBLIC
${SVN_INCLUDE_DIRECTORIES})[if-any targets.group]
+list(APPEND [targets.group] [targets.name])[end]
[end][is targets.type "exe"]
add_executable([targets.name][for targets.sources]
[targets.sources][end]