Skip to content

Commit f5fb9d9

Browse files
author
Mahesh Pai
committed
Review comments
1 parent ba2aa69 commit f5fb9d9

File tree

1 file changed

+16
-32
lines changed

1 file changed

+16
-32
lines changed

common/test/CMakeLists.txt

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,15 @@ add_executable(integration_test)
7777

7878
target_link_libraries(integration_test count cpc density fi hll kll req sampling theta tuple quantiles common_test_lib)
7979

80-
# Use C++17 if CMAKE_CXX_STANDARD is set to 17+, otherwise C++11
81-
# This allows hardening tests to use std::optional with libc++ hardening
80+
# Use CMAKE_CXX_STANDARD if defined, otherwise C++11
81+
set(_integration_cxx_standard 11)
8282
if(DEFINED CMAKE_CXX_STANDARD)
83-
if(CMAKE_CXX_STANDARD MATCHES "17|20|23")
84-
set_target_properties(integration_test PROPERTIES
85-
CXX_STANDARD ${CMAKE_CXX_STANDARD}
86-
CXX_STANDARD_REQUIRED YES
87-
)
88-
else()
89-
set_target_properties(integration_test PROPERTIES
90-
CXX_STANDARD 11
91-
CXX_STANDARD_REQUIRED YES
92-
)
93-
endif()
94-
else()
95-
set_target_properties(integration_test PROPERTIES
96-
CXX_STANDARD 11
97-
CXX_STANDARD_REQUIRED YES
98-
)
83+
set(_integration_cxx_standard ${CMAKE_CXX_STANDARD})
9984
endif()
85+
set_target_properties(integration_test PROPERTIES
86+
CXX_STANDARD ${_integration_cxx_standard}
87+
CXX_STANDARD_REQUIRED YES
88+
)
10089

10190
add_test(
10291
NAME integration_test
@@ -110,8 +99,7 @@ target_sources(integration_test
11099

111100
# Separate hardening test executable (header-only, no pre-compiled libs)
112101
# This ensures the sketch code is compiled with C++17 + hardening
113-
# Always build this target - it will use CMAKE_CXX_STANDARD if set, otherwise C++17
114-
message(STATUS "CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}")
102+
# Always build this target - it will use CMAKE_CXX_STANDARD if set (and >= 17), otherwise C++17
115103

116104
add_executable(hardening_test)
117105
target_link_libraries(hardening_test common common_test_lib)
@@ -125,19 +113,15 @@ target_include_directories(hardening_test PRIVATE
125113
)
126114

127115
# Use C++17 minimum for hardening tests
128-
if(CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD GREATER_EQUAL 17)
129-
set_target_properties(hardening_test PROPERTIES
130-
CXX_STANDARD ${CMAKE_CXX_STANDARD}
131-
CXX_STANDARD_REQUIRED YES
132-
)
133-
message(STATUS "hardening_test will use C++${CMAKE_CXX_STANDARD}")
134-
else()
135-
set_target_properties(hardening_test PROPERTIES
136-
CXX_STANDARD 17
137-
CXX_STANDARD_REQUIRED YES
138-
)
139-
message(STATUS "hardening_test will use C++17 (default)")
116+
set(_hardening_cxx_standard 17)
117+
if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD GREATER_EQUAL 17)
118+
set(_hardening_cxx_standard ${CMAKE_CXX_STANDARD})
140119
endif()
120+
set_target_properties(hardening_test PROPERTIES
121+
CXX_STANDARD ${_hardening_cxx_standard}
122+
CXX_STANDARD_REQUIRED YES
123+
)
124+
message(STATUS "hardening_test will use C++${_hardening_cxx_standard}")
141125

142126
add_test(
143127
NAME hardening_test

0 commit comments

Comments
 (0)