Skip to content

Commit 5fed6ca

Browse files
committed
fix cmake: fixes for local configuration
* Use CPM's `GIT_SHALLOW` to avoid downloading heavy history of Protobuf, gRPC and other packages * `write_package_stub` is no longer needed and only harms with CMake 3.24+. Do the right thing for all versions * Fix cryptopp failing to configure with CPM + cmake-3.30 * Fix configuration of Protobuf from CPM * Use simpler logic for checking availability of Google Benchmark ASLR * Make CPM-downloaded CURL find CPM-downloaded libnghttp2 commit_hash:dcd14490fd6683b17790cf9e4c4f554ebb6f6a96
1 parent f7e9e67 commit 5fed6ca

31 files changed

+90
-67
lines changed

.mapping.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@
583583
"cmake/modules/FindGssApi.cmake":"taxi/uservices/userver/cmake/modules/FindGssApi.cmake",
584584
"cmake/modules/FindPostgreSQLInternal.cmake":"taxi/uservices/userver/cmake/modules/FindPostgreSQLInternal.cmake",
585585
"cmake/modules/FindPythonDev.cmake":"taxi/uservices/userver/cmake/modules/FindPythonDev.cmake",
586+
"cmake/modules/FindRapidJSON.cmake":"taxi/uservices/userver/cmake/modules/FindRapidJSON.cmake",
586587
"cmake/modules/FindRdKafka.cmake":"taxi/uservices/userver/cmake/modules/FindRdKafka.cmake",
587588
"cmake/modules/FindSASL2.cmake":"taxi/uservices/userver/cmake/modules/FindSASL2.cmake",
588589
"cmake/modules/FindUserverGBench.cmake":"taxi/uservices/userver/cmake/modules/FindUserverGBench.cmake",
@@ -5113,7 +5114,6 @@
51135114
"universal/CMakeLists.txt":"taxi/uservices/userver/universal/CMakeLists.txt",
51145115
"universal/README.md":"taxi/uservices/userver/universal/README.md",
51155116
"universal/benchmarks/main.cpp":"taxi/uservices/userver/universal/benchmarks/main.cpp",
5116-
"universal/benchmarks/main_check_aslr_disable.cpp":"taxi/uservices/userver/universal/benchmarks/main_check_aslr_disable.cpp",
51175117
"universal/include/userver/cache/impl/lru.hpp":"taxi/uservices/userver/universal/include/userver/cache/impl/lru.hpp",
51185118
"universal/include/userver/cache/impl/slru.hpp":"taxi/uservices/userver/universal/include/userver/cache/impl/slru.hpp",
51195119
"universal/include/userver/cache/lru_map.hpp":"taxi/uservices/userver/universal/include/userver/cache/lru_map.hpp",

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ include(ModuleHelpers)
188188
include(AddGoogleTests)
189189
include(FindPackageRequired)
190190
include(IncludeWhatYouUse)
191-
include(UserverTestsuite)
191+
include(UserverVenv)
192192
include(UserverCodegenTarget)
193193
include(UserverGenerateComponentsSchemaDocs)
194194
include(UserverGenerateDynamicConfigsDocs)
@@ -212,6 +212,7 @@ if(USERVER_FEATURE_GRPC)
212212
include(SetupProtobuf)
213213
endif()
214214

215+
include(UserverTestsuite) # Uses protobuf version.
215216
if(USERVER_BUILD_TESTS)
216217
include(testsuite/SetupUserverTestsuiteEnv.cmake)
217218
add_subdirectory(testsuite)

cmake/DownloadUsingCPM.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ endif()
2828
# If A uses find_package(B), and we install A and B using CPM, then: 1. make sure to call write_package_stub in SetupB
2929
# 2. make sure to call SetupB at the beginning of SetupA
3030
function(write_package_stub PACKAGE_NAME)
31-
file(WRITE "${CMAKE_BINARY_DIR}/package_stubs/${PACKAGE_NAME}Config.cmake" )
31+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
32+
if(CPM_DONT_UPDATE_MODULE_PATH)
33+
message(FATAL_ERROR "userver does not support CPM_DONT_UPDATE_MODULE_PATH=TRUE")
34+
endif()
35+
else()
36+
# CPM with cmake<3.24 behaves badly for packages normally found via find_package(... CONFIG).
37+
# This is an ugly workaround.
38+
file(WRITE "${CMAKE_BINARY_DIR}/package_stubs/${PACKAGE_NAME}Config.cmake")
39+
endif()
3240
endfunction()
3341

3442
function(_list_subdirectories directory result_list)

cmake/ModuleHelpers.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ macro(_userver_cpm_addpackage name)
371371
NAME ${name}
372372
VERSION ${ARG_CPM_VERSION}
373373
GITHUB_REPOSITORY ${ARG_CPM_GITHUB_REPOSITORY}
374+
GIT_SHALLOW TRUE
374375
URL ${ARG_CPM_URL}
375376
OPTIONS ${ARG_CPM_OPTIONS}
376377
SOURCE_SUBDIR ${ARG_CPM_SOURCE_SUBDIR}

cmake/SetupAbseil.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ endif()
2222
include(DownloadUsingCPM)
2323

2424
cpmaddpackage(
25-
NAME abseil-cpp
25+
NAME absl
2626
VERSION 20230802.1
2727
GIT_TAG 20230802.1
2828
GITHUB_REPOSITORY abseil/abseil-cpp
29+
GIT_SHALLOW TRUE
2930
SYSTEM
3031
PATCHES abseil_pr_1707.patch abseil_pr_1739.patch
31-
OPTIONS "ABSL_PROPAGATE_CXX_STD ON" "ABSL_ENABLE_INSTALL ON"
32+
OPTIONS "ABSL_PROPAGATE_CXX_STD ON" "ABSL_ENABLE_INSTALL OFF"
3233
)
3334

34-
mark_targets_as_system("${abseil-cpp_SOURCE_DIR}")
35+
mark_targets_as_system("${absl_SOURCE_DIR}")
3536
write_package_stub(absl)

cmake/SetupAmqpCPP.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ cpmaddpackage(
1717
NAME amqp-cpp
1818
VERSION 4.3.18
1919
GITHUB_REPOSITORY CopernicaMarketingSoftware/AMQP-CPP
20+
GIT_SHALLOW TRUE
2021
)
2122

2223
target_compile_options(amqpcpp PRIVATE "-Wno-unused-parameter")

cmake/SetupBrotli.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cpmaddpackage(
2121
NAME Brotli
2222
VERSION ${USERVER_BROTLI_VERSION}
2323
GITHUB_REPOSITORY google/brotli
24+
GIT_SHALLOW TRUE
2425
OPTIONS "BROTLI_DISABLE_TESTS TRUE" "BUILD_SHARED_LIBS OFF"
2526
)
2627

cmake/SetupCAres.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cpmaddpackage(
2020
VERSION 1.19.0
2121
GITHUB_REPOSITORY c-ares/c-ares
2222
GIT_TAG cares-1_19_0
23+
GIT_SHALLOW TRUE
2324
OPTIONS "CARES_INSTALL OFF" "CARES_BUILD_TOOLS OFF" "CARES_SHARED OFF" "CARES_STATIC ON"
2425
)
2526

cmake/SetupCCTZ.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cpmaddpackage(
1919
NAME cctz
2020
VERSION 2.3
2121
GITHUB_REPOSITORY google/cctz
22+
GIT_SHALLOW TRUE
2223
OPTIONS "BUILD_TOOLS OFF" "BUILD_EXAMPLES OFF" "BUILD_TESTING OFF"
2324
)
2425
_userver_install_targets(COMPONENT universal TARGETS cctz)

cmake/SetupCURL.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ endif()
4949

5050
include(DownloadUsingCPM)
5151
cpmaddpackage(
52-
NAME curl
52+
NAME CURL
5353
VERSION 7.81
5454
GITHUB_REPOSITORY curl/curl
5555
GIT_TAG curl-7_81_0
56+
GIT_SHALLOW TRUE
5657
OPTIONS "BUILD_CURL_EXE OFF" "BUILD_SHARED_LIBS OFF" "CURL_DISABLE_TESTS ON" "CURL_DISABLE_LDAP ON"
57-
"HAVE_DLOPEN TRUE" ${CURL_LTO_OPTION}
58+
"HAVE_DLOPEN TRUE" "USE_NGHTTP2 TRUE"
59+
"NGHTTP2_INCLUDE_DIR ${NGHTTP2_INCLUDE_DIR}" "NGHTTP2_LIBRARY ${NGHTTP2_LIBRARY}" ${CURL_LTO_OPTION}
5860
)
5961

6062
mark_targets_as_system("${CURL_SOURCE_DIR}")

0 commit comments

Comments
 (0)