From 8712e467f45af19594019224ba5f5b946d468684 Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 07:35:50 -0500 Subject: [PATCH 1/8] Update the build of boost as part of the project --- CMakeLists.txt | 141 ++++++++++++++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e78503..5c835fbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +# For external modules that need to be built suppress build output +set(FETCHCONTENT_QUIET TRUE) if (SPECFEMPP_ENABLE_PYTHON) message("-- Adding -fPIC flag for Python binding.") @@ -54,40 +56,43 @@ else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() if (DEFINED Kokkos_ENABLE_CUDA) - if (Kokkos_ENABLE_CUDA) - # message("Setting CUDA variables") - set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "Using CUDA Lambda by default") - set(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE ON CACHE BOOL "Using CUDA Relocatable device by default") - endif() + if (Kokkos_ENABLE_CUDA) + # message("Setting CUDA variables") + set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "Using CUDA Lambda by default") + set(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE ON CACHE BOOL "Using CUDA Relocatable device by default") + endif() endif() + # Install Kokkos as a dependency ## TODO: Add options for on utilizing in house builds include(FetchContent) FetchContent_Declare( -kokkos -URL https://github.com/kokkos/kokkos/archive/refs/tags/4.3.01.zip + kokkos + URL https://github.com/kokkos/kokkos/archive/refs/tags/4.3.01.zip + DOWNLOAD_EXTRACT_TIMESTAMP FALSE ) FetchContent_MakeAvailable(kokkos) FetchContent_Declare( yaml URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz + DOWNLOAD_EXTRACT_TIMESTAMP FALSE ) FetchContent_MakeAvailable(yaml) include_directories(BEFORE SYSTEM ${yaml_BINARY_DIR} ${yaml_SOURCE_DIR}/include) find_package(VTK COMPONENTS -CommonColor -CommonCore -FiltersSources -InteractionStyle -RenderingContextOpenGL2 -RenderingCore -RenderingFreeType -RenderingGL2PSOpenGL2 -RenderingOpenGL2 + CommonColor + CommonCore + FiltersSources + InteractionStyle + RenderingContextOpenGL2 + RenderingCore + RenderingFreeType + RenderingGL2PSOpenGL2 + RenderingOpenGL2 ) @@ -103,25 +108,52 @@ endif() find_package(Boost 1.73.0 COMPONENTS program_options filesystem system) if (NOT ${Boost_FOUND}) - add_subdirectory(boost-cmake) -else () - message(STATUS " LIB: ${Boost_LIBRARY_DIRS}") - message(STATUS " INC: ${Boost_INCLUDE_DIRS}") - message(STATUS " LIBSO: ${Boost_LIBRARIES}") + # Add boost lib sources + set(BOOST_INCLUDE_LIBRARIES program_options filesystem system algorithm) + set(BOOST_ENABLE_CMAKE ON) + set(BOOST_ENABLE_MPI ON CACHE INTERNAL "Boost MPI Switch") # Assume outer variable + set(BOOST_ENABLE_PYTHON OFF CACHE INTERNAL "Boost Python Switch") # Assume outer variable + set(BOOST_BUILD_TESTING OFF CACHE BOOL INTERNAL "Boost Test Switch") # Disable testing for boost + # The test flag is not really working... added it for completeness + + # Download and extract the boost library from GitHub + set(BOOST_VERSION 1.83.0) + message(STATUS "Downloading and extracting boost (${BOOST_VERSION}) library sources. This will take <1 min.") + include(FetchContent) + + # Fetch boost from the Github release zip file to reduce download time + FetchContent_Declare( + Boost + URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}.7z # downloading a zip release speeds up the download + USES_TERMINAL_DOWNLOAD True + GIT_PROGRESS TRUE + DOWNLOAD_NO_EXTRACT FALSE + DOWNLOAD_EXTRACT_TIMESTAMP FALSE + ) + FetchContent_MakeAvailable(Boost) + +else() + # Check which boost LIBRARY_DIRS to use + message(STATUS "Boost libs/ and incs/:") + message(STATUS " LIB: ${Boost_LIBRARY_DIRS}") + message(STATUS " INC: ${Boost_INCLUDE_DIRS}") + message(STATUS " LIBSO: ${Boost_LIBRARIES}") endif() # Install HDF5 as a dependency if not found find_package(HDF5 COMPONENTS CXX) if (NOT ${HDF5_FOUND}) - message("-- HDF5 not found. Building without HDF5.") - set(HDF5_CXX_BUILD OFF) -else () - message(STATUS " LIB: ${HDF5_LIBRARIES}") - message(STATUS " INC: ${HDF5_INCLUDE_DIRS}") - message(STATUS " LIBSO: ${HDF5_CXX_LIBRARIES}") + message("-- HDF5 not found. Building without HDF5.") + set(HDF5_CXX_BUILD OFF) +else() + message("HDF5 libs/ and incs/:.") + message(STATUS " LIB: ${HDF5_LIBRARIES}") + message(STATUS " INC: ${HDF5_INCLUDE_DIRS}") + message(STATUS " LIBSO: ${HDF5_CXX_LIBRARIES}") endif() + configure_file(constants.hpp.in constants.hpp) include_directories(include) @@ -131,13 +163,13 @@ add_subdirectory(fortran/meshfem2d) add_subdirectory(fortran/meshfem3d) if (ENABLE_SIMD) - message("-- Enabling SIMD") - add_definitions(-DENABLE_SIMD) + message("-- Enabling SIMD") + add_definitions(-DENABLE_SIMD) endif() if (ENABLE_PROFILING) - message("-- Enabling profiling") - add_definitions(-DENABLE_PROFILING) + message("-- Enabling profiling") + add_definitions(-DENABLE_PROFILING) endif() # Build specfem2d libraries @@ -172,31 +204,32 @@ add_library( ) if (NOT HDF5_CXX_BUILD) - target_compile_definitions( - IO - PUBLIC -DNO_HDF5 - ) + target_compile_definitions( + IO + PUBLIC -DNO_HDF5 + ) - target_link_libraries( - IO - Boost::boost - Kokkos::kokkos - ) + target_link_libraries( + IO + mesh + source_class + receiver_class + Boost::filesystem + Boost::algorithm + Kokkos::kokkos) else() - target_link_libraries( - IO - ${HDF5_LIBRARIES} - Boost::boost - Kokkos::kokkos - ) + target_link_libraries( + IO + mesh + source_class + receiver_class + Boost::filesystem + Boost::algorithm + Kokkos::kokkos + ${HDF5_LIBRARIES} + ) endif() -target_link_libraries( - IO - mesh - source_class - receiver_class -) add_library( point @@ -365,7 +398,7 @@ target_link_libraries( yaml-cpp point algorithms - Boost::boost + Boost::filesystem ) add_library( @@ -380,7 +413,7 @@ target_link_libraries( # utilities quadrature yaml-cpp - Boost::boost + Boost::filesystem ) add_library( From 49c0af72245f725c0b04ff0e35e5221278c25e8e Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 07:41:01 -0500 Subject: [PATCH 2/8] Removed timestamp warning from the fetch download --- tests/unit-tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 8143c969..58c27e04 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -7,6 +7,7 @@ include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip + DOWNLOAD_EXTRACT_TIMESTAMP FALSE ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) From b623c86caba7b13efabb194027ad5c825e721e13 Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 07:49:50 -0500 Subject: [PATCH 3/8] Forgot the tokenizer dependency of boost --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c835fbb..601ad60d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ find_package(Boost 1.73.0 COMPONENTS program_options filesystem system) if (NOT ${Boost_FOUND}) # Add boost lib sources - set(BOOST_INCLUDE_LIBRARIES program_options filesystem system algorithm) + set(BOOST_INCLUDE_LIBRARIES program_options filesystem system algorithm tokenizer) set(BOOST_ENABLE_CMAKE ON) set(BOOST_ENABLE_MPI ON CACHE INTERNAL "Boost MPI Switch") # Assume outer variable set(BOOST_ENABLE_PYTHON OFF CACHE INTERNAL "Boost Python Switch") # Assume outer variable @@ -216,6 +216,7 @@ if (NOT HDF5_CXX_BUILD) receiver_class Boost::filesystem Boost::algorithm + Boost::tokenizer Kokkos::kokkos) else() target_link_libraries( @@ -225,6 +226,7 @@ else() receiver_class Boost::filesystem Boost::algorithm + Boost::tokenizer Kokkos::kokkos ${HDF5_LIBRARIES} ) From f5e85150c303696a962a57db475e82cd922657cb Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 08:11:21 -0500 Subject: [PATCH 4/8] Increased boost dependency so that the dependencies work on jenkins --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 601ad60d..a07eaa21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ endif() # Try finding boost and if not found install. -find_package(Boost 1.73.0 COMPONENTS program_options filesystem system) +find_package(Boost 1.83.0 COMPONENTS program_options filesystem system) if (NOT ${Boost_FOUND}) # Add boost lib sources From d1700c8f4db75755fbe6422e5db1951ce8fb39f0 Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 08:50:09 -0500 Subject: [PATCH 5/8] Updated installation --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a07eaa21..c40afe36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,26 +105,26 @@ endif() # Try finding boost and if not found install. -find_package(Boost 1.83.0 COMPONENTS program_options filesystem system) +find_package(Boost 1.78.0 COMPONENTS program_options filesystem system) if (NOT ${Boost_FOUND}) # Add boost lib sources set(BOOST_INCLUDE_LIBRARIES program_options filesystem system algorithm tokenizer) set(BOOST_ENABLE_CMAKE ON) - set(BOOST_ENABLE_MPI ON CACHE INTERNAL "Boost MPI Switch") # Assume outer variable + set(BOOST_ENABLE_MPI OFF CACHE INTERNAL "Boost MPI Switch") # Assume outer variable set(BOOST_ENABLE_PYTHON OFF CACHE INTERNAL "Boost Python Switch") # Assume outer variable set(BOOST_BUILD_TESTING OFF CACHE BOOL INTERNAL "Boost Test Switch") # Disable testing for boost # The test flag is not really working... added it for completeness # Download and extract the boost library from GitHub - set(BOOST_VERSION 1.83.0) + set(BOOST_VERSION 1.87.0) message(STATUS "Downloading and extracting boost (${BOOST_VERSION}) library sources. This will take <1 min.") include(FetchContent) # Fetch boost from the Github release zip file to reduce download time FetchContent_Declare( Boost - URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}.7z # downloading a zip release speeds up the download + URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.7z # downloading a zip release speeds up the download USES_TERMINAL_DOWNLOAD True GIT_PROGRESS TRUE DOWNLOAD_NO_EXTRACT FALSE From 0064fe4277c30d52fb9b9b976d6e0ecc4f93d2bb Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 09:00:07 -0500 Subject: [PATCH 6/8] Changed 7z to tar gz checking whether that is the issue --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c40afe36..258218a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ if (NOT ${Boost_FOUND}) # Fetch boost from the Github release zip file to reduce download time FetchContent_Declare( Boost - URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.7z # downloading a zip release speeds up the download + URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.gz # downloading a zip release speeds up the download USES_TERMINAL_DOWNLOAD True GIT_PROGRESS TRUE DOWNLOAD_NO_EXTRACT FALSE From 7cfd82ba6109fb5687fce21b9a1d857315041bd7 Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 09:10:37 -0500 Subject: [PATCH 7/8] skdjf --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 258218a9..e8a2eafa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ endif() # Try finding boost and if not found install. -find_package(Boost 1.78.0 COMPONENTS program_options filesystem system) +find_package(Boost 1.73.0 COMPONENTS program_options filesystem system algorithm tokenizer) if (NOT ${Boost_FOUND}) # Add boost lib sources From 57b2c03141e5590d1641fa7e825485ef6f92cbb1 Mon Sep 17 00:00:00 2001 From: Lucas Sawade Date: Thu, 2 Jan 2025 09:58:50 -0500 Subject: [PATCH 8/8] Made the required boost libraries a variable that is set separately for loaded and built boost --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8a2eafa..34d8fe43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,11 +105,13 @@ endif() # Try finding boost and if not found install. -find_package(Boost 1.73.0 COMPONENTS program_options filesystem system algorithm tokenizer) +find_package(Boost 1.73.0 COMPONENTS program_options filesystem system) + if (NOT ${Boost_FOUND}) # Add boost lib sources set(BOOST_INCLUDE_LIBRARIES program_options filesystem system algorithm tokenizer) + set(BOOST_LIBS Boost::program_options Boost::filesystem Boost::system Boost::algorithm Boost::tokenizer) set(BOOST_ENABLE_CMAKE ON) set(BOOST_ENABLE_MPI OFF CACHE INTERNAL "Boost MPI Switch") # Assume outer variable set(BOOST_ENABLE_PYTHON OFF CACHE INTERNAL "Boost Python Switch") # Assume outer variable @@ -134,6 +136,7 @@ if (NOT ${Boost_FOUND}) else() # Check which boost LIBRARY_DIRS to use + set(BOOST_LIBS Boost::boost Boost::program_options Boost::filesystem Boost::system) message(STATUS "Boost libs/ and incs/:") message(STATUS " LIB: ${Boost_LIBRARY_DIRS}") message(STATUS " INC: ${Boost_INCLUDE_DIRS}") @@ -214,9 +217,7 @@ if (NOT HDF5_CXX_BUILD) mesh source_class receiver_class - Boost::filesystem - Boost::algorithm - Boost::tokenizer + ${BOOST_LIBS} Kokkos::kokkos) else() target_link_libraries( @@ -224,9 +225,7 @@ else() mesh source_class receiver_class - Boost::filesystem - Boost::algorithm - Boost::tokenizer + Kokkos::kokkos ${HDF5_LIBRARIES} ) @@ -400,7 +399,7 @@ target_link_libraries( yaml-cpp point algorithms - Boost::filesystem + ${BOOST_LIBS} ) add_library( @@ -415,7 +414,7 @@ target_link_libraries( # utilities quadrature yaml-cpp - Boost::filesystem + ${BOOST_LIBS} ) add_library( @@ -618,7 +617,7 @@ target_link_libraries( kernels domain solver - Boost::filesystem + ${BOOST_LIBS} ) add_executable( @@ -645,7 +644,7 @@ target_link_libraries( coupled_interface kernels solver - Boost::program_options + ${BOOST_LIBS} ) # Include tests @@ -708,7 +707,7 @@ if (SPECFEMPP_ENABLE_PYTHON) coupled_interface kernels solver - Boost::program_options + ${BOOST_LIBS} pybind11::headers ) target_compile_definitions(_core PRIVATE SPECFEMPP_ENABLE_PYTHON)