Skip to content

Commit

Permalink
Use canonical variables for the installation locations of libraries a…
Browse files Browse the repository at this point in the history
…nd binaries
  • Loading branch information
Andrii Verbytskyi committed Jan 6, 2025
1 parent abb85cb commit 2c08565
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 60 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
PROJECT( DD4hep LANGUAGES NONE)
PROJECT( DD4hep LANGUAGES CXX)
SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DD4hep)

include("GNUInstallDirs")

#################
# Setup version #
#################
Expand Down Expand Up @@ -273,9 +275,9 @@ configure_file(cmake/thisdd4hep.sh bin/thisdd4hep.sh @ONLY)
configure_file(cmake/thisdd4hep_only.sh bin/thisdd4hep_only.sh @ONLY)
configure_file(cmake/run_test.sh bin/run_test.sh @ONLY)

install(FILES ${CMAKE_BINARY_DIR}/bin/thisdd4hep.sh DESTINATION bin )
install(FILES ${CMAKE_BINARY_DIR}/bin/thisdd4hep_only.sh DESTINATION bin )
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/run_test.sh DESTINATION bin )
install(FILES ${CMAKE_BINARY_DIR}/bin/thisdd4hep.sh DESTINATION ${CMAKE_INSTALL_BINDIR} )
install(FILES ${CMAKE_BINARY_DIR}/bin/thisdd4hep_only.sh DESTINATION ${CMAKE_INSTALL_BINDIR} )
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/run_test.sh DESTINATION ${CMAKE_INSTALL_BINDIR} )

install(DIRECTORY cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}
Expand Down
7 changes: 3 additions & 4 deletions DDAlign/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ add_library(DD4hep::DDAlign ALIAS DDAlign)
target_include_directories(DDAlign
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(DDAlign PUBLIC DDCore)
Expand All @@ -27,7 +27,6 @@ dd4hep_add_plugin(DDAlignPlugins SOURCES src/plugins/*.cpp USES DDAlign)

set_target_properties(DDAlign DDAlignPlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})

install(DIRECTORY include/DDAlign DESTINATION include)
install(DIRECTORY include/DDAlign DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS DDAlign DDAlignPlugins EXPORT DD4hep
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
DESTINATION ${CMAKE_INSTALL_LIBDIR})
7 changes: 3 additions & 4 deletions DDCAD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ endif()
target_include_directories(DDCAD
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(DDCAD PUBLIC DD4hep::DDCore assimp::assimp ROOT::RCsg)

Expand All @@ -104,7 +104,6 @@ dd4hep_add_plugin(DDCADPlugins

set_target_properties(DDCAD DDCADPlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})

install(DIRECTORY include/DDCAD DESTINATION include)
install(DIRECTORY include/DDCAD DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS DDCAD DDCADPlugins EXPORT DD4hep
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
DESTINATION ${CMAKE_INSTALL_LIBDIR})
7 changes: 3 additions & 4 deletions DDCond/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ add_library(DD4hep::DDCond ALIAS DDCond)
target_include_directories(DDCond
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(DDCond PUBLIC DD4hep::DDCore)
Expand All @@ -36,7 +36,6 @@ dd4hep_add_plugin(DDCondPlugins

set_target_properties(DDCond DDCondPlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})

install(DIRECTORY include/DDCond DESTINATION include)
install(DIRECTORY include/DDCond DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS DDCond DDCondPlugins EXPORT DD4hep
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
DESTINATION ${CMAKE_INSTALL_LIBDIR})
7 changes: 3 additions & 4 deletions DDCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ endif()
target_include_directories(DDCore
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(DDCore
Expand Down Expand Up @@ -152,11 +152,10 @@ install(DIRECTORY
include/JSON
include/Parsers
include/ROOT
DESTINATION include
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

set_target_properties(DDCore DDCorePlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
install(TARGETS DDCore DDCorePlugins ${OPTIONAL_TARGETS} EXPORT DD4hep
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
3 changes: 1 addition & 2 deletions DDDetectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dd4hep_add_plugin(DDDetectors

set_target_properties(DDDetectors PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
install(TARGETS DDDetectors EXPORT DD4hep
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY compact DESTINATION DDDetectors)
9 changes: 4 additions & 5 deletions DDDigi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ target_link_libraries(DDDigi PUBLIC
target_include_directories(DDDigi
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
#
if(DD4HEP_USE_TBB)
Expand Down Expand Up @@ -82,7 +82,7 @@ dd4hep_add_plugin(DDDigi_IO
DEFINITIONS ${DDDigiIO_DEFINITIONS}
)
set_target_properties(DDDigi_IO PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
install(TARGETS DDDigi_IO EXPORT DD4hep ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
install(TARGETS DDDigi_IO EXPORT DD4hep DESTINATION ${CMAKE_INSTALL_LIBDIR})
#
#---Package installation procedure(s) ----------------------------------------------
set_target_properties(DDDigi DDDigiPlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
Expand All @@ -91,7 +91,6 @@ file(GLOB DDDigi_python python/*.py python/*.C)
install(FILES ${DDDigi_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
#
install(TARGETS DDDigi DDDigiPlugins EXPORT DD4hep
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY include/DDDigi DESTINATION include)
install(DIRECTORY include/DDDigi DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
19 changes: 10 additions & 9 deletions DDEve/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_library(DD4hep::DDEve_Interface ALIAS DDEve_Interface)
target_include_directories(DDEve_Interface
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(DDEve_Interface INTERFACE ROOT::Core ROOT::Rint ROOT::Eve ROOT::Gui ROOT::Graf3d ROOT::RGL ROOT::EG)
Expand Down Expand Up @@ -60,8 +60,7 @@ if(DD4HEP_USE_GEANT4)
target_link_libraries(DDG4IO DD4hep::DDG4 DD4hep::DDEve_Interface)
set_target_properties(DDG4IO PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
install(TARGETS DDG4IO EXPORT DD4hep
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()

Expand All @@ -73,9 +72,11 @@ set_target_properties(DDEvePlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSIO


install(DIRECTORY DDEve DESTINATION examples )
install(DIRECTORY include/DDEve DESTINATION include)
install(TARGETS ddeve DDEvePlugins DDEve_Interface EXPORT DD4hep
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY include/DDEve DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS ddeve EXPORT DD4hep
DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(TARGETS DDEvePlugins DDEve_Interface EXPORT DD4hep
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
2 changes: 1 addition & 1 deletion DDG4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ target_link_libraries(DDG4
target_include_directories(DDG4 BEFORE
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if(NOT Geant4_gdml_FOUND)
Expand Down
7 changes: 3 additions & 4 deletions DDParsers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ ENDIF()
target_include_directories(DDParsers
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(DDParsers PUBLIC ROOT::Core ROOT::GenVector Boost::boost ${XML_LIBRARIES})

set_target_properties(DDParsers PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
install(DIRECTORY include/Parsers include/Evaluator DESTINATION include)
install(DIRECTORY include/Parsers include/Evaluator DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS DDParsers ${OPTIONAL_TARGETS} EXPORT DD4hep
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Unset job pool
SET(CMAKE_JOB_POOL_COMPILE)
7 changes: 3 additions & 4 deletions DDRec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ADD_LIBRARY(DD4hep::DDRec ALIAS DDRec)
TARGET_INCLUDE_DIRECTORIES(DDRec
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

TARGET_LINK_LIBRARIES(DDRec PUBLIC
Expand Down Expand Up @@ -74,8 +74,7 @@ set_target_properties(DDRec DDRecPlugins PROPERTIES VERSION ${DD4hep_VERSION} SO

file(GLOB DDRec_python python/*.py)
install(FILES ${DDRec_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
install(DIRECTORY include/DDRec DESTINATION include)
install(DIRECTORY include/DDRec DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS DDRec DDRecPlugins EXPORT DD4hep
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
8 changes: 4 additions & 4 deletions DDTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ foreach(TEST_NAME
)
add_executable(${TEST_NAME} src/${TEST_NAME}.cc)
target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDTest)
install(TARGETS ${TEST_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${TEST_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

set(cmd ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME})
add_test(NAME t_${TEST_NAME} COMMAND ${cmd} ${TEST_NAME})
Expand All @@ -42,7 +42,7 @@ foreach(TEST_NAME
)
add_executable(${TEST_NAME} src/${TEST_NAME}.cc)
target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDTest)
install(TARGETS ${TEST_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${TEST_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_test(NAME t_${TEST_NAME}
COMMAND ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME} file:${CMAKE_CURRENT_SOURCE_DIR}/units.xml)
set_tests_properties(t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED")
Expand Down Expand Up @@ -114,7 +114,7 @@ if (DD4HEP_USE_GEANT4)
endif()
target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDG4)
target_include_directories(${TEST_NAME} PRIVATE ./include)
install(TARGETS ${TEST_NAME} DESTINATION bin)
install(TARGETS ${TEST_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

add_test(NAME t_${TEST_NAME} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR})
set_tests_properties(t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED")
Expand Down Expand Up @@ -162,7 +162,7 @@ if (DD4HEP_USE_GEANT4)
)

endif()
install(DIRECTORY include/DD4hep DESTINATION include)
install(DIRECTORY include/DD4hep DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})


# Test that GrammarUnparsed and GrammarParsed fail to be compiled
Expand Down
8 changes: 4 additions & 4 deletions GaudiPluginService/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set_target_properties(listcomponents
PROPERTIES
OUTPUT_NAME listcomponents_dd4hep
)
INSTALL(TARGETS listcomponents DD4hepGaudiPluginMgr EXPORT DD4hep
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
INSTALL(TARGETS listcomponents EXPORT DD4hep
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
INSTALL(TARGETS DD4hepGaudiPluginMgr EXPORT DD4hep DESTINATION ${CMAKE_INSTALL_LIBDIR})
2 changes: 1 addition & 1 deletion UtilityApps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ INSTALL(TARGETS geoDisplay
teveDisplay
${OPTIONAL_EXECUTABLES}
EXPORT DD4hep
RUNTIME DESTINATION bin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
2 changes: 1 addition & 1 deletion cmake/DD4hep.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function ( dd4hep_instantiate_package PackageName )
configure_file( ${DD4hep_DIR}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/this${PackageName}.sh
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
)


Expand Down
5 changes: 2 additions & 3 deletions cmake/DD4hepBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ function(dd4hep_add_dictionary dictionary )
)

# Install the binary to the destination directory
install(FILES ${output_dir}/${dictionary}_rdict.pcm DESTINATION lib)
install(FILES ${output_dir}/${dictionary}_rdict.pcm DESTINATION ${CMAKE_INSTALL_LIBDIR})

endfunction()

Expand Down Expand Up @@ -680,8 +680,7 @@ function(dd4hep_add_plugin binary)
set(install_destination ${CMAKE_INSTALL_LIBDIR})
endif()
install(TARGETS ${binary}
ARCHIVE DESTINATION ${install_destination}
LIBRARY DESTINATION ${install_destination}
DESTINATION ${install_destination}
)
endif()
endfunction(dd4hep_add_plugin)
Expand Down
2 changes: 1 addition & 1 deletion cmake/thisdd4hep_package.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dd4hep_add_path PYTHONPATH ${THIS}/@DD4HEP_PYTHON_INSTALL_DIR@;
#----ROOT_INCLUDE_PATH--------------------------------------------------------
dd4hep_add_path ROOT_INCLUDE_PATH ${THIS}/include;
#----LIBRARY_PATH-------------------------------------------------------------
dd4hep_add_library_path ${THIS}/lib;
dd4hep_add_library_path ${THIS}/@CMAKE_INSTALL_LIBDIR@;
# -- need to extend dynamic search path for all external libraries:
if [ @External_LIBRARY_DIRS@ ]; then
for lp in @External_LIBRARY_DIRS@; do
Expand Down
2 changes: 1 addition & 1 deletion examples/CLICSiD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (DD4HEP_USE_GEANT4)

add_executable(CLICSiDAClick scripts/CLICSiDAClick.C)
target_link_libraries(CLICSiDAClick DD4hep::DDCore DD4hep::DDG4)
install(TARGETS CLICSiDXML CLICSiDAClick DESTINATION bin)
install(TARGETS CLICSiDXML CLICSiDAClick DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
#
#
Expand Down

0 comments on commit 2c08565

Please sign in to comment.