Skip to content

Commit 429a6c8

Browse files
committed
feat cmake: unify target names, prefer config mode for conan
Tests: протестировано CI Pull Request resolved: #829 Co-authored-by: Fedor Osetrov <33493672+fdr400@users.noreply.github.com> commit_hash:b291d72a6564d544aaacb1d26e9ecc2abe8f6040
1 parent 48f7ee4 commit 429a6c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+258
-242
lines changed

.github/workflows/alpine.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ jobs:
2525
name: ubuntu-24.04 (build-only)
2626
runs-on: ubuntu-24.04
2727

28+
env:
29+
CMAKE_PROGRAM_PATH: /usr/lib/llvm17/bin
30+
CMAKE_FLAGS: >-
31+
-DCMAKE_BUILD_TYPE=Debug
32+
-DUSERVER_USE_LD=lld
33+
-DUSERVER_NO_WERROR=OFF
34+
-DUSERVER_BUILD_ALL_COMPONENTS=1
35+
-DUSERVER_BUILD_SAMPLES=1
36+
-DUSERVER_BUILD_TESTS=1
37+
-DUSERVER_FEATURE_JEMALLOC=OFF
38+
-DUSERVER_FEATURE_KAFKA=OFF
39+
-DUSERVER_FEATURE_CLICKHOUSE=OFF
40+
-DUSERVER_FEATURE_STACKTRACE=OFF
41+
-DUSERVER_FEATURE_PATCH_LIBPQ=OFF
42+
-DUSERVER_DISABLE_RSEQ_ACCELERATION=YES
43+
-DUSERVER_FORCE_DOWNLOAD_ABSEIL=1
44+
-DUSERVER_FORCE_DOWNLOAD_PROTOBUF=1
45+
-DUSERVER_FORCE_DOWNLOAD_GRPC=1
46+
2847
steps:
2948
- uses: actions/checkout@v4
3049
with:
@@ -88,25 +107,13 @@ jobs:
88107
shell: alpine.sh --root {0}
89108
run: |
90109
pwd
91-
CMAKE_PROGRAM_PATH=/usr/lib/llvm17/bin/ \
92-
cmake -S . -B build_debug \
93-
-DCMAKE_BUILD_TYPE=Debug \
94-
-DUSERVER_USE_LD=lld \
95-
-DUSERVER_NO_WERROR=OFF \
96-
-DUSERVER_BUILD_ALL_COMPONENTS=1 \
97-
-DUSERVER_BUILD_SAMPLES=1 \
98-
-DUSERVER_BUILD_TESTS=1 \
99-
-DUSERVER_FEATURE_JEMALLOC=OFF \
100-
-DUSERVER_FEATURE_KAFKA=OFF \
101-
-DUSERVER_FEATURE_CLICKHOUSE=OFF \
102-
-DUSERVER_FEATURE_STACKTRACE=OFF \
103-
-DUSERVER_FEATURE_PATCH_LIBPQ=OFF \
104-
-DUSERVER_DOWNLOAD_PACKAGE_PROTOBUF=ON \
105-
-DUSERVER_DISABLE_RSEQ_ACCELERATION=YES \
106-
-DUSERVER_FORCE_DOWNLOAD_RE2=1 \
107-
-DUSERVER_FORCE_DOWNLOAD_ABSEIL=1 \
108-
-DUSERVER_FORCE_DOWNLOAD_PROTOBUF=1 \
109-
-DUSERVER_FORCE_DOWNLOAD_GRPC=1 \
110+
cmake -S . -B build_debug $CMAKE_FLAGS
111+
112+
- name: Reconfigure cmake
113+
shell: alpine.sh --root {0}
114+
run: |
115+
pwd
116+
cmake -S . -B build_debug $CMAKE_FLAGS
110117
111118
- name: Compile
112119
shell: alpine.sh --root {0}

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ jobs:
245245
run: |
246246
cmake -S . -B build_debug ${{matrix.cmake-flags}}
247247
248+
- name: Reconfigure cmake
249+
run: |
250+
cmake -S . -B build_debug ${{matrix.cmake-flags}}
251+
248252
- name: Run clang-tidy
249253
if: matrix.info == 'clang-14 + debug + sanitize addr+ub'
250254
run: |

.github/workflows/docker.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,21 @@ jobs:
114114
run: docker-compose -f .github/docker-compose.yml run --rm ${{ matrix.image
115115
}} bash -c 'ccache -M 2.0GB && ccache -s -v'
116116

117-
- name: CMake
117+
- name: Run cmake
118118
run: >-
119119
docker-compose -f .github/docker-compose.yml
120120
run --rm ${{ matrix.image }} bash -c
121121
'cd /userver && cmake -DUSERVER_GOOGLE_COMMON_PROTOS=/app/api-common-protos
122122
${{ matrix.cmake-flags }} -B./build -S./'
123123
124-
- name: Build
124+
- name: Reconfigure cmake
125+
run: >-
126+
docker-compose -f .github/docker-compose.yml
127+
run --rm ${{ matrix.image }} bash -c
128+
'cd /userver && cmake -DUSERVER_GOOGLE_COMMON_PROTOS=/app/api-common-protos
129+
${{ matrix.cmake-flags }} -B./build -S./'
130+
131+
- name: Compile
125132
run: >-
126133
docker-compose -f .github/docker-compose.yml
127134
run --rm ${{ matrix.image }} bash -c

.github/workflows/macos.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ jobs:
8484
run: |
8585
cmake -S./ -B./build_debug -DUSERVER_PYTHON_PATH=$(brew --prefix)/bin/python3.11 $CMAKE_FLAGS
8686
87+
- name: Reconfigure cmake
88+
run: |
89+
cmake -S./ -B./build_debug -DUSERVER_PYTHON_PATH=$(brew --prefix)/bin/python3.11 $CMAKE_FLAGS
90+
8791
- name: Compile
8892
run: |
8993
cmake --build build_debug -j$(nproc) -- -k 1

.mapping.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,34 +452,34 @@
452452
"cmake/install/userver-universal-config.cmake":"taxi/uservices/userver/cmake/install/userver-universal-config.cmake",
453453
"cmake/install/userver-ydb-config.cmake":"taxi/uservices/userver/cmake/install/userver-ydb-config.cmake",
454454
"cmake/modules/FindBrotli.cmake":"taxi/uservices/userver/cmake/modules/FindBrotli.cmake",
455-
"cmake/modules/FindCryptoPP.cmake":"taxi/uservices/userver/cmake/modules/FindCryptoPP.cmake",
456455
"cmake/modules/FindGrpcChannelz.cmake":"taxi/uservices/userver/cmake/modules/FindGrpcChannelz.cmake",
457456
"cmake/modules/FindGssApi.cmake":"taxi/uservices/userver/cmake/modules/FindGssApi.cmake",
458-
"cmake/modules/FindHiredis.cmake":"taxi/uservices/userver/cmake/modules/FindHiredis.cmake",
459-
"cmake/modules/FindJemalloc.cmake":"taxi/uservices/userver/cmake/modules/FindJemalloc.cmake",
460-
"cmake/modules/FindLibEv.cmake":"taxi/uservices/userver/cmake/modules/FindLibEv.cmake",
461-
"cmake/modules/FindNghttp2.cmake":"taxi/uservices/userver/cmake/modules/FindNghttp2.cmake",
462457
"cmake/modules/FindPostgreSQLInternal.cmake":"taxi/uservices/userver/cmake/modules/FindPostgreSQLInternal.cmake",
463-
"cmake/modules/FindPugixml.cmake":"taxi/uservices/userver/cmake/modules/FindPugixml.cmake",
464458
"cmake/modules/FindPythonDev.cmake":"taxi/uservices/userver/cmake/modules/FindPythonDev.cmake",
465459
"cmake/modules/FindRdKafka.cmake":"taxi/uservices/userver/cmake/modules/FindRdKafka.cmake",
466-
"cmake/modules/FindRocksDB.cmake":"taxi/uservices/userver/cmake/modules/FindRocksDB.cmake",
467460
"cmake/modules/FindSASL2.cmake":"taxi/uservices/userver/cmake/modules/FindSASL2.cmake",
468461
"cmake/modules/FindUserverGBench.cmake":"taxi/uservices/userver/cmake/modules/FindUserverGBench.cmake",
469462
"cmake/modules/FindUserverGrpc.cmake":"taxi/uservices/userver/cmake/modules/FindUserverGrpc.cmake",
463+
"cmake/modules/Findamqpcpp.cmake":"taxi/uservices/userver/cmake/modules/Findamqpcpp.cmake",
470464
"cmake/modules/Findbson.cmake":"taxi/uservices/userver/cmake/modules/Findbson.cmake",
471465
"cmake/modules/Findc-ares.cmake":"taxi/uservices/userver/cmake/modules/Findc-ares.cmake",
472466
"cmake/modules/Findcctz.cmake":"taxi/uservices/userver/cmake/modules/Findcctz.cmake",
473467
"cmake/modules/Findclickhouse-cpp.cmake":"taxi/uservices/userver/cmake/modules/Findclickhouse-cpp.cmake",
468+
"cmake/modules/Findcryptopp.cmake":"taxi/uservices/userver/cmake/modules/Findcryptopp.cmake",
474469
"cmake/modules/Findfmt.cmake":"taxi/uservices/userver/cmake/modules/Findfmt.cmake",
470+
"cmake/modules/Findhiredis.cmake":"taxi/uservices/userver/cmake/modules/Findhiredis.cmake",
471+
"cmake/modules/Findjemalloc.cmake":"taxi/uservices/userver/cmake/modules/Findjemalloc.cmake",
472+
"cmake/modules/Findlibev.cmake":"taxi/uservices/userver/cmake/modules/Findlibev.cmake",
475473
"cmake/modules/Findlibgflags.cmake":"taxi/uservices/userver/cmake/modules/Findlibgflags.cmake",
476474
"cmake/modules/Findlibmariadb.cmake":"taxi/uservices/userver/cmake/modules/Findlibmariadb.cmake",
475+
"cmake/modules/Findlibnghttp2.cmake":"taxi/uservices/userver/cmake/modules/Findlibnghttp2.cmake",
477476
"cmake/modules/Findlibsnappy.cmake":"taxi/uservices/userver/cmake/modules/Findlibsnappy.cmake",
478-
"cmake/modules/Findlibyamlcpp.cmake":"taxi/uservices/userver/cmake/modules/Findlibyamlcpp.cmake",
479-
"cmake/modules/Findlibzstd.cmake":"taxi/uservices/userver/cmake/modules/Findlibzstd.cmake",
480477
"cmake/modules/Findlz4.cmake":"taxi/uservices/userver/cmake/modules/Findlz4.cmake",
481478
"cmake/modules/Findmongoc.cmake":"taxi/uservices/userver/cmake/modules/Findmongoc.cmake",
479+
"cmake/modules/Findpugixml.cmake":"taxi/uservices/userver/cmake/modules/Findpugixml.cmake",
482480
"cmake/modules/Findre2.cmake":"taxi/uservices/userver/cmake/modules/Findre2.cmake",
481+
"cmake/modules/Findyaml-cpp.cmake":"taxi/uservices/userver/cmake/modules/Findyaml-cpp.cmake",
482+
"cmake/modules/Findzstd.cmake":"taxi/uservices/userver/cmake/modules/Findzstd.cmake",
483483
"cmake/sanitize-macos.blacklist.txt":"taxi/uservices/userver/cmake/sanitize-macos.blacklist.txt",
484484
"cmake/sanitize.blacklist.txt":"taxi/uservices/userver/cmake/sanitize.blacklist.txt",
485485
"conanfile.py":"taxi/uservices/userver/conanfile.py",

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ option(USERVER_FEATURE_OTLP "Provide asynchronous OTLP exporters" "${USERVER_LIB
144144
set(CMAKE_DEBUG_POSTFIX d)
145145

146146
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
147+
if(USERVER_CONAN AND NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG)
148+
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
149+
endif()
147150

148151
set(USERVER_USE_STATIC_LIBS_DEFAULT OFF)
149152
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0)

clickhouse/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
project(userver-clickhouse CXX)
22

33
if (USERVER_CONAN)
4-
find_package(clickhouse-cpp REQUIRED CONFIG)
5-
set(CLICKHOUSE_CPP_TARGET clickhouse-cpp-lib::clickhouse-cpp-lib)
4+
find_package(clickhouse-cpp REQUIRED)
65
else()
76
include(SetupClickhouseCPP)
8-
set(CLICKHOUSE_CPP_TARGET clickhouse-cpp)
97
endif()
108

119
userver_module(clickhouse
1210
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
13-
LINK_LIBRARIES_PRIVATE "${CLICKHOUSE_CPP_TARGET}"
11+
LINK_LIBRARIES_PRIVATE clickhouse-cpp-lib::clickhouse-cpp-lib
1412

1513
UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp"
1614
DBTEST_SOURCES

cmake/ModuleHelpers.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,12 @@ macro(_userver_module_end)
324324
add_library("${name}" INTERFACE IMPORTED GLOBAL)
325325

326326
if(NOT "${${includes_variable}}" STREQUAL "")
327-
target_include_directories("${name}" INTERFACE ${${includes_variable}})
327+
set_target_properties("${name}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${${includes_variable}}")
328328
message(STATUS "${name} include directories: ${${includes_variable}}")
329329
endif()
330330

331331
if(NOT "${${libraries_variable}}" STREQUAL "")
332-
target_link_libraries("${name}" INTERFACE ${${libraries_variable}})
332+
set_target_properties("${name}" PROPERTIES INTERFACE_LINK_LIBRARIES "${${libraries_variable}}")
333333
message(STATUS "${name} libraries: ${${libraries_variable}}")
334334
endif()
335335
endif()

cmake/SetupBrotli.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ if (NOT USERVER_FORCE_DOWNLOAD_PACKAGES)
1010
endif()
1111

1212
if (Brotli_FOUND)
13-
if(NOT TARGET Brotli::dec)
14-
add_library(Brotli::dec ALIAS brotlidec)
15-
endif()
16-
if(NOT TARGET Brotli::enc)
17-
add_library(Brotli::enc ALIAS brotlienc)
18-
endif()
1913
return()
2014
endif()
2115
endif()

cmake/SetupCAres.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ if (NOT USERVER_FORCE_DOWNLOAD_PACKAGES)
88
endif()
99

1010
if (c-ares_FOUND)
11-
if(NOT TARGET c-ares::cares)
12-
add_library(c-ares::cares ALIAS c-ares)
13-
endif()
1411
return()
1512
endif()
1613
endif()

0 commit comments

Comments
 (0)