From fa33976e3bec14b1864c4f5ba92abb0979ae2edc Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Wed, 16 Oct 2024 18:18:49 -0700 Subject: [PATCH 1/3] fix cmake install config files --- cmake/Config.cmake | 30 +++++++++++++++++++++++++++--- cmake/blt | 2 +- cmake/shiva-config.cmake.in | 18 ++++++++++-------- docs/doxygen/ShivaConfig.hpp | 2 +- scripts/config-build.py | 15 +++++++++++++++ 5 files changed, 54 insertions(+), 13 deletions(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 708f03d..113f302 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -34,8 +34,32 @@ install( FILES ${CMAKE_BINARY_DIR}/include/ShivaConfig.hpp DESTINATION include ) # Configure and install the CMake config -configure_file( ${CMAKE_CURRENT_LIST_DIR}/shiva-config.cmake.in - ${PROJECT_BINARY_DIR}/share/shiva/cmake/shiva-config.cmake) +# configure_file( ${CMAKE_CURRENT_LIST_DIR}/shiva-config.cmake.in +# ${PROJECT_BINARY_DIR}/share/shiva/cmake/shiva-config.cmake) -install( FILES ${PROJECT_BINARY_DIR}/share/shiva/cmake/shiva-config.cmake +# Set up cmake package config file + +set(SHIVA_INSTALL_INCLUDE_DIR "include" CACHE STRING "") +set(SHIVA_INSTALL_CONFIG_DIR "lib" CACHE STRING "") +set(SHIVA_INSTALL_LIB_DIR "lib" CACHE STRING "") +set(SHIVA_INSTALL_BIN_DIR "bin" CACHE STRING "") +set(SHIVA_INSTALL_CMAKE_MODULE_DIR "${SHIVA_INSTALL_CONFIG_DIR}/cmake" CACHE STRING "") +set(SHIVA_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "" FORCE) + + +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/shiva-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/shiva-config.cmake + INSTALL_DESTINATION + ${SHIVA_INSTALL_CONFIG_DIR} + PATH_VARS + SHIVA_INSTALL_INCLUDE_DIR + SHIVA_INSTALL_LIB_DIR + SHIVA_INSTALL_BIN_DIR + SHIVA_INSTALL_CMAKE_MODULE_DIR + ) + + +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/shiva-config.cmake DESTINATION share/shiva/cmake/) diff --git a/cmake/blt b/cmake/blt index f01e062..9ff7734 160000 --- a/cmake/blt +++ b/cmake/blt @@ -1 +1 @@ -Subproject commit f01e0627c617bc658e52632f0922ffbcd6f4bd58 +Subproject commit 9ff77344f0b2a6ee345e452bddd6bfd46cbbfa35 diff --git a/cmake/shiva-config.cmake.in b/cmake/shiva-config.cmake.in index d016f9f..96434d5 100644 --- a/cmake/shiva-config.cmake.in +++ b/cmake/shiva-config.cmake.in @@ -1,10 +1,12 @@ +if( NOT SHIVA_FOUND ) + get_filename_component(SHIVA_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + include(${CMAKE_INSTALL_PREFIX}/lib/cmake/shiva/shiva-targets.cmake) -if( NOT SHIVA_CONFIG_LOADED ) - set( SHIVA_CONFIG_LOADED TRUE ) - include( @CMAKE_INSTALL_PREFIX@/share/shiva/cmake/shiva.cmake ) -endif() -# Export version number -set( SHIVA_VERSION_MAJOR @SHIVA_VERSION_MAJOR@ ) -set( SHIVA_VERSION_MINOR @SHIVA_VERSION_MINOR@ ) -set( SHIVA_VERSION_PATCHLEVEL @SHIVA_VERSION_PATCHLEVEL@ ) + set(SHIVA_FOUND TRUE) + + # Export version number + set( SHIVA_VERSION_MAJOR @SHIVA_VERSION_MAJOR@ ) + set( SHIVA_VERSION_MINOR @SHIVA_VERSION_MINOR@ ) + set( SHIVA_VERSION_PATCHLEVEL @SHIVA_VERSION_PATCHLEVEL@ ) +endif() \ No newline at end of file diff --git a/docs/doxygen/ShivaConfig.hpp b/docs/doxygen/ShivaConfig.hpp index cb43a6e..d89803f 100644 --- a/docs/doxygen/ShivaConfig.hpp +++ b/docs/doxygen/ShivaConfig.hpp @@ -8,7 +8,7 @@ #define SHIVA_VERSION_PATCHLEVEL 0 -#define SHIVA_USE_CUDA +/* #undef SHIVA_USE_CUDA */ /* #undef SHIVA_USE_HIP */ diff --git a/scripts/config-build.py b/scripts/config-build.py index 8e7eda7..a345ac7 100755 --- a/scripts/config-build.py +++ b/scripts/config-build.py @@ -65,6 +65,11 @@ def extract_cmake_location(file_path): type=str, help="select a specific host-config file to initalize CMake's cache") +parser.add_argument("-n", "--ninja", action='store_true', help="Create a ninja project.") +parser.add_argument("-gvz", "--graphviz", action="store_true", help="Generate graphviz dependency graph") + + + args, unknown_args = parser.parse_known_args() if unknown_args: print("[config-build]: Passing the following unknown arguments directly to cmake... %s" % unknown_args) @@ -147,6 +152,14 @@ def extract_cmake_location(file_path): if args.xcode: cmakeline += ' -G Xcode' +if args.ninja: + cmakeline += ' -GNinja' + +if args.graphviz: + cmakeline += " --graphviz=dependency.dot" + dot_line = "dot -Tpng dependency.dot -o dependency.png" + + if unknown_args: cmakeline += " " + " ".join( unknown_args ) @@ -169,6 +182,8 @@ def extract_cmake_location(file_path): try: subprocess.call(cmakeline,shell=True) + if args.graphviz: + subprocess.call(dot_line, shell=True) except: print("CMake failed. See above output for details.") sys.exit(1) From 185295df28fdf4f3d357d24f29159e00055a48b6 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Fri, 18 Oct 2024 13:18:10 -0700 Subject: [PATCH 2/3] fix some of the cmake install issues --- cmake/shiva-config.cmake.in | 3 +-- src/functions/CMakeLists.txt | 8 ++++++-- src/geometry/CMakeLists.txt | 10 ++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmake/shiva-config.cmake.in b/cmake/shiva-config.cmake.in index 96434d5..035662e 100644 --- a/cmake/shiva-config.cmake.in +++ b/cmake/shiva-config.cmake.in @@ -1,6 +1,5 @@ if( NOT SHIVA_FOUND ) - get_filename_component(SHIVA_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - include(${CMAKE_INSTALL_PREFIX}/lib/cmake/shiva/shiva-targets.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/shiva/shiva-targets.cmake) set(SHIVA_FOUND TRUE) diff --git a/src/functions/CMakeLists.txt b/src/functions/CMakeLists.txt index 8a972b5..2d2e73b 100644 --- a/src/functions/CMakeLists.txt +++ b/src/functions/CMakeLists.txt @@ -1,5 +1,6 @@ set( functions_headers + bases/BasisProduct.hpp bases/LagrangeBasis.hpp quadrature/Quadrature.hpp spacing/Spacing.hpp @@ -18,8 +19,11 @@ blt_add_library( NAME functions DEPENDS_ON ${functions_dependencies} ) -install( FILES ${functions_headers} - DESTINATION include/functions ) +foreach( _header ${functions_headers} ) + get_filename_component( _header_dir ${_header} DIRECTORY ) + install( FILES ${_header} + DESTINATION include/functions/${_header_dir} ) +endforeach() install( TARGETS functions EXPORT shiva-targets diff --git a/src/geometry/CMakeLists.txt b/src/geometry/CMakeLists.txt index 9ca9da8..10c5803 100644 --- a/src/geometry/CMakeLists.txt +++ b/src/geometry/CMakeLists.txt @@ -23,8 +23,14 @@ blt_add_library( NAME geometry DEPENDS_ON ${geometry_dependencies} ) -install( FILES ${geometry_headers} - DESTINATION include/geometry ) +foreach( _header ${geometry_headers} ) + get_filename_component( _header_dir ${_header} DIRECTORY ) + install( FILES ${_header} + DESTINATION include/geometry/${_header_dir} ) +endforeach() + +# install( FILES ${geometry_headers} +# DESTINATION include/geometry ) install( TARGETS geometry EXPORT shiva-targets From ab0c9263bb93a587ef0826bab03cc6d8556bc9c1 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Fri, 18 Oct 2024 14:45:33 -0700 Subject: [PATCH 3/3] Update cmake/Config.cmake --- cmake/Config.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 113f302..24e78c7 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -34,8 +34,6 @@ install( FILES ${CMAKE_BINARY_DIR}/include/ShivaConfig.hpp DESTINATION include ) # Configure and install the CMake config -# configure_file( ${CMAKE_CURRENT_LIST_DIR}/shiva-config.cmake.in -# ${PROJECT_BINARY_DIR}/share/shiva/cmake/shiva-config.cmake) # Set up cmake package config file