Skip to content

Commit c8b0913

Browse files
authored
fix preprocessor defines warning for self-contained header test; add -Wall for this check. Closes #294 (#296)
1 parent 5a0baf0 commit c8b0913

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,19 +496,29 @@ if (NOT "${CMAKE_REQUIRED_INCLUDES}" STREQUAL "")
496496
endif()
497497
foreach(file ${PyPartMC_headers})
498498
set(CMAKE_REQUIRED_INCLUDES "${PYPARTMC_INCLUDE_DIRS};${pybind11_INCLUDE_DIRS}")
499+
set(CMAKE_REQUIRED_FLAGS "-Werror")
500+
string(REGEX REPLACE "[\-./:]" "_" file_var ${file})
499501
check_cxx_source_compiles("
500502
// https://github.com/nlohmann/json/issues/1408
501-
#define HAVE_SNPRINTF
503+
#if defined(_WIN32) || defined(_WIN64)
504+
# define HAVE_SNPRINTF
505+
#endif
502506
#include \"${file}\"
503507
int main() { return 0;}
504508
"
505-
_header_self_contained_${file}
509+
_header_self_contained_${file_var}
506510
)
507511
unset(CMAKE_REQUIRED_INCLUDES)
508-
if (NOT _header_self_contained_${file})
512+
unset(CMAKE_REQUIRED_FLAGS)
513+
if (NOT _header_self_contained_${file_var})
509514
message(SEND_ERROR "non-self-contained header: ${file}")
510-
file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log" tmp)
515+
if (${CMAKE_VERSION} VERSION_LESS "3.26.0")
516+
file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log" tmp)
517+
else()
518+
file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml" tmp)
519+
endif()
511520
message(FATAL_ERROR ${tmp})
512521
endif()
522+
unset(file_var)
513523
endforeach()
514524

0 commit comments

Comments
 (0)