Skip to content

Commit 7560700

Browse files
authored
GCC compile fix (#339)
1 parent c023420 commit 7560700

File tree

4 files changed

+53
-30
lines changed

4 files changed

+53
-30
lines changed

cmake/global_flags.cmake

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ string(APPEND ${COMMON_C_CXX_FLAGS} "\
2828
")
2929

3030
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
31-
# Use .init_array instead of .ctors (default for old clang versions)
32-
# See: https://maskray.me/blog/2021-11-07-init-ctors-init-array
33-
string(APPEND COMMON_C_CXX_FLAGS " -fuse-init-array")
31+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
32+
# Use .init_array instead of .ctors (default for old clang versions)
33+
# See: https://maskray.me/blog/2021-11-07-init-ctors-init-array
34+
string(APPEND COMMON_C_CXX_FLAGS " -fuse-init-array")
35+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
36+
string(APPEND COMMON_C_CXX_FLAGS " -fpermissive")
37+
endif()
3438
endif()
3539

3640
string(APPEND COMMON_C_CXX_FLAGS " -D_FILE_OFFSET_BITS=64")
@@ -64,18 +68,23 @@ endif()
6468
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_CXX_FLAGS}")
6569
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_C_CXX_FLAGS} \
6670
-Woverloaded-virtual \
67-
-Wimport-preprocessor-directive-pedantic \
68-
-Wno-undefined-var-template \
69-
-Wno-return-std-move \
70-
-Wno-defaulted-function-deleted \
7171
-Wno-pessimizing-move \
72-
-Wno-deprecated-anon-enum-enum-conversion \
73-
-Wno-deprecated-enum-enum-conversion \
7472
-Wno-deprecated-enum-float-conversion \
75-
-Wno-ambiguous-reversed-operator \
76-
-Wno-deprecated-volatile \
7773
")
7874

75+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
76+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_C_CXX_FLAGS} \
77+
-Wimport-preprocessor-directive-pedantic \
78+
-Wno-undefined-var-template \
79+
-Wno-return-std-move \
80+
-Wno-defaulted-function-deleted \
81+
-Wno-deprecated-enum-enum-conversion \
82+
-Wno-ambiguous-reversed-operator \
83+
-Wno-deprecated-volatile \
84+
-Wno-deprecated-anon-enum-enum-conversion \
85+
")
86+
endif()
87+
7988
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64|AMD64)$")
8089
set(_ALL_X86_EXTENSIONS_DEFINES "\
8190
${flagPrefixSymbol}DSSE_ENABLED=1 \

contrib/libs/libc_compat/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
_ydb_sdk_add_library(contrib-libs-libc_compat)
22

33
target_compile_options(contrib-libs-libc_compat PRIVATE
4-
$<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
4+
$<IF:$<CXX_COMPILER_ID:Clang>,-Wno-everything,>
55
)
66

77
target_sources(contrib-libs-libc_compat PRIVATE

library/cpp/yt/CMakeLists.txt

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
_ydb_sdk_add_library(yt-assert)
2-
target_compile_options(yt-assert PRIVATE
3-
-Wdeprecated-this-capture
4-
)
2+
3+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
4+
target_compile_options(yt-assert PRIVATE
5+
-Wdeprecated-this-capture
6+
)
7+
endif()
8+
59
target_link_libraries(yt-assert PUBLIC
610
yutil
711
)
@@ -30,9 +34,12 @@ _ydb_sdk_install_targets(TARGETS yt-containers)
3034

3135

3236
_ydb_sdk_add_library(yt-exception)
33-
target_compile_options(yt-exception PRIVATE
34-
-Wdeprecated-this-capture
35-
)
37+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
38+
target_compile_options(yt-exception PRIVATE
39+
-Wdeprecated-this-capture
40+
)
41+
endif()
42+
3643
target_link_libraries(yt-exception PUBLIC
3744
yutil
3845
)
@@ -49,7 +56,7 @@ target_link_libraries(yt-malloc PUBLIC
4956
target_sources(yt-malloc PRIVATE
5057
malloc/malloc.cpp
5158
)
52-
if (NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64"))
59+
if (NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
5360
target_compile_options(yt-malloc PRIVATE
5461
-Wdeprecated-this-capture
5562
)
@@ -79,7 +86,7 @@ target_sources(yt-memory
7986
memory/safe_memory_reader.cpp
8087
memory/shared_range.cpp
8188
)
82-
if (NOT WIN32)
89+
if (NOT WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
8390
target_compile_options(yt-memory PRIVATE
8491
-Wdeprecated-this-capture
8592
)
@@ -88,9 +95,11 @@ _ydb_sdk_install_targets(TARGETS yt-memory)
8895

8996

9097
_ydb_sdk_add_library(yt-misc)
91-
target_compile_options(yt-misc PRIVATE
92-
-Wdeprecated-this-capture
93-
)
98+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
99+
target_compile_options(yt-misc PRIVATE
100+
-Wdeprecated-this-capture
101+
)
102+
endif()
94103
target_link_libraries(yt-misc
95104
PUBLIC
96105
yutil
@@ -118,9 +127,11 @@ _ydb_sdk_install_targets(TARGETS yt-small_containers)
118127

119128

120129
_ydb_sdk_add_library(yt-string)
121-
target_compile_options(yt-string PRIVATE
122-
-Wdeprecated-this-capture
123-
)
130+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
131+
target_compile_options(yt-string PRIVATE
132+
-Wdeprecated-this-capture
133+
)
134+
endif()
124135
target_link_libraries(yt-string
125136
PUBLIC
126137
yutil
@@ -141,9 +152,11 @@ _ydb_sdk_install_targets(TARGETS yt-string)
141152

142153

143154
_ydb_sdk_add_library(yt-yson)
144-
target_compile_options(yt-yson PRIVATE
145-
-Wdeprecated-this-capture
146-
)
155+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
156+
target_compile_options(yt-yson PRIVATE
157+
-Wdeprecated-this-capture
158+
)
159+
endif()
147160
target_link_libraries(yt-yson
148161
PUBLIC
149162
yutil
@@ -171,7 +184,7 @@ target_sources(yt-yson_string PRIVATE
171184
yson_string/convert.cpp
172185
yson_string/string.cpp
173186
)
174-
if (NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64"))
187+
if (NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
175188
target_compile_options(yt-yson_string PRIVATE
176189
-Wdeprecated-this-capture
177190
)

src/client/topic/impl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ target_link_libraries(client-ydb_topic-impl PUBLIC
1414
client-ydb_driver
1515
client-ydb_topic-common
1616
client-ydb_proto
17+
client-ydb_topic-codecs
1718
proto_output
1819
)
1920

0 commit comments

Comments
 (0)