Newer
Older
#=================================================================================
#
# AIDA Detector description implementation for LCD
#---------------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
#=================================================================================
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
###set(DD4HEP_DEBUG_CMAKE 1)
message ( STATUS "INCLUDING DD4hepBuild.... c++11:${DD4HEP_USE_CXX11} c++14:${DD4HEP_USE_CXX14}" )
include ( CMakeParseArguments )
####set ( DD4HEP_DEBUG_CMAKE ON )
####set ( CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} --test-output-size-passed 4096 )
#---------------------------------------------------------------------------------------------------
macro(dd4hep_to_parent_scope val)
set ( ${val} ${${val}} PARENT_SCOPE )
endmacro(dd4hep_to_parent_scope)
#---------------------------------------------------------------------------------------------------
# MACRO: dd4hep_set_compiler_flags
#
# Set compiler flags
#
# \author M.Frank
# \version 1.0
#
#---------------------------------------------------------------------------------------------------
macro(dd4hep_set_compiler_flags)
if ( DD4HEP_USE_CXX14 )
set ( CMAKE_CXX_FLAGS "-std=c++14 -ftls-model=global-dynamic")
set ( DD4HEP_USE_CXX11 OFF )
set ( DD4HEP_USE_STDCXX 14 )
add_definitions(-DDD4HEP_USE_STDCXX=14)
elseif ( DD4HEP_USE_CXX11 )
set ( CMAKE_CXX_FLAGS "-std=c++11 -ftls-model=global-dynamic")
set ( DD4HEP_USE_STDCXX 11 )
add_definitions(-DDD4HEP_USE_STDCXX=11)
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated")
Marko Petric
committed
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
Marko Petric
committed
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND APPLE)
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
# All this simply does not work!
# if ( APPLE )
# set(CMAKE_SKIP_BUILD_RPATH FALSE)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/lib")
# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath ${CMAKE_BINARY_DIR}/lib")
# message( STATUS "Apple settings: CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}" )
# message( STATUS "Apple settings: CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}" )
# endif()
endmacro(dd4hep_set_compiler_flags)
#---------------------------------------------------------------------------------------------------
# dd4hep_debug
#
# Print messages if debug flag is enabled
#
# \author M.Frank
# \version 1.0
#
#---------------------------------------------------------------------------------------------------
function ( dd4hep_debug msg )
if( NOT "${DD4HEP_DEBUG_CMAKE}" STREQUAL "" )
get_property(pkg DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_NAME)
string ( LENGTH "${msg}" lmsg )
if ( ${lmsg} GREATER 1024 )
string ( SUBSTRING "${msg}" 0 132 pmsg )
message( STATUS "D++> [${pkg}] ${pmsg}" )
else()
message( STATUS "D++> [${pkg}] ${msg}" )
endif()
endif()
endfunction( dd4hep_debug )
#---------------------------------------------------------------------------------------------------
# dd4hep_include_directories
#
# Same as include_directories but treat all external packages as SYSTEM -> no warnings
#
# \author A.Sailer
# \version 1.0
#
#---------------------------------------------------------------------------------------------------
function ( dd4hep_include_directories pkg_incs )
FOREACH( INCDIR ${pkg_incs} )
string(FIND "${INCDIR}" "${CMAKE_SOURCE_DIR}" out)
IF("${out}" EQUAL 0)
INCLUDE_DIRECTORIES( ${INCDIR} )
ELSE()
INCLUDE_DIRECTORIES( SYSTEM ${INCDIR} )
ENDIF()
ENDFOREACH()
endfunction( dd4hep_include_directories )
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#---------------------------------------------------------------------------------------------------
# dd4hep_print
#
#
# \author M.Frank
# \version 1.0
#
#---------------------------------------------------------------------------------------------------
function ( dd4hep_print msg )
message ( STATUS ${msg} )
endfunction ( dd4hep_print )
function ( dd4hep_skipmsg msg )
message ( STATUS "SKIPPED !!!!!!!!!!!!!! ${msg}" )
endfunction ( dd4hep_skipmsg )
#---------------------------------------------------------------------------------------------------
# dd4hep_fatal
#
#
# \author M.Frank
# \version 1.0
#
#---------------------------------------------------------------------------------------------------
function ( dd4hep_fatal msg )
get_property(pkg DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_NAME)
if ( "${pkg}" STREQUAL "" )
message ( FATAL_ERROR "++> ${msg}" )
else()
message ( FATAL_ERROR "++> [${pkg}] ${msg}" )
endif()
endfunction ( dd4hep_fatal )
#---------------------------------------------------------------------------------------------------
# dd4hep_set_version
#
# Set version structure for building the DD4hep software
#
# \author M.Frank
# \version 1.0
#
#---------------------------------------------------------------------------------------------------
function ( dd4hep_set_version packageName )
cmake_parse_arguments ( ARG "" "MAJOR;MINOR;PATCH" "" ${ARGN} )
if ( NOT "${packageName}" STREQUAL "" )
project ( ${packageName} )
else()
dd4hep_fatal ( "${packageName}: !!! Attempt to define a DD4hep project without a name !!!" )
endif()
set ( major ${ARG_MAJOR} )
set ( minor ${ARG_MINOR} )
set ( patch ${ARG_PATCH} )
if ( "${major}" STREQUAL "" )
set ( major ${DD4hep_VERSION_MAJOR} )
endif()
if ( "${minor}" STREQUAL "" )
set ( minor ${DD4hep_VERSION_MINOR} )
endif()
if ( "${patch}" STREQUAL "" )
set ( patch ${DD4hep_VERSION_PATCH} )
endif()
if ( NOT ("${major}" STREQUAL "" OR "${minor}" STREQUAL "" OR "${patch}" STREQUAL "") )
set( ${packageName}_VERSION_MAJOR ${major} PARENT_SCOPE )
set( ${packageName}_VERSION_MINOR ${minor} PARENT_SCOPE )
set( ${packageName}_VERSION_PATCH ${patch} PARENT_SCOPE )
set( ${packageName}_VERSION "${major}.${minor}" PARENT_SCOPE )
set( ${packageName}_SOVERSION "${major}.${minor}" PARENT_SCOPE )
else()
dd4hep_fatal ( "${packageName}: No Package versions specified.....-> ( ${major}.${minor}.${patch} )" )
endif()
endfunction( dd4hep_set_version )
#---------------------------------------------------------------------------------------------------
# dd4hep_print_options
#
# Print the current option setup for informational purposes
#
# \author M.Frank
# \version 1.0
#---------------------------------------------------------------------------------------------------
function ( dd4hep_print_options )
dd4hep_print ( "+-------------------------------------------------------------------------------" )
dd4hep_print ( "| DD4hep build setup: " )
dd4hep_print ( "| " )
dd4hep_print ( "| CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH} " )
Loading
Loading full blame...