Skip to content

Commit 8a231d3

Browse files
authored
reinstantiate header-independence checks in CMakeLists.txt (was commented out in the nanobind PR) (#437)
1 parent d664b97 commit 8a231d3

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

CMakeLists.txt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
####################################################################################################
22
# This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3-
# Copyright (C) 2022 University of Illinois Urbana-Champaign #
4-
# Author: Sylwester Arabas #
3+
# Copyright (C) 2022-2025 University of Illinois Urbana-Champaign #
4+
# Author: PyPartMC developers (https://github.com/open-atmos/PyPartMC/graphs/contributors) #
55
####################################################################################################
66

77
cmake_minimum_required(VERSION 3.15) # CXX17
@@ -566,32 +566,32 @@ file(GLOB PyPartMC_headers ${CMAKE_SOURCE_DIR}/src/*.hpp)
566566
if (NOT "${CMAKE_REQUIRED_INCLUDES}" STREQUAL "")
567567
message("CMAKE_REQUIRED_INCLUDES not empty! (${CMAKE_REQUIRED_INCLUDES})")
568568
endif()
569-
# foreach(file ${PyPartMC_headers})
570-
# set(CMAKE_REQUIRED_INCLUDES "${PYPARTMC_INCLUDE_DIRS};${pybind11_INCLUDE_DIRS}")
571-
# set(CMAKE_REQUIRED_FLAGS "-Werror")
572-
# string(REGEX REPLACE "[\-./:]" "_" file_var ${file})
573-
# check_cxx_source_compiles("
574-
# // https://github.com/nlohmann/json/issues/1408
575-
# #if defined(_WIN32) || defined(_WIN64)
576-
# # define HAVE_SNPRINTF
577-
# #endif
578-
# #include \"${file}\"
579-
# int main() { return 0;}
580-
# "
581-
# _header_self_contained_${file_var}
582-
# )
583-
# unset(CMAKE_REQUIRED_INCLUDES)
584-
# unset(CMAKE_REQUIRED_FLAGS)
585-
# if (NOT _header_self_contained_${file_var})
586-
# message(SEND_ERROR "non-self-contained header: ${file}")
587-
# if (${CMAKE_VERSION} VERSION_LESS "3.26.0")
588-
# file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log" tmp)
589-
# else()
590-
# file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml" tmp)
591-
# endif()
592-
# message(FATAL_ERROR ${tmp})
593-
# endif()
594-
# unset(file_var)
595-
# endforeach()
569+
foreach(file ${PyPartMC_headers})
570+
set(CMAKE_REQUIRED_INCLUDES "${PYPARTMC_INCLUDE_DIRS};${Python_INCLUDE_DIRS}")
571+
set(CMAKE_REQUIRED_FLAGS "-Werror")
572+
string(REGEX REPLACE "[\-./:]" "_" file_var ${file})
573+
check_cxx_source_compiles("
574+
// https://github.com/nlohmann/json/issues/1408
575+
#if defined(_WIN32) || defined(_WIN64)
576+
# define HAVE_SNPRINTF
577+
#endif
578+
#include \"${file}\"
579+
int main() { return 0;}
580+
"
581+
_header_self_contained_${file_var}
582+
)
583+
unset(CMAKE_REQUIRED_INCLUDES)
584+
unset(CMAKE_REQUIRED_FLAGS)
585+
if (NOT _header_self_contained_${file_var})
586+
message(SEND_ERROR "non-self-contained header: ${file}")
587+
if (${CMAKE_VERSION} VERSION_LESS "3.26.0")
588+
file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log" tmp)
589+
else()
590+
file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml" tmp)
591+
endif()
592+
message(FATAL_ERROR ${tmp})
593+
endif()
594+
unset(file_var)
595+
endforeach()
596596

597597
_install(TARGETS _PyPartMC LIBRARY DESTINATION PyPartMC)

0 commit comments

Comments
 (0)