-
Notifications
You must be signed in to change notification settings - Fork 176
/
CMakeLists.txt
907 lines (754 loc) · 27.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# CMakeLists.txt -- configuration file for CMake build system
#
function(read_version path var major minor patch)
get_filename_component(path ${path} ABSOLUTE)
if (EXISTS ${path})
file(
STRINGS ${path} VERSION_STRINGS
REGEX "#define (${major}|${minor}|${patch})"
)
string(REGEX REPLACE ".*${major} +([0-9]+).*" "\\1" VER_MAJOR ${VERSION_STRINGS})
string(REGEX REPLACE ".*${minor} +([0-9]+).*" "\\1" VER_MINOR ${VERSION_STRINGS})
string(REGEX REPLACE ".*${patch} +([0-9]+).*" "\\1" VER_PATCH ${VERSION_STRINGS})
set(${var} "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}" PARENT_SCOPE)
endif()
endfunction()
cmake_minimum_required(VERSION 3.12)
# CMP0092: MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
# CMP0078: UseSWIG generates standard target names.
if(POLICY CMP0078)
cmake_policy(SET CMP0078 NEW)
else()
# Otherwise, setup this behavior manually.
set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
endif()
# CMP0086: UseSWIG honors SWIG_MODULE_NAME via -module flag.
if(POLICY CMP0086)
cmake_policy(SET CMP0086 NEW)
endif()
read_version(
"subversion/include/svn_version.h" SVN_VERSION
SVN_VER_MAJOR SVN_VER_MINOR SVN_VER_PATCH
)
project("Subversion"
VERSION "${SVN_VERSION}"
LANGUAGES C
)
### Options
include(CMakeDependentOption)
# Build components
option(SVN_ENABLE_SVNXX "Enable compilation of the C++ bindings (requires C++)" OFF)
option(SVN_ENABLE_PROGRAMS "Build Subversion programs (such as svn.exe)" ON)
cmake_dependent_option(SVN_ENABLE_TOOLS "Build Subversion tools" ON "SVN_ENABLE_TESTS" OFF)
option(SVN_ENABLE_TESTS "Build Subversion test-suite" OFF)
option(EXPAND_TESTS "Expand tests; This will slow-down configuration, but you will have an ability to run any subtest" OFF)
option(SVN_TEST_CONFIGURE_FOR_PARALLEL "Configures tests for parallel run execution" OFF)
option(SVN_ENABLE_APACHE_MODULES "Build modules for Apache HTTPD" OFF)
option(SVN_ENABLE_SWIG_PERL "Enable Subversion SWIG bindings for Perl" OFF)
option(SVN_ENABLE_SWIG_PYTHON "Enable Subversion SWIG bindings into Python" OFF)
option(SVN_ENABLE_SWIG_RUBY "Enable Subversion SWIG bindings into Ruby" OFF)
# Enable modules and features
option(SVN_ENABLE_RA_LOCAL "Enable Subversion Local Repository Access Library" ON)
option(SVN_ENABLE_RA_SERF "Enable Subversion HTTP/WebDAV Protocol Repository Access Library" OFF)
option(SVN_ENABLE_RA_SVN "Enable Subversion SVN Protocol Repository Access Library" ON)
option(SVN_ENABLE_FS_FS "Enable Subversion FSFS Repository Filesystem Library" ON)
option(SVN_ENABLE_FS_X "Enable Subversion FSX Repository Filesystem Library" ON)
option(SVN_ENABLE_FS_BASE "Enable Subversion Filesystem Base Library (NOT IMPLEMENTED and DEPRECATED)" OFF)
option(SVN_ENABLE_NLS "Enable gettext functionality" OFF)
option(SVN_ENABLE_AUTH_KWALLET "Enable KWallet auth library" OFF)
option(SVN_ENABLE_AUTH_GNOME_KEYRING "Enable GNOME Keyring for auth credentials" OFF)
cmake_dependent_option(SVN_ENABLE_AUTH_GPG_AGENT "Enable GPG Agent support" OFF "WIN32" ON)
option(SVN_INSTALL_PRIVATE_H "Install private header files." OFF)
# Configuration
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
cmake_dependent_option(SVN_BUILD_SHARED_FS "Build shared FS modules" ON "BUILD_SHARED_LIBS" OFF)
cmake_dependent_option(SVN_BUILD_SHARED_RA "Build shared RA modules" ON "BUILD_SHARED_LIBS" OFF)
option(SVN_DEBUG "Enables specific features for developer builds" OFF)
cmake_dependent_option(SVN_USE_WIN32_CRASHHANDLER "Enables WIN32 crash handler." ON "WIN32" OFF)
option(SVN_USE_DSO "Defined if svn should try to load DSOs" OFF)
set(SVN_SOVERSION "0" CACHE STRING "Subversion library ABI version")
mark_as_advanced(SVN_SOVERSION)
# Dependecies
option(SVN_USE_INTERNAL_LZ4 "Use internal version of lz4" ON)
option(SVN_USE_INTERNAL_UTF8PROC "Use internal version of utf8proc" ON)
option(SVN_SQLITE_USE_AMALGAMATION "Use sqlite amalgamation" OFF)
set(SQLiteAmalgamation_ROOT "${CMAKE_SOURCE_DIR}/sqlite-amalgamation" CACHE STRING "Directory with sqlite amalgamation")
# Require C++ compiler
if (SVN_ENABLE_SVNXX OR SVN_ENABLE_AUTH_KWALLET)
# TODO: Also add SVN_ENABLE_JAVAHL to the conditions when they done.
enable_language(CXX)
endif()
set(PRIVATE_CONFIG_DEFINITIONS "")
macro(add_private_config_definition comment name value)
string(APPEND PRIVATE_CONFIG_DEFINITIONS
"\n"
"/* ${comment} */\n"
)
if("${value}" STREQUAL "")
string(APPEND PRIVATE_CONFIG_DEFINITIONS
"#define ${name}\n"
)
else()
string(APPEND PRIVATE_CONFIG_DEFINITIONS
"#define ${name} ${value}\n"
)
endif()
endmacro()
if (SVN_ENABLE_RA_LOCAL)
add_private_config_definition(
"Defined if libsvn_ra should link against libsvn_ra_local"
"SVN_LIBSVN_RA_LINKS_RA_LOCAL" "1"
)
endif()
if (SVN_ENABLE_RA_SERF)
add_private_config_definition(
"Defined if libsvn_ra should link against libsvn_ra_serf"
"SVN_LIBSVN_RA_LINKS_RA_SERF" "1"
)
endif()
if (SVN_ENABLE_RA_SVN)
add_private_config_definition(
"Defined if libsvn_ra should link against libsvn_ra_svn"
"SVN_LIBSVN_RA_LINKS_RA_SVN" "1"
)
endif()
if (SVN_ENABLE_FS_FS)
add_private_config_definition(
"Defined if libsvn_fs should link against libsvn_fs_fs"
"SVN_LIBSVN_FS_LINKS_FS_FS" "1"
)
endif()
if (SVN_ENABLE_FS_X)
add_private_config_definition(
"Defined if libsvn_fs should link against libsvn_fs_x"
"SVN_LIBSVN_FS_LINKS_FS_X" "1"
)
endif()
if(SVN_ENABLE_AUTH_KWALLET)
if(NOT BUILD_SHARED_LIBS)
message(SEND_ERROR "SVN_ENABLE_AUTH_KWALLET is not supported in static build.")
endif()
add_private_config_definition(
"Defined if KWallet support is enabled"
"SVN_HAVE_KWALLET" "1"
)
endif()
if(SVN_ENABLE_AUTH_GPG_AGENT)
add_private_config_definition(
"Is GPG Agent support enabled?"
"SVN_HAVE_GPG_AGENT" "1"
)
endif()
if (SVN_DEBUG)
add_compile_definitions("SVN_DEBUG")
endif()
if(SVN_USE_DSO)
add_private_config_definition(
"Defined if svn should try to load DSOs"
"SVN_USE_DSO" "1"
)
endif()
add_private_config_definition(
"Shared library file name suffix format"
"SVN_DSO_SUFFIX_FMT" "\"%d${CMAKE_SHARED_LIBRARY_SUFFIX}\""
)
add_private_config_definition(
"Subversion library major version"
"SVN_SOVERSION" "${SVN_SOVERSION}"
)
if (SVN_ENABLE_TESTS)
enable_testing()
endif()
if(SVN_BUILD_SHARED_FS)
set(SVN_FS_BUILD_TYPE SHARED)
else()
set(SVN_FS_BUILD_TYPE STATIC)
endif()
if(SVN_BUILD_SHARED_RA)
set(SVN_RA_BUILD_TYPE SHARED)
else()
set(SVN_RA_BUILD_TYPE STATIC)
endif()
if(SVN_ENABLE_FS_BASE)
message(FATAL_ERROR "SVN_ENABLE_FS_BASE is NOT implemented and deprecated.")
endif()
if(BUILD_SHARED_LIBS OR SVN_BUILD_SHARED_FS OR SVN_BUILD_SHARED_RA)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# Setup modules path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
### APR
find_package(APR REQUIRED)
add_library(external-apr ALIAS apr::apr)
### APR-Util
find_package(APRUtil REQUIRED)
add_library(external-aprutil ALIAS apr::aprutil)
### ZLIB
find_package(ZLIB REQUIRED)
add_library(external-zlib ALIAS ZLIB::ZLIB)
### EXPAT
find_package(EXPAT REQUIRED)
add_library(external-xml ALIAS EXPAT::EXPAT)
### LZ4
if(SVN_USE_INTERNAL_LZ4)
add_library(external-lz4 INTERFACE)
target_compile_definitions(external-lz4 INTERFACE "SVN_INTERNAL_LZ4")
read_version(
"subversion/libsvn_subr/lz4/lz4internal.h" lz4_VERSION
LZ4_VERSION_MAJOR LZ4_VERSION_MINOR LZ4_VERSION_RELEASE
)
else()
find_package(lz4 CONFIG REQUIRED)
add_library(external-lz4 ALIAS lz4::lz4)
endif()
### UTF8PROC
if(SVN_USE_INTERNAL_UTF8PROC)
add_library(external-utf8proc INTERFACE)
target_compile_definitions(external-utf8proc INTERFACE "SVN_INTERNAL_UTF8PROC")
read_version(
"subversion/libsvn_subr/utf8proc/utf8proc_internal.h" UTF8PROC_VERSION
UTF8PROC_VERSION_MAJOR UTF8PROC_VERSION_MINOR UTF8PROC_VERSION_PATCH
)
else()
find_package(UTF8PROC REQUIRED)
add_library(external-utf8proc ALIAS UTF8PROC::UTF8PROC)
endif()
### SQLite3
if(SVN_SQLITE_USE_AMALGAMATION)
find_package(SQLiteAmalgamation REQUIRED)
add_library(external-sqlite ALIAS SQLite::SQLite3Amalgamation)
else()
# It should be not required.
find_package(SQLite3)
if(SQLite3_FOUND)
add_library(external-sqlite ALIAS SQLite::SQLite3)
else()
find_package(SQLiteAmalgamation REQUIRED)
add_library(external-sqlite ALIAS SQLite::SQLite3Amalgamation)
# Is implicitness an actual problem? This warning could be removed
# if it isn't.
message(WARNING
"Implicitly using SQLite amalgamation; enable"
"SVN_SQLITE_USE_AMALGAMATION option to force it."
)
endif()
endif()
### Serf
if (SVN_ENABLE_RA_SERF)
find_package(Serf REQUIRED)
add_library(external-serf ALIAS Serf::Serf)
endif()
### Python
if(SVN_ENABLE_SWIG_PYTHON)
find_package(Python REQUIRED COMPONENTS
Interpreter
Development.Embed
)
elseif(SVN_ENABLE_TESTS)
find_package(Python REQUIRED COMPONENTS
Interpreter
)
endif()
### Httpd
if(SVN_ENABLE_APACHE_MODULES)
find_package(Httpd REQUIRED)
add_library(external-libhttpd ALIAS httpd::httpd)
add_library(external-mod_dav ALIAS httpd::mod_dav)
endif()
### KWallet
if(SVN_ENABLE_AUTH_KWALLET)
find_package(KF5Wallet REQUIRED)
find_package(KF5CoreAddons REQUIRED)
find_package(KF5I18n REQUIRED)
find_package(DBus1 REQUIRED)
find_package(Qt5 COMPONENTS Core REQUIRED)
add_library(external-kwallet INTERFACE)
target_link_libraries(external-kwallet INTERFACE
KF5::Wallet
KF5::CoreAddons
KF5::I18n
Qt5::Core
dbus-1
)
target_compile_definitions(external-kwallet INTERFACE SVN_HAVE_KF5)
endif()
### GNOME Keyring
if(SVN_ENABLE_AUTH_GNOME_KEYRING)
add_library(external-gnome-keyring INTERFACE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libsecret-1 REQUIRED IMPORTED_TARGET libsecret-1)
target_link_libraries(external-gnome-keyring INTERFACE PkgConfig::libsecret-1)
add_private_config_definition(
"Is libsecret support enabled?"
"SVN_HAVE_LIBSECRET" "1"
)
endif()
if(SVN_ENABLE_SWIG_PERL OR SVN_ENABLE_SWIG_PYTHON OR SVN_ENABLE_SWIG_RUBY)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/subversion/bindings/swig/proxy")
set(SWIG_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig/include
${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig
${CMAKE_CURRENT_SOURCE_DIR}/subversion/include
${CMAKE_CURRENT_BINARY_DIR}/subversion/bindings/swig/proxy
${CMAKE_CURRENT_BINARY_DIR}
)
add_library(external-swig INTERFACE)
file(GLOB swig_headers_input "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include/*.h")
set(swig_headers_output)
foreach(swig_header ${swig_headers_input})
get_filename_component(filename ${swig_header} NAME_WLE)
set(output "${CMAKE_CURRENT_BINARY_DIR}/subversion/bindings/swig/proxy/${filename}_h.swg")
list(APPEND swig_headers_output ${output})
add_custom_command(
DEPENDS
"${swig_header}"
OUTPUT
"${output}"
WORKING_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}"
COMMAND
"${Python3_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/build/generator/swig/header_wrappers.py"
"${CMAKE_CURRENT_SOURCE_DIR}/build.conf"
"${SWIG_EXECUTABLE}"
"${swig_header}"
COMMAND_EXPAND_LISTS
)
endforeach()
add_custom_target(swig_headers DEPENDS ${swig_headers_output})
add_dependencies(external-swig swig_headers)
endif()
function(swig_target_external_runtime target lang)
set(swig_runtime_path "${CMAKE_CURRENT_BINARY_DIR}/subversion/bindings/swig/proxy/swig_${lang}_external_runtime.swg")
add_custom_command(
OUTPUT ${swig_runtime_path}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND
"${Python3_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/build/generator/swig/external_runtime.py"
"${CMAKE_CURRENT_SOURCE_DIR}/build.conf"
"${SWIG_EXECUTABLE}"
"${lang}"
COMMAND_EXPAND_LISTS
)
target_sources(${target} INTERFACE ${swig_runtime_path})
endfunction()
if(SVN_ENABLE_SWIG_PYTHON)
find_package(PY3C REQUIRED)
add_library(external-python INTERFACE)
target_link_libraries(external-python INTERFACE
Python::Python
Python::py3c
)
target_include_directories(external-python INTERFACE
${SWIG_INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig/python/libsvn_swig_py
)
swig_target_external_runtime(external-python python)
endif()
if(SVN_ENABLE_SWIG_PERL)
find_package(Perl REQUIRED)
find_package(PerlLibs REQUIRED)
separate_arguments(PERL_EXTRA_C_FLAGS)
add_library(external-perl IMPORTED INTERFACE)
target_include_directories(external-perl INTERFACE
${PERL_INCLUDE_PATH}
${SWIG_INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig/perl/libsvn_swig_perl
)
target_compile_definitions(external-perl INTERFACE "__inline__=__inline")
target_compile_options(external-perl INTERFACE ${PERL_EXTRA_C_FLAGS})
target_link_libraries(external-perl INTERFACE ${PERL_LIBRARY})
swig_target_external_runtime(external-perl perl)
endif()
if(SVN_ENABLE_SWIG_RUBY)
find_package(Ruby REQUIRED)
add_library(external-ruby IMPORTED INTERFACE)
target_include_directories(external-ruby INTERFACE
${Ruby_INCLUDE_DIRS}
${SWIG_INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig/ruby/libsvn_swig_ruby
)
target_compile_definitions(external-ruby INTERFACE HAVE_RB_ERRINFO)
target_link_libraries(external-ruby INTERFACE ${Ruby_LIBRARY})
swig_target_external_runtime(external-ruby ruby)
endif()
function(target_exports target_name)
if (WIN32)
set(filter_names
# svn_config_enumerator_t looks like (to our regex) a
# function declaration for svn_boolean_t
"svn_boolean_t"
# Not available on Windows
"svn_auth_get_keychain_simple_provider"
"svn_auth_get_keychain_ssl_client_cert_pw_provider"
"svn_auth_get_gnome_keyring_simple_provider"
"svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider"
"svn_auth_get_kwallet_simple_provider"
"svn_auth_get_kwallet_ssl_client_cert_pw_provider"
"svn_auth_gnome_keyring_version"
"svn_auth_kwallet_version"
"svn_auth_get_gpg_agent_simple_provider"
"svn_auth_gpg_agent_version"
# Unavailable in release mode
"svn_fs_base__trail_debug"
)
set(def_file_path ${CMAKE_BINARY_DIR}/${target_name}.def)
# see build/generator/extractor.py
set(func_regex "(^|\n)((([A-Za-z0-9_]+|[*]) )+[*]?)?((svn|apr)_[A-Za-z0-9_]+)[ \t\r\n]*\\(")
set(defs)
foreach(file ${ARGN})
file(READ ${file} contents)
string(REGEX MATCHALL "${func_regex}" funcs ${contents})
foreach(func_string ${funcs})
string(REGEX MATCH "[A-Za-z0-9_]+[ \t\r\n]*\\($" func_name ${func_string})
string(REGEX REPLACE "[ \t\r\n]*\\($" "" func_name ${func_name})
list(APPEND defs "${func_name}")
endforeach()
get_filename_component(filename ${file} NAME)
if(${filename} STREQUAL "svn_ctype.h")
# See libsvn_subr/ctype.c for an explanation why we use CONSTANT and not
# DATA, even though it causes an LNK4087 warning!
list(APPEND defs "svn_ctype_table = svn_ctype_table_internal CONSTANT")
elseif(${filename} STREQUAL "svn_wc_private.h")
# svn_wc__internal_walk_children() is now internal to libsvn_wc
# but entries-dump.c still calls it
list(APPEND defs "svn_wc__internal_walk_children")
endif()
endforeach()
list(SORT defs)
list(REMOVE_DUPLICATES defs)
set(def_file_content "EXPORTS\n")
foreach(def ${defs})
list(FIND filter_names "${def}" skip)
if(skip LESS 0)
string(APPEND def_file_content "${def}\n")
endif()
endforeach()
if(EXISTS "${def_file_path}")
file(READ "${def_file_path}" old_file_content)
else()
set(old_file_content "NOT_EXISTS")
endif()
if(NOT ${old_file_content} STREQUAL ${def_file_content})
file(WRITE "${def_file_path}" ${def_file_content})
endif()
target_sources("${target_name}" PRIVATE "${def_file_path}")
endif()
endfunction()
### Checks
include(CheckIncludeFiles)
include(CheckSymbolExists)
macro(autocheck_include_files INCLUDE VARIABLE)
check_include_files(${INCLUDE} ${VARIABLE})
if(${VARIABLE})
add_private_config_definition(
"Define to 1 if you have the <${INCLUDE}> header file."
"${VARIABLE}" "1"
)
endif()
endmacro()
macro(autocheck_symbol_exists SYMBOL FILE VARIABLE)
check_symbol_exists(${SYMBOL} ${FILE} ${VARIABLE})
if(${VARIABLE})
add_private_config_definition(
"Define to 1 if you have the `${SYMBOL}' function."
"${VARIABLE}" "1"
)
endif()
endmacro()
autocheck_include_files("elf.h" HAVE_ELF_H)
autocheck_include_files("inttypes.h" HAVE_INTTYPES_H)
autocheck_include_files("stdbool.h" HAVE_STDBOOL_H)
autocheck_include_files("stdint.h" HAVE_STDINT_H)
autocheck_include_files("sys/utsname.h" HAVE_SYS_UTSNAME_H)
if (HAVE_SYS_UTSNAME_H)
autocheck_symbol_exists("uname" "sys/utsname.h" HAVE_UNAME)
endif()
autocheck_include_files("sys/types.h" HAVE_SYS_TYPES_H)
autocheck_include_files("termios.h" HAVE_TERMIOS_H)
if(HAVE_TERMIOS_H)
autocheck_symbol_exists("tcgetattr" "termios.h" HAVE_TCGETATTR)
autocheck_symbol_exists("tcsetattr" "termios.h" HAVE_TCSETATTR)
endif()
autocheck_include_files("unistd.h" HAVE_UNISTD_H)
if (HAVE_UNISTD_H)
autocheck_symbol_exists("symlink" "unistd.h" HAVE_SYMLINK)
autocheck_symbol_exists("readlink" "unistd.h" HAVE_READLINK)
autocheck_symbol_exists("getpid" "unistd.h" HAVE_GETPID)
endif()
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
file(GLOB public_headers "subversion/include/*.h")
install(FILES ${public_headers} DESTINATION "include/subversion-1")
if(SVN_INSTALL_PRIVATE_H)
file(GLOB private_headers "subversion/include/private/*.h")
install(FILES ${private_headers} DESTINATION "include/subversion-1/private")
endif()
if(SVN_ENABLE_SVNXX)
install(
DIRECTORY "subversion/bindings/cxx/include/"
DESTINATION "include/subversion-1"
)
endif()
if (WIN32)
add_compile_definitions(
"alloca=_alloca"
"WIN32"
)
endif()
if(APPLE)
add_compile_definitions("DARWIN")
endif()
if (MSVC)
# Setup warning level
add_compile_options(/W4)
# Disable warning
add_compile_options(/wd4100)
add_compile_options(/wd4127)
add_compile_options(/wd4206)
add_compile_options(/wd4512)
add_compile_options(/wd4701)
add_compile_options(/wd4706)
add_compile_options(/wd4800)
# Treat some criticial warnings as error
add_compile_options(/we4002)
add_compile_options(/we4003)
add_compile_options(/we4013)
add_compile_options(/we4020)
add_compile_options(/we4022)
add_compile_options(/we4024)
add_compile_options(/we4028)
add_compile_options(/we4029)
add_compile_options(/we4030)
add_compile_options(/we4031)
add_compile_options(/we4033)
add_compile_options(/we4047)
add_compile_options(/we4089)
add_compile_options(/we4113)
add_compile_options(/we4133)
add_compile_options(/we4204)
add_compile_options(/we4700)
add_compile_options(/we4715)
add_compile_options(/we4789)
add_compile_definitions(
"_CRT_SECURE_NO_DEPRECATE"
"_CRT_NONSTDC_NO_DEPRECATE"
"_CRT_SECURE_NO_WARNINGS"
)
endif()
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/build/cmake/targets.cmake")
message(FATAL_ERROR
"The 'build/cmake/targets.cmake' file does NOT exist. "
"Use the following command to generate it:\n"
" python gen-make.py -t cmake"
)
endif()
add_library(ra-libs INTERFACE)
add_library(fs-libs INTERFACE)
if(SVN_ENABLE_NLS)
# Note: when installing these dependecies with vcpkg, you will need to
# install 'gettext' package with 'tools' feature. Use the following command
# for this: `./vcpkg install gettext[tools]`. This package contains both,
# Gettext and Intl dependecies.
find_package(Gettext REQUIRED)
find_package(Intl REQUIRED)
# If using CMake of version < 3.20, FindIntl would not define IMPORTED target.
# https://cmake.org/cmake/help/latest/module/FindIntl.html
if(NOT TARGET Intl::Intl)
add_library(Intl::Intl INTERFACE IMPORTED)
set_target_properties(Intl::Intl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Intl_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${Intl_LIBRARIES}"
)
endif()
add_library(external-intl ALIAS Intl::Intl)
add_private_config_definition(
"Define to 1 if translation of program messages to the user's native language is requested."
"ENABLE_NLS" "1"
)
add_custom_target(locale ALL)
file(GLOB SVN_PO_FILES "subversion/po/*.po")
foreach(po_file ${SVN_PO_FILES})
get_filename_component(lang ${po_file} NAME_WLE)
set(mo_file "${CMAKE_BINARY_DIR}/${lang}.mo")
add_custom_command(
DEPENDS
"${po_file}"
OUTPUT
"${mo_file}"
COMMAND
"${GETTEXT_MSGFMT_EXECUTABLE}" -c -o ${mo_file} ${po_file}
)
target_sources(locale PRIVATE ${mo_file})
install(
FILES "${mo_file}"
DESTINATION "share/locale/${lang}/LC_MESSAGES"
RENAME "subversion.mo"
)
endforeach()
else()
# Declare empty target for Intl if we don't use it.
add_library(external-intl INTERFACE)
endif()
# Link all targets with Intl library. The 'external-intl' target is always,
# even if we don't use NLS functionality.
#
# Following the CMake documentation [1], the link_libraries affects only on
# the targets declared later, so it should be here.
#
# [1] https://cmake.org/cmake/help/latest/command/link_libraries.html
# -- "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_ENABLE_TESTS)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
set(run_tests_script "${CMAKE_CURRENT_SOURCE_DIR}/build/run_tests.py")
function(add_py_test name prog)
if(SVN_TEST_CONFIGURE_FOR_PARALLEL)
set(test_root "${CMAKE_CURRENT_BINARY_DIR}/Testing/${name}")
else()
set(test_root "${CMAKE_CURRENT_BINARY_DIR}/Testing")
endif()
file(MAKE_DIRECTORY "${test_root}/subversion/tests/cmdline")
add_test(
NAME
"${name}"
COMMAND
"${Python3_EXECUTABLE}" "${run_tests_script}"
--bin ${binary_dir}
--tools-bin ${binary_dir}
--verbose
--log-to-stdout
--set-log-level=WARNING
${CMAKE_CURRENT_SOURCE_DIR}
${test_root}
"${prog}"
WORKING_DIRECTORY
${test_root}
)
endfunction()
file(GLOB PYTHON_TESTS
"subversion/tests/cmdline/*_tests.py"
)
foreach(py_test_abspath ${PYTHON_TESTS})
# Keep `.py'.
get_filename_component(py_test_name ${py_test_abspath} NAME_WLE)
file(RELATIVE_PATH py_test_relpath ${CMAKE_CURRENT_SOURCE_DIR} ${py_test_abspath})
set(binary_dir $<TARGET_FILE_DIR:svn>)
if(EXPAND_TESTS)
message("Listing tests in ${py_test_name}")
execute_process(
COMMAND
"${Python3_EXECUTABLE}" "${run_tests_script}"
--log-to-stdout
--list
${CMAKE_CURRENT_SOURCE_DIR}
${binary_dir}
${py_test_abspath}
OUTPUT_VARIABLE tests_list_output
)
string(REGEX MATCHALL "\n *([0-9]+)" tests_list ${tests_list_output})
foreach(test_num ${tests_list})
string(REGEX MATCH "([0-9]+)" test_num ${test_num})
add_py_test(
"cmdline.${py_test_name}.${test_num}"
"${py_test_relpath}#${test_num}"
)
endforeach()
else()
add_py_test(
"cmdline.${py_test_name}"
"${py_test_relpath}"
)
endif()
endforeach()
endif()
if (SVN_ENABLE_SVNXX)
target_include_directories(libsvnxx PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/cxx/include"
)
endif()
if(SVN_USE_WIN32_CRASHHANDLER)
target_compile_definitions(libsvn_subr PRIVATE
"SVN_USE_WIN32_CRASHHANDLER"
"SVN_WIN32_CRASHREPORT_EMAIL=\"[email protected]\""
)
endif()
if(SVN_ENABLE_SWIG_PYTHON)
add_custom_command(TARGET libsvn_swig_py POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig/python/svn"
"$<TARGET_FILE_DIR:libsvn_swig_py>/PythonPackages/svn"
)
add_custom_command(TARGET libsvn_swig_py POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/subversion/bindings/swig/python/__init__.py"
"$<TARGET_FILE_DIR:libsvn_swig_py>/PythonPackages/libsvn/__init__.py"
)
endif()
string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM_NAME}" SVN_BUILD_HOST)
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}" SVN_BUILD_TARGET)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/subversion/svn_private_config.hc"
"${CMAKE_CURRENT_BINARY_DIR}/svn_private_config.h"
)
message(STATUS "Configuration summary:")
message(STATUS " Version ......................... : ${SVN_VERSION}")
message(STATUS " Build type ...................... : ${CMAKE_BUILD_TYPE}")
message(STATUS " Build shared libraries ........ : ${BUILD_SHARED_LIBS}")
message(STATUS " Build shared FS Modues ........ : ${SVN_BUILD_SHARED_FS}")
message(STATUS " Build shared RA Modues ........ : ${SVN_BUILD_SHARED_RA}")
message(STATUS " FS modules:")
message(STATUS " Enable FSFS ................... : ${SVN_ENABLE_FS_FS}")
message(STATUS " Enable FSX .................... : ${SVN_ENABLE_FS_X}")
message(STATUS " RA modules:")
message(STATUS " Enable file:// ................ : ${SVN_ENABLE_RA_LOCAL}")
message(STATUS " Enable svn:// ................. : ${SVN_ENABLE_RA_SVN}")
message(STATUS " Enable http:// and https://.... : ${SVN_ENABLE_RA_SERF}")
message(STATUS " Auth providers:")
message(STATUS " Enable KWallet integration .... : ${SVN_ENABLE_AUTH_KWALLET}")
message(STATUS " Enable Gnome Keyring .......... : ${SVN_ENABLE_AUTH_GNOME_KEYRING}")
message(STATUS " Enable GPG Agent support ...... : ${SVN_ENABLE_AUTH_GPG_AGENT}")
message(STATUS " Optional modules and targets:")
message(STATUS " Build Apache Modules .......... : ${SVN_ENABLE_APACHE_MODULES}")
message(STATUS " Build programs ................ : ${SVN_ENABLE_PROGRAMS}")
message(STATUS " Build tools ................... : ${SVN_ENABLE_TOOLS}")
message(STATUS " Build test suite .............. : ${SVN_ENABLE_TESTS}")
message(STATUS " Install:")
message(STATUS " Install prefix: ............... : ${CMAKE_INSTALL_PREFIX}")
message(STATUS " Install private headers: ...... : ${SVN_INSTALL_PRIVATE_H}")
message(STATUS " Bindings:")
message(STATUS " Build SVNXX ................... : ${SVN_ENABLE_SVNXX}")
message(STATUS " Build SWIG_PERL ............... : ${SVN_ENABLE_SWIG_PERL}")
message(STATUS " Build SWIG_PYTHON ............. : ${SVN_ENABLE_SWIG_PYTHON}")
message(STATUS " Build SWIG_RUBY ............... : ${SVN_ENABLE_SWIG_RUBY}")