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

Simplify build/use of builtin/system Eigen

- Make builtin "imported" target depend on Eigen external project.
- Subprojects only then need to link to the Eigen3::Eigen target
  whether builtin/external is used
parent 26d26704
No related branches found
No related tags found
1 merge request!184Modernisation of CMake scripting to simplify build of FullSimLight
......@@ -49,7 +49,6 @@ set(PROJECT_SOURCES ${SOURCES})
# Set up the library.
add_library(DummyUserActionPlugin SHARED ${SOURCES})
#find_package (Eigen3 REQUIRED)
find_package(Geant4 REQUIRED)
#find_package(FullSimLight REQUIRED)
find_package( HDF5 REQUIRED COMPONENTS CXX )
......
......@@ -51,7 +51,6 @@ set(PROJECT_SOURCES ${SOURCES})
# Set up the library.
add_library(GenerateHitsPlugin SHARED ${SOURCES})
#find_package (Eigen3 REQUIRED)
find_package(Geant4 REQUIRED)
#find_package(FullSimLight REQUIRED)
find_package( HDF5 REQUIRED COMPONENTS CXX )
......
......@@ -50,7 +50,6 @@ set(PROJECT_SOURCES ${HEADERS} ${SOURCES} TracksPlugin.cc)
# Set up the library.
add_library(GenerateTracksPlugin SHARED ${HEADERS} ${SOURCES} TracksPlugin.cc)
#find_package (Eigen3 REQUIRED)
find_package(Geant4 REQUIRED)
#find_package(FullSimLight REQUIRED)
find_package( HDF5 REQUIRED COMPONENTS CXX )
......
......@@ -13,9 +13,6 @@ target_include_directories( GeoModelKernel PUBLIC
$<INSTALL_INTERFACE:include> )
source_group( "GeoModelKernel" FILES ${HEADERS} )
source_group( "src" FILES ${SOURCES} )
if( GEOMODEL_USE_BUILTIN_EIGEN3 )
add_dependencies( GeoModelKernel Eigen3 )
endif()
set_target_properties( GeoModelKernel PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR} )
......
......@@ -5,60 +5,51 @@
#
# Make sure that this file is only included once.
get_property( _eigenSetUp GLOBAL PROPERTY GEOMODEL_EIGEN_SET_UP SET )
if( _eigenSetUp )
unset( _eigenSetUp )
return()
endif()
set_property( GLOBAL PROPERTY GEOMODEL_EIGEN_SET_UP TRUE )
include_guard(GLOBAL)
# Configuration option for how Eigen should be used.
option( GEOMODEL_USE_BUILTIN_EIGEN3
"Download a version of Eigen3 during the build" FALSE )
option(GEOMODEL_USE_BUILTIN_EIGEN3 "Download a version of Eigen3 during the build" OFF)
# Now do what was requested.
if( GEOMODEL_USE_BUILTIN_EIGEN3 )
# Tell the user what's happening.
message( STATUS "Building Eigen3 as part of the project" )
# Helper variables for the Eigen build.
set( Eigen3_INCLUDE_DIR
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Install/include/eigen3" )
set( Eigen3_VERSION "3.2.9" )
# Create the include directory already, otherwise CMake refuses to
# create the imported target.
file( MAKE_DIRECTORY "${Eigen3_INCLUDE_DIR}" )
# Build/install Eigen3 using ExternalProject_Add(...).
include( ExternalProject )
ExternalProject_Add( Eigen3
PREFIX ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Build
INSTALL_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Install
URL "http://cern.ch/lcgpackages/tarFiles/sources/eigen-${Eigen3_VERSION}.tar.gz"
URL_MD5 "de04f424e6b86907ccc9737b5d3048e7"
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
BUILD_BYPRODUCTS "${Eigen3_INCLUDE_DIR}" )
ExternalProject_Add_Step( Eigen3 removepc
COMMAND ${CMAKE_COMMAND} -E remove_directory <INSTALL_DIR>/share
COMMENT "Removing the pkgconfig file from Eigen"
DEPENDEES install )
install( DIRECTORY
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Install/
DESTINATION .
COMPONENT Development
USE_SOURCE_PERMISSIONS )
# Set up an imported target that mimicks the one created by the exported
# CMake configuration of an Eigen installation.
add_library( Eigen3::Eigen INTERFACE IMPORTED )
set_target_properties( Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Eigen3_INCLUDE_DIR}" )
# Tell the user what's happening.
message( STATUS "Building Eigen3 as part of the project" )
# Helper variables for the Eigen build.
set( Eigen3_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Install/include/eigen3" )
set( Eigen3_VERSION "3.2.9" )
# Create the include directory already, otherwise CMake refuses to
# create the imported target.
file( MAKE_DIRECTORY "${Eigen3_INCLUDE_DIR}" )
# Build/install Eigen3 using ExternalProject_Add(...).
include( ExternalProject )
ExternalProject_Add( Eigen3
PREFIX ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Build
INSTALL_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Install
URL "http://cern.ch/lcgpackages/tarFiles/sources/eigen-${Eigen3_VERSION}.tar.gz"
URL_MD5 "de04f424e6b86907ccc9737b5d3048e7"
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
BUILD_BYPRODUCTS "${Eigen3_INCLUDE_DIR}" )
ExternalProject_Add_Step( Eigen3 removepc
COMMAND ${CMAKE_COMMAND} -E remove_directory <INSTALL_DIR>/share
COMMENT "Removing the pkgconfig file from Eigen"
DEPENDEES install )
install( DIRECTORY
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Eigen3Install/
DESTINATION .
COMPONENT Development
USE_SOURCE_PERMISSIONS )
# Set up an imported target that mimicks the one created by the exported
# CMake configuration of an Eigen installation.
add_library( Eigen3::Eigen INTERFACE IMPORTED )
set_target_properties( Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Eigen3_INCLUDE_DIR}" )
# Add dependency to the underlying external project
add_dependencies(Eigen3::Eigen Eigen3)
else()
# Just find an existing installation of Eigen3.
find_package( Eigen3 REQUIRED NO_MODULE )
# Just find an existing installation of Eigen3.
find_package( Eigen3 REQUIRED NO_MODULE )
endif()
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