Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: make install locations configurable #424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMake/SiloFindHDF5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if(HDF5_FOUND)
# DLL may also be needed by testing infrastructure
get_target_property(HDF5_DLL ${HDF5_C_LIBRARIES} IMPORTED_LOCATION_RELEASE )
if(SILO_ENABLE_SILEX OR SILO_ENABLE_BROWSER)
install(FILES ${HDF5_DLL} DESTINATION bin
install(FILES ${HDF5_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down
2 changes: 1 addition & 1 deletion CMake/SiloFindSzip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if(SZIP_FOUND)
if(WIN32)
get_target_property(SZIP_DLL szip IMPORTED_LOCATION_RELEASE )
if(SILO_ENABLE_SILEX OR SILO_ENABLE_BROWSER)
install(FILES ${SZIP_DLL} DESTINATION bin
install(FILES ${SZIP_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down
2 changes: 1 addition & 1 deletion CMake/SiloFindZlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if(ZLIB_FOUND)
if(WIN32)
get_target_property(ZLIB_DLL zlib IMPORTED_LOCATION_RELEASE)
if(SILO_ENABLE_SILEX OR SILO_ENABLE_BROWSER)
install(FILES ${ZLIB_DLL} DESTINATION bin
install(FILES ${ZLIB_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down
26 changes: 17 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,17 @@ configure_file(${Silo_SOURCE_DIR}/src/silo/silo.h.in
# Create config.h from config.h.in
###-----------------------------------------------------------------------------

# define and populate CMAKE_INSTALL_*DIR variables
include(GNUInstallDirs)

if(SILO_ENABLE_FORTRAN)
enable_language(Fortran)
include(FortranCInterface)
# for config.h
FortranCInterface_HEADER(${silo_build_include_dir}/silo_FC.h MACRO_NAMESPACE "FC_")
if(EXISTS ${silo_build_include_dir}/silo_FC.h)
set(HAVE_SILO_FC_H 1)
install(FILES ${silo_build_include_dir}/silo_FC.h DESTINATION include
install(FILES ${silo_build_include_dir}/silo_FC.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down Expand Up @@ -611,7 +614,7 @@ set(silo_headers
if(WIN32)
list(APPEND silo_headers ${Silo_SOURCE_DIR}/src/silo/silo_win32_compatibility.h)
# Also install silodiff.bat into bin
install(FILES ${Silo_SOURCE_DIR}/resources/silodiff.bat DESTINATION bin
install(FILES ${Silo_SOURCE_DIR}/resources/silodiff.bat DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
Expand All @@ -624,7 +627,7 @@ if(WIN32)
endif()
endif()

install(FILES ${silo_headers} DESTINATION include
install(FILES ${silo_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand All @@ -639,7 +642,7 @@ endif()
# setting up for installing Silo CMake config files
set(silo_targets_name "SiloTargets")
install(TARGETS silo EXPORT ${silo_targets_name}
LIBRARY DESTINATION lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down Expand Up @@ -674,7 +677,7 @@ if(SILO_ENABLE_SILOCK AND NOT WIN32)
target_include_directories(silock PRIVATE
${silo_build_include_dir}
${Silo_SOURCE_DIR}/src/silo)
install(TARGETS silock DESTINATION bin EXPORT ${silo_targets_name}
install(TARGETS silock DESTINATION ${CMAKE_INSTALL_BINDIR} EXPORT ${silo_targets_name}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
Expand All @@ -699,18 +702,23 @@ endif()
# INSTALL
#-----------------------------------------------------------------------------

install(EXPORT ${silo_targets_name} DESTINATION cmake)
###
# Set up the CMAKE install location
###
set(CMAKE_MODULE_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/Silo)

install(EXPORT ${silo_targets_name} DESTINATION ${CMAKE_MODULE_INSTALL_DIR})

include(${CMAKE_ROOT}/Modules/CMakePackageConfigHelpers.cmake)

###
# Set up the include install location for use with the package config files
###
set(INCLUDE_INSTALL_DIR include)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})

configure_package_config_file(${Silo_SOURCE_DIR}/CMake/SiloConfig.cmake.in
${Silo_BINARY_DIR}/cmake/SiloConfig.cmake
INSTALL_DESTINATION cmake
INSTALL_DESTINATION ${CMAKE_MODULE_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR
)

Expand All @@ -723,7 +731,7 @@ write_basic_package_version_file(

install(FILES ${Silo_BINARY_DIR}/cmake/SiloConfig.cmake
${Silo_BINARY_DIR}/cmake/SiloConfigVersion.cmake
DESTINATION cmake
DESTINATION ${CMAKE_MODULE_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down
4 changes: 2 additions & 2 deletions tools/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ if(SILO_ENABLE_HDF5 AND HDF5_FOUND)
target_link_libraries(browser ${HDF5_C_LIBRARIES})
endif()

install(TARGETS browser DESTINATION bin EXPORT ${silo_targets_name}
install(TARGETS browser DESTINATION ${CMAKE_INSTALL_BINDIR} EXPORT ${silo_targets_name}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)

if(NOT WIN32)
install(FILES silodiff silofile
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
Expand Down
6 changes: 3 additions & 3 deletions tools/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ Python_add_library(SiloPy MODULE
# Have the output be relative to the root build dir, not in tools/python subdir
if(WIN32)
# on Windows, the module should live alongside the silo dll, so put it in bin
set(mod_dest bin)
set(mod_dest ${CMAKE_INSTALL_BINDIR})
else()
set(mod_dest lib)
set(mod_dest ${CMAKE_INSTALL_LIBDIR})
endif()

set_target_properties(SiloPy PROPERTIES
Expand All @@ -94,7 +94,7 @@ install(TARGETS SiloPy DESTINATION ${mod_dest} EXPORT ${silo_targets_name}
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)

install(FILES s2ex.py DESTINATION bin
install(FILES s2ex.py DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)
Expand Down
4 changes: 2 additions & 2 deletions tools/silex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ target_include_directories(silex PRIVATE
${Silo_SOURCE_DIR}/src/silo
${Silo_SOURCE_DIR}/tools/silex)

install(TARGETS silex DESTINATION bin EXPORT ${silo_targets_name}
install(TARGETS silex DESTINATION ${CMAKE_INSTALL_BINDIR} EXPORT ${silo_targets_name}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
Expand Down Expand Up @@ -125,7 +125,7 @@ if(WIN32 AND TARGET Qt6::windeployqt)
install(
DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/windeployqt/"
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()

Expand Down