From 9888d9163bbb4f1f4acedc22de284c8afd7fa9b0 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sat, 7 May 2022 11:57:32 +0200 Subject: [PATCH 1/4] Places configured version.h in source dir, for building with FetchContent --- .gitignore | 1 + CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 88e59895d5..b4ed5552f6 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ src/CMakeFiles/ src/bin/ src/cmake_install.cmake src/install_manifest.txt +include/openmc/version.h # Nuclear data scripts/nndc diff --git a/CMakeLists.txt b/CMakeLists.txt index 28f917956a..0e5063c39e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(OPENMC_VERSION_MAJOR 0) set(OPENMC_VERSION_MINOR 13) set(OPENMC_VERSION_RELEASE 1) set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE}) -configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY) +configure_file(include/openmc/version.h.in "${CMAKE_CURRENT_SOURCE_DIR}/include/openmc/version.h" @ONLY) # Setup output directories set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -495,4 +495,3 @@ install(FILES install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(FILES "${CMAKE_BINARY_DIR}/include/openmc/version.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openmc) From 198eb76cab1e25a5a50c026cec9e520fd7ebead9 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 9 May 2022 21:20:08 +0200 Subject: [PATCH 2/4] Revert "Places configured version.h in source dir, for building with FetchContent" This reverts commit 9888d9163bbb4f1f4acedc22de284c8afd7fa9b0. --- .gitignore | 1 - CMakeLists.txt | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b4ed5552f6..88e59895d5 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,6 @@ src/CMakeFiles/ src/bin/ src/cmake_install.cmake src/install_manifest.txt -include/openmc/version.h # Nuclear data scripts/nndc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e5063c39e..28f917956a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(OPENMC_VERSION_MAJOR 0) set(OPENMC_VERSION_MINOR 13) set(OPENMC_VERSION_RELEASE 1) set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE}) -configure_file(include/openmc/version.h.in "${CMAKE_CURRENT_SOURCE_DIR}/include/openmc/version.h" @ONLY) +configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY) # Setup output directories set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -495,3 +495,4 @@ install(FILES install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES "${CMAKE_BINARY_DIR}/include/openmc/version.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openmc) From bd3fe3a893fa91eabc8ff1e0f0990228697248f3 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 9 May 2022 21:22:19 +0200 Subject: [PATCH 3/4] Makes modification to build includes suggested by @paulromano --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28f917956a..3f0d4807aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -394,7 +394,8 @@ target_include_directories(libopenmc target_compile_options(libopenmc PRIVATE ${cxxflags}) # Add include directory for configured version file -target_include_directories(libopenmc PRIVATE ${CMAKE_BINARY_DIR}/include) +target_include_directories(libopenmc + PUBLIC $) if (HDF5_IS_PARALLEL) target_compile_definitions(libopenmc PRIVATE -DPHDF5) From df30923a338561f3e8e5bcea6893f352b508c7b5 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 9 May 2022 21:47:06 +0200 Subject: [PATCH 4/4] Adds include guards to version.h.in --- include/openmc/version.h.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/openmc/version.h.in b/include/openmc/version.h.in index 2933746e2f..e1c2b0541a 100644 --- a/include/openmc/version.h.in +++ b/include/openmc/version.h.in @@ -1,3 +1,6 @@ +#ifndef OPENMC_VERSION_H +#define OPENMC_VERSION_H + #include "openmc/array.h" namespace openmc { @@ -12,3 +15,5 @@ constexpr std::array VERSION {VERSION_MAJOR, VERSION_MINOR, VERSION_RELE // clang-format on } // namespace openmc + +#endif // OPENMC_VERSION_H