Skip to content
Snippets Groups Projects
Commit cd4f5c34 authored by Benjamin Morgan's avatar Benjamin Morgan
Browse files

Always link to namespaced CMake targets

All GeoModel targets provide ALIAS targets to their namespaced
equivalents as exported for use later as imported targets. This
renders obsolete the need to check for full/local builds and use different
target names.

Remove use of .._INDIVIDUAL_BUILD variables, consistently link to
namespaced targets.

TODO: fix this in FullSimLight due to incomplete use of FullSimLight
interface target.
parent 1cc28ca0
No related branches found
No related tags found
1 merge request!184Modernisation of CMake scripting to simplify build of FullSimLight
......@@ -21,8 +21,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# Set up how the project handle some of its dependenices. Either by picking them
# up from the environment, or building them itself.
include( SetupJSON )
# Set a flag to steer the of the subpackages
set( ${PROJECT_NAME}_INDIVIDUAL_BUILD ON )
find_package (FullSimLight REQUIRED)
add_definitions (-DFSLPLUGINROOT="${FullSimLight_DIR}/../../../${CMAKE_INSTALL_DATAROOTDIR}" )
message ( STATUS "FSL plugin files sought here: ${FullSimLight_DIR}/../../../${CMAKE_INSTALL_DATAROOTDIR}" )
......
......@@ -151,24 +151,11 @@ if(Pythia_FOUND)
endif()
# Check if we are building FullSimLight individually,
# or as a part of the main GeoModel.
# In the first case, we link against the imported targets, which are taken
# from the base GeoModel packages already installed on the system.
# This is used when building distribution packages.
if ( ${PROJECT_NAME}_INDIVIDUAL_BUILD ) # if built individually
target_link_libraries( gmclash PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( gmmasscalc PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( fullSimLight PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( gmgeantino PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( gm2gdml PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
else() # if built as a part of GeoModel
target_link_libraries( gmclash PUBLIC GeoModelKernel GeoModelRead GeoModelWrite )
target_link_libraries( gmmasscalc PUBLIC GeoModelKernel GeoModelRead GeoModelWrite )
target_link_libraries( fullSimLight PUBLIC GeoModelKernel GeoModelRead GeoModelWrite )
target_link_libraries( gmgeantino PUBLIC GeoModelKernel GeoModelRead GeoModelWrite )
target_link_libraries( gm2gdml PUBLIC GeoModelKernel GeoModelRead GeoModelWrite )
endif()
target_link_libraries( gmclash PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( gmmasscalc PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( fullSimLight PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( gmgeantino PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
target_link_libraries( gm2gdml PUBLIC GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite )
# targets that need 'nlohmann_json'
target_link_libraries( gmclash PRIVATE nlohmann_json::nlohmann_json )
......
......@@ -28,8 +28,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# Find the base GeoModel packages, which must be installed on the target system already
find_package( GeoModelCore REQUIRED )
# Set a flag to steer the build of the subpackages
#set( VISUALIZATION_INDIVIDUAL_BUILD ON )
else()
# I am called from other project with add_subdirectory().
message( STATUS "Building ${PROJECT_NAME} as part of the root GeoModel project.")
......
......@@ -31,8 +31,6 @@ if( (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) OR GEOMODEL_BUILD_GEOMODELG4_
find_package( Geant4 REQUIRED )
include( SetupXercesC )
endif()
# Set a flag to steer the of the subpackages
set( ${PROJECT_NAME}_INDIVIDUAL_BUILD ON )
# Print Build Info on screen
include( PrintBuildInfo )
else()
......
......@@ -18,18 +18,7 @@ include(${Geant4_USE_FILE})
# Set target and properties
add_library( GeoMaterial2G4 SHARED ${HEADERS} ${SOURCES} )
# Check if we are building FullSimLight individually,
# or as a part of the main GeoModel.
# In the first case, we link against the imported targets, which are taken
# from the base GeoModel packages already installed on the system.
# This is used when building distribution packages.
if ( GeoModelG4_INDIVIDUAL_BUILD ) # if built individually
target_link_libraries( GeoMaterial2G4 PUBLIC GeoModelCore::GeoModelKernel )
else()
target_link_libraries( GeoMaterial2G4 PUBLIC GeoModelKernel )
endif()
target_link_libraries( GeoMaterial2G4 PUBLIC ${Geant4_LIBRARIES} )
target_link_libraries( GeoMaterial2G4 PUBLIC GeoModelCore::GeoModelKernel ${Geant4_LIBRARIES} )
target_include_directories( GeoMaterial2G4 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
......
......@@ -40,17 +40,7 @@ message("==> NOTE: G4 solid extensions will be searched in: ${PATHEXTENSIONS}. I
add_library( GeoModel2G4 SHARED ${HEADERS} ${SOURCES} )
target_link_libraries( GeoModel2G4
PUBLIC ${GEANT4_LIBRARIES}
PRIVATE GeoMaterial2G4 )
# Check if we are building FullSimLight individually,
# or as a part of the main GeoModel.
# In the first case, we link against the imported targets, which are taken
# from the base GeoModel packages already installed on the system.^[OB
# This is used when building distribution packages.
if ( GeoModelG4_INDIVIDUAL_BUILD ) # if built individually
target_link_libraries( GeoModel2G4 PRIVATE GeoModelCore::GeoModelKernel )
else()
target_link_libraries( GeoModel2G4 PRIVATE GeoModelKernel )
endif()
PRIVATE GeoMaterial2G4 GeoModelCore::GeoModelKernel )
target_include_directories( GeoModel2G4 SYSTEM PUBLIC ${GEANT4_INCLUDE_DIRS} )
target_include_directories( GeoModel2G4 PUBLIC
......
......@@ -32,8 +32,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# Find the base GeoModel packages, which must be installed on the target system already
find_package( GeoModelCore REQUIRED ${GeoModel_VERSION} )
find_package( GeoModelIO REQUIRED ${GeoModel_VERSION} )
# Set a flag to steer the build of the subpackages
#set( VISUALIZATION_INDIVIDUAL_BUILD ON )
# Print Build Info on screen
include( PrintBuildInfo )
else()
......
......@@ -33,8 +33,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# Find the base GeoModel packages, which must be installed on the target system already
find_package( GeoModelCore REQUIRED ${GeoModel_VERSION} )
find_package( GeoModelIO REQUIRED ${GeoModel_VERSION} )
# Set a flag to steer the build of the subpackages
set( VISUALIZATION_INDIVIDUAL_BUILD ON )
# Print Build Info on screen
include( PrintBuildInfo )
else()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment