Skip to content

Commit

Permalink
fix cmake installed config files (#35)
Browse files Browse the repository at this point in the history
* fix cmake install config files
  • Loading branch information
rrsettgast authored Oct 18, 2024
1 parent 91e2f33 commit 8f3b1b9
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 17 deletions.
28 changes: 25 additions & 3 deletions cmake/Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,30 @@ 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)

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/)
2 changes: 1 addition & 1 deletion cmake/blt
17 changes: 9 additions & 8 deletions cmake/shiva-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
if( NOT SHIVA_FOUND )
include(${CMAKE_CURRENT_LIST_DIR}/../../../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()
2 changes: 1 addition & 1 deletion docs/doxygen/ShivaConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define SHIVA_VERSION_PATCHLEVEL 0

#define SHIVA_USE_CUDA
/* #undef SHIVA_USE_CUDA */

/* #undef SHIVA_USE_HIP */

Expand Down
15 changes: 15 additions & 0 deletions scripts/config-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 )

Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/functions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

set( functions_headers
bases/BasisProduct.hpp
bases/LagrangeBasis.hpp
quadrature/Quadrature.hpp
spacing/Spacing.hpp
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f3b1b9

Please sign in to comment.