Author: rinrab
Date: Wed Jul 17 18:52:47 2024
New Revision: 1919320
URL: http://svn.apache.org/viewvc?rev=1919320&view=rev
Log:
On the 'cmake' branch: Build static libraries without 'lib' prefix and fix
bug with double 'lib' in name on Linux as implicit change.
Changes brief
-------------
- Skip 'lib' from the start of output name.
- Setup CMAKE_*_LIBRARY_PREFIX variables to add 'lib' to the start of shared
library and implib names and to keep static libraries with the original
name.
How does it work?
-----------------
Firstly, when the output name is renamed to not contain 'lib' at the start, it
will build into just svn_client-1.lib, but since we set
CMAKE_SHARED_LIBRARY_PREFIX and CMAKE_IMPORT_LIBRARY_PREFIX to 'lib', it will
be prepended to the final output name automatically by CMake in shared
configuration, so it will be as it was before ('libsvn_client-1.lib'). Also
after this commit, the name will be left unchanged in static configuration
because CMAKE_STATIC_LIBRARY_PREFIX is set to empty. This repeats the behavior
of gen-win.
The another thing it fixes implicitly is the library names on Linux. On Linux
the CMAKE_SHARED_LIBRARY_PREFIX and CMAKE_IMPORT_LIBRARY_PREFIX variables are
automatically set to be 'lib', so before the OUTPUT_NAME has changed, the
libraries was compiling into files with double 'lib' in the name
(liblibsvn_client-1.so), which is incorrect. After this commit, their
behavior should be same as on Windows.
Also do a little refactoring of the abstraction of setting the name: the
output name is now passed from the generator (gen-cmake.py) to the template
using a field. This field contains a name without 'lib' prefix and also
'-1' postfix for major version. The template now only adds the content of
targets.output_name OUTPUT_NAME without any conversions.
Changes summary
---------------
* build/generator/gen_cmake.py
(get_output_name): New function.
(Generator.write): Add output_name field to the target.
* build/generator/templates/targets.cmake.ezt
(output name): Simply pass output_name here instead of target name with
'-1' added to the end.
* CMakeLists.txt
(CMAKE_*_LIBRARY_PREFIX): Setup these vars and add some comments explaining
them.
Modified:
subversion/branches/cmake/CMakeLists.txt
subversion/branches/cmake/build/generator/gen_cmake.py
subversion/branches/cmake/build/generator/templates/targets.cmake.ezt
Modified: subversion/branches/cmake/CMakeLists.txt
URL: http://svn.apache.org/viewvc/subversion/branches/cmake/CMakeLists.txt?rev=1919320&r1=1919319&r2=1919320&view=diff
==============================================================================
--- subversion/branches/cmake/CMakeLists.txt (original)
+++ subversion/branches/cmake/CMakeLists.txt Wed Jul 17 18:52:47 2024
@@ -360,6 +360,15 @@ endif()
# -- "Link libraries to all targets added later."
link_libraries(external-intl)
+# Build shared libraries and theirs implibs with 'lib' prefix, for example
+# libsvn_subr-1.[lib|a] and libsvn_subr-1.[dll|so]
+set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+set(CMAKE_IMPORT_LIBRARY_PREFIX "lib")
+
+# This tells CMake to build static libraries without any prefix
+# (just svn_subr-1.[lib|a])
+set(CMAKE_STATIC_LIBRARY_PREFIX "")
+
include("build/cmake/targets.cmake")
if (SVN_BUILD_SVNXX)
Modified: subversion/branches/cmake/build/generator/gen_cmake.py
URL: http://svn.apache.org/viewvc/subversion/branches/cmake/build/generator/gen_cmake.py?rev=1919320&r1=1919319&r2=1919320&view=diff
==============================================================================
--- subversion/branches/cmake/build/generator/gen_cmake.py (original)
+++ subversion/branches/cmake/build/generator/gen_cmake.py Wed Jul 17 18:52:47 2024
@@ -55,6 +55,12 @@ def get_module_name(name):
return name[7:].upper()
+def get_output_name(name):
+ if name.startswith("lib"):
+ return name[3:] + "-1"
+ else:
+ return name
+
class Generator(gen_base.GeneratorBase):
_extension_map = {
('exe', 'target'): '.exe',
@@ -171,6 +177,7 @@ class Generator(gen_base.GeneratorBase):
new_target = _eztdata(
name = target.name,
+ output_name = get_output_name(target.name),
type = target_type,
sources = sources,
libs = libs,
Modified: subversion/branches/cmake/build/generator/templates/targets.cmake.ezt
URL: http://svn.apache.org/viewvc/subversion/branches/cmake/build/generator/templates/targets.cmake.ezt?rev=1919320&r1=1919319&r2=1919320&view=diff
==============================================================================
--- subversion/branches/cmake/build/generator/templates/targets.cmake.ezt (original)
+++ subversion/branches/cmake/build/generator/templates/targets.cmake.ezt Wed Jul 17 18:52:47 2024
@@ -28,7 +28,7 @@ if ([targets.enable_condition])[is targe
target_exports([targets.name][for targets.msvc_export]
[targets.msvc_export][end]
)[end]
- set_target_properties([targets.name] PROPERTIES OUTPUT_NAME "[targets.name]-1")
+ set_target_properties([targets.name] PROPERTIES OUTPUT_NAME "[targets.output_name]")
target_include_directories([targets.name] PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
)[if-any targets.group]
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.