Skip to content

Commit 9cf1f44

Browse files
authored
Merge pull request #1996 from DLR-AMR/feature-ignore_warnings_in_tests
Bugfix: Ignore warnings when executing CMake tests
2 parents 98ffe9d + 6199720 commit 9cf1f44

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ else()
169169
set( SC_BUILD_EXAMPLES ${T8CODE_BUILD_TPL_EXAMPLES} )
170170
set( SC_BUILD_TESTING ${T8CODE_BUILD_TPL_TESTS} )
171171

172+
# When executing CMake tests for libsc, i.e. check_c_source_compiles/check_cxx_source_compiles and others
173+
# we need to ignore the -Werror option, since these tests often produce warnings (see check_mpicommshared.cmake for example).
174+
# If theses warnings are interpreted as errors, the test fails even though we want it to pass.
175+
# This behaviour caused a serious bug and did not initialize our shared memory. See https://github.com/DLR-AMR/t8code/issues/1985.
176+
set( T8CODE_OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}" )
177+
if (WIN32)
178+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /w" )
179+
else()
180+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -w" )
181+
endif()
182+
172183
# Capture the list of variables before adding the subdirectory to mark the added ones as advanced.
173184
get_cmake_property(_vars_before_sc VARIABLES )
174185
list( APPEND CMAKE_MESSAGE_CONTEXT "sc" )
@@ -219,6 +230,10 @@ else()
219230
message(WARNING "mpi.h not found!")
220231
endif()
221232
########################## End of fix for OpenMPI ############################################
233+
234+
# Reactivate previous CMAKE_REQUIRED_FLAGS
235+
set( CMAKE_REQUIRED_FLAGS "${T8CODE_OLD_CMAKE_REQUIRED_FLAGS}" )
236+
unset( T8CODE_OLD_CMAKE_REQUIRED_FLAGS )
222237
endif()
223238

224239
if ( T8CODE_USE_SYSTEM_P4EST )

0 commit comments

Comments
 (0)