Commit 4a567de4 authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

add cmake facility

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@1750 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 61b089ac
# CMake for GammaWare
# O. Stezowski
#------------------------------------------------------------------------------
# Check cmake version is compatible
#
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
#------------------------------------------------------------------------------
# Enforce an out-of-source builds before anything else
#
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "Gammaware requires an out-of-source build.")
message(STATUS "Please remove these files from ${CMAKE_BINARY_DIR} first:")
message(STATUS "CMakeCache.txt")
message(STATUS "CMakeFiles")
message(STATUS "Once these files are removed, create a separate directory")
message(STATUS "and run CMake from there")
message(FATAL_ERROR "in-source build detected")
endif()
#----------------------------------------------------------------------------
# Globals
#
# Where to look first for cmake modules
#
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
#
project(GammaWare)
#
set(${PROJECT_NAME}_VERSION "0.9.0")
set(${PROJECT_NAME}_VERSION_MAJOR "0")
set(${PROJECT_NAME}_VERSION_MINOR "9")
set(${PROJECT_NAME}_VERSION_PATCH "0")
#
# CMake directories
#
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#
# ROOT MANDATORY
#
find_package(ROOT REQUIRED)
#MESSAGE("ROOT has been found: ${ROOT_INCLUDE_DIRS} ${ROOTVERSION}")
#
# Ckeck compatibilities
#
include(RootNewMacros)
#----------------------------------------------------------------------------
# configuration for all modules
#
include_directories(${ROOT_INCLUDE_DIRS})
include_directories(${CMAKE_BINARY_DIR}/include)
#
# install directories (standard or customized) in case install procedure is used
if ( NOT CMAKE_INSTALL_PREFIX )
MESSAGE("[GW] NO PREFIX given, set default to /ag if install called, otherwise change it with -DCMAKE_INSTALL_PREFIX=/your/path/to/install ")
else()
MESSAGE("[GW] PREFIX is given to be ${CMAKE_INSTALL_PREFIX} ")
endif()
MESSAGE("[GW] IN CASE OF INSTALL, prefix is : ${CMAKE_INSTALL_PREFIX}")
MESSAGE("[GW] |-> to change it : -DCMAKE_INSTALL_PREFIX=/your/path/to/install ")
MESSAGE("[GW] |-> libraries in /your/path/to/install/lib, binaries in /your/path/to/install/bin, includes in /your/path/to/install/include ")
MESSAGE("[GW] -DADIR=ON put all libraries, binaries and includes in /your/path/to/install")
if ( NOT DATADIR )
MESSAGE("[GW] NO DATADIR given explicitely, set to ${CMAKE_INSTALL_PREFIX}/share if install called, otherwise change it with -DDATADIR=/your/path/to/data ")
set ( DATADIR ${CMAKE_INSTALL_PREFIX}/share )
endif()
#
# compute all install dir
#
set( GW_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib )
set( GW_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin )
set( GW_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include )
set( GW_DATA_DIR ${DATADIR} )
#
# install in a single dir lib/bin/include
if ( ADIR )
set( GW_LIB_DIR ${CMAKE_INSTALL_PREFIX} )
set( GW_BIN_DIR ${CMAKE_INSTALL_PREFIX} )
set( GW_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX} )
endif()
#----------------------------------------------------------------------------
# Add modules
#
# options
option(DO_DEV "If ON, the GWDEV library is also built" OFF)
#
add_subdirectory (src/root/core)
add_subdirectory (src/root/physics)
add_subdirectory (src/root/tools)
add_subdirectory (src/system)
add_subdirectory (src/root/gem)
add_subdirectory (src/adf)
add_subdirectory (src/root/adfe)
add_subdirectory (src/deprecated)
#
if ( DO_DEV )
add_subdirectory (src/dev)
endif()
#----------------------------------------------------------------------------
# Global configure/install/copies
#
set( DATADIR_TO_INSTALL icons ndb macros )
#
install(DIRECTORY ${DATADIR_TO_INSTALL} DESTINATION ${GW_DATA_DIR} PATTERN ".svn" EXCLUDE )
#
# because cmake2.6 does not provide COPY in file, do it another way
if( ${CMAKE_VERSION} VERSION_GREATER "2.8.0" )
file(COPY ${DATADIR_TO_INSTALL} DESTINATION ${CMAKE_BINARY_DIR}/share PATTERN ".svn" EXCLUDE)
else()
if ( EXISTS ${CMAKE_BINARY_DIR}/share )
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/share )
endif()
foreach ( f ${DATADIR_TO_INSTALL} )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${f} ${CMAKE_BINARY_DIR}/share )
endforeach()
endif()
#
# script to set env in case cmake build directory is used directly
# bash then tcsh
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/Gw-env.sh.cmake"
"${CMAKE_BINARY_DIR}/Gw-env.sh"
@ONLY
)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/Gw-env.csh.cmake"
"${CMAKE_BINARY_DIR}/Gw-env.csh"
@ONLY
)
# config script in bin generated first before being installed
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/Gw-config.py.cmake"
"${CMAKE_BINARY_DIR}/.bin/Gw-config.py"
@ONLY
)
install(PROGRAMS ${CMAKE_BINARY_DIR}/.bin/Gw-config.py DESTINATION ${GW_BIN_DIR})
#----------------------------------------------------------------------------
# Cache
#
# BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON
#SET( BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}" CACHE BOOL "Set to OFF to build static libraries" FORCE )
set(DO_DEV "${DO_DEV}" CACHE BOOL "If ON, the GWDEV library is also built" FORCE)
#!/usr/bin/env python
import os
import shutil
import getopt, sys
# part to be changed by configure/cmake
L_LIBDIR = "@GW_LIB_DIR@"
L_BINDIR = "@GW_BIN_DIR@"
L_INCDIR = "@GW_INCLUDE_DIR@"
L_VERSION = "@GammaWare_VERSION@"
L_RVERSION = "@ROOTVERSION@"
# print help and current conditions
help = """
Usage : Gw-config.py --opt
possible options :
* --h : print help
* --libdir : to get the path to the libraries for the current version
* --bindir : to get the path to the binaries for the current version
* --incdir : to get the path to the includes for the current version
* --version : to get the current running version
* --rootversion : to get the root version used to compile this version
"""
def Usage() :
print
print ' ***********************************************************************'
print help
print ' ****** in case of questions/problems, agata{_{at}_}ipnl.in2p3.fr ******'
print
def main():
global ARCH, FORCE_ARCH
if (sys.version_info < (2,3,4) ) :
raise "Version python min required 2.3.4 !"
# check options
try:
opts, args = getopt.getopt(sys.argv[1:], "h", [
"help", "libdir", "bindir", "incdir", "version", "rootversion"])
except getopt.GetoptError, err:
print ''
print str(err)
Usage()
sys.exit(2)
# display help
for index in range(len(opts)) :
if ( opts[index][0] == '-h' ) :
Usage()
return 0
for index in range(len(opts)) :
if ( opts[index][0] == '--libdir' ) :
sys.exit(L_LIBDIR)
if ( opts[index][0] == '--bindir' ) :
sys.exit(L_BINDIR)
if ( opts[index][0] == '--incdir' ) :
sys.exit(L_INCDIR)
if ( opts[index][0] == '--version' ) :
sys.exit(L_VERSION)
if ( opts[index][0] == '--rootversion' ) :
sys.exit(L_RVERSION)
Usage()
# execute main
if __name__ == "__main__":
main()
\ No newline at end of file
#
# Source this file to set up the environment to work with Gammaware Version @GammaWare_VERSION@
#
setenv GammaWare Gw_ @GammaWare_VERSION@
if ($?LD_LIBRARY_PATH) then
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ # Linux, ELF HP-UX
endif
if ($?DYLD_LIBRARY_PATH) then
setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ # Mac OS X
endif
if ($?SHLIB_PATH) then
setenv SHLIB_PATH ${SHLIB_PATH}:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ # legacy HP-UX
endif
if ($?LIBPATH) then
setenv LIBPATH ${LIBPATH}:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ # AIX
endif
echo ' ---> You are working now with GammaWare version' @GammaWare_VERSION@
#
# Source this file to set up the environment to work with Gammaware Version @GammaWare_VERSION@
#
GammaWare=Gw_ @GammaWare_VERSION@ ; export GammaWare
if [ -n "${LD_LIBRARY_PATH}" ]; then
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ ; export LD_LIBRARY_PATH # Linux, ELF HP-UX
fi
if [ -n "${DYLD_LIBRARY_PATH}" ]; then
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ ; export DYLD_LIBRARY_PATH # Mac OS X
fi
if [ -n "${SHLIB_PATH}" ]; then
SHLIB_PATH=$SHLIB_PATH:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ ; export SHLIB_PATH # legacy HP-UX
fi
if [ -n "${LIBPATH}" ]; then
LIBPATH=$LIBPATH:@CMAKE_LIBRARY_OUTPUT_DIRECTORY@ ; export LIBPATH # AIX
fi
echo ' ---> You are working now with GammaWare version' @GammaWare_VERSION@
\ No newline at end of file
# CMake for module of GW
# O. Stezowski
cmake_minimum_required (VERSION 2.6)
#
#
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
#
include(CMakeLists_ADF.cmake) # standalone
else()
#
include(CMakeLists_GW.cmake) # GW
endif()
# CMake for module of GW
# O. Stezowski
cmake_minimum_required (VERSION 2.6)
#
#
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) # standalone
#
include(config/standalone.cmake)
#
else()
#
set(_LIB_NAME GWADF)
# add to includes
#
endif()
#
# internal and external dependencies
#
#set( EXTRA_INTERNAL_LIBRARIES AgataDPPCommon)
#set( EXTRA_EXTERNAL_LIBRARIES ${ADF_LIBRARY})
#
# headers / sources
file(GLOB headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h standalone/*.h)
file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp standalone/*.cpp)
# Remove if any
if ( DO_NARVAL_INTERFACE )
list(ADD_ITEMS sources ${PROJECT_SOURCE_DIR}/libPreprocessingFilter.cpp)
endif()
option(DO_OFT "Built internal OFT" ON)
#----------------------------------------------------------------------------
#
add_library(${_LIB_NAME} SHARED ${sources})
#
target_link_libraries(${_LIB_NAME} ${EXTRA_EXTERNAL_LIBRARIES} ${EXTRA_INTERNAL_LIBRARIES})
#
set_target_properties(${_LIB_NAME} PROPERTIES ${GW_LIBRARY_PROPERTIES})
#
install(TARGETS ${_LIB_NAME} RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT libraries)
# copy headers file in a single directory
# because cmake2.6 does not provide COPY in file, do it another way
if( ${CMAKE_VERSION} VERSION_GREATER "2.8.0" )
file(COPY ${headers} DESTINATION ${CMAKE_BINARY_DIR}/include)
else()
if ( EXISTS ${CMAKE_BINARY_DIR}/include )
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/ )
endif()
foreach ( f ${headers} )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${f} ${CMAKE_BINARY_DIR}/include/ )
endforeach()
endif()
# CMake for GammaWare/ADF
# O. Stezowski
#
project (adf)
#
MESSAGE("[GW] + ${PROJECT_NAME}")
#
#
set(GWLIBNAME GWADF)
#
# internal and external dependencies
#
set( EXTRA_INTERNAL_LIBRARIES GWCORE )
set( EXTRA_EXTERNAL_LIBRARIES )
#
# headers / dictionnary / sources
#
# so far no automatic methods for computing which class has a dictionnary or not
# manual method : base file name separated in two lists with different treatment.
#
set( with_dictionnaries
)
set( without_dictionnaries
ADFConfig
ADFObjects
AgataCompositeFrame
AgataConfigurationFrame
AgataDataFrame
AgataFrameFactory
AgataKeyFactory
AgataRawFrame
Algo
BaseBuffer
BasicAFC
BasicAFP
BufferIO
# CentralLog
CompositeFrame
ConfAgent
ConfigurationFrame
Counter
CrystalFrame
DFAgent
DataHandling
DefaultKeyFactory
DotConf
FactoryItem
Frame
FrameBlock
FrameFactory
FrameIO
GObject
GenericFrame
Hits
Key
KeyFactory
# LogCollector
# LogMessage
MetaFrame
NarvalInterface
PSAFrame
PtrStack
RunAgent
Signals
StackOfObjects
TestFIO
TrackedFrame
Trigger
Version
)
# add includes : root + current (before to have the latest) + all gw includes copied in CMAKE_BINARY_DIR/include
#
include_directories(${ROOT_INCLUDES})
include_directories(${CMAKE_BINARY_DIR}/include)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
#
set (ALL_GW_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/include ${ROOT_INCLUDES})
#
link_directories(${ROOT_LIBRARY_DIR})
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
#
# configure file
#
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/ADFConfig.h.cmake"
"${CMAKE_BINARY_DIR}/include/ADFConfig.h"
)
#
# headers / linkdef etc ...
#
set(headers ${CMAKE_BINARY_DIR}/include/ADFConfig.h)
set(all_headers "")
set(sources "")
set(dictionnaries "")
set(linkdefs "")
#
# set headers/ etc and generate dictionnary for the files which require it
#
foreach( f ${with_dictionnaries} )
GWROOT_GENERATE_DICTIONARY("${CMAKE_CURRENT_SOURCE_DIR}/${f}.h"
"${CMAKE_CURRENT_SOURCE_DIR}/${f}LinkDef.h"
"${f}Dict.cpp"
"${ALL_GW_INCLUDES}")
set(sources ${sources} ${f}Dict.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${f}.cpp)
set(headers ${headers} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.h)
set(dictionnaries ${dictionnaries} ${f}Dict.h)
set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}LinkDef.h)
endforeach()
#
foreach( f ${without_dictionnaries} )
set(sources ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.cpp)
set(headers ${headers} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.h)
endforeach()
#
#MESSAGE("headers ${headers}")
#MESSAGE("sources ${sources}")
#MESSAGE("dictionnaries ${dictionnaries}")
#MESSAGE("ROOT ${ROOT_INCLUDES}")
#MESSAGE("ROOT ${ROOT_LIBRARY_DIR}")
#----------------------------------------------------------------------------
#
# Use root functions to generate the library and the root map file
#
ROOT_LINKER_LIBRARY(${GWLIBNAME} ${sources} LIBRARIES ${EXTRA_INTERNAL_LIBRARIES} ${EXTRA_EXTERNAL_LIBRARIES})
ROOT_GENERATE_ROOTMAP(${GWLIBNAME} LINKDEF ${linkdefs} DEPENDENCIES ${EXTRA_INTERNAL_LIBRARIES} ${EXTRA_EXTERNAL_LIBRARIES})
#
# copy headers file in a single directory so that is becomes available for ohers sub-projects
# because cmake2.6 does not provide COPY in file, do it another way
if( ${CMAKE_VERSION} VERSION_GREATER "2.8.0" )
file(COPY ${headers} DESTINATION ${CMAKE_BINARY_DIR}/include)
else()
if ( EXISTS ${CMAKE_BINARY_DIR}/include )
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/ )
endif()
foreach ( f ${headers} )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${f} ${CMAKE_BINARY_DIR}/include/ )
endforeach()
endif()
#
# Install lib and headers
#
install(TARGETS ${GWLIBNAME} RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT libraries)
#
install(FILES ${headers} DESTINATION include COMPONENT headers )
# CMake for GammaWare/DEPRECATED
# O. Stezowski
#
project (deprecated)
#
MESSAGE("[GW] + ${PROJECT_NAME}")
#
#
set(GWLIBNAME GWDEPRECATED)
#
# internal and external dependencies
#
set( EXTRA_INTERNAL_LIBRARIES GWCORE GWADF GWADFE GWPHYSICS GWTOOLS GWGEM GWSYSTEM )
set( EXTRA_EXTERNAL_LIBRARIES Core Cint Graf MathCore XMLParser Hist Gui)
#
# headers / dictionnary / sources
#
# so far no automatic methods for computing which class has a dictionnary or not
# manual method : base file name separated in two lists with different treatment.
#
set( with_dictionnaries
Peak
PeakFitter
ClickCollector
Events
)
set( without_dictionnaries
)
# add includes : root + current (before to have the latest) + all gw includes copied in CMAKE_BINARY_DIR/include
#
include_directories(${ROOT_INCLUDES})
include_directories(${CMAKE_BINARY_DIR}/include)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
#
set (ALL_GW_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/include ${ROOT_INCLUDES})
#
link_directories(${ROOT_LIBRARY_DIR})
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
#
# headers / linkdef etc ...
#
set(headers "")
set(all_headers "")
set(sources "")
set(dictionnaries "")
set(linkdefs "")
#
# set headers/ etc and generate dictionnary for the files which require it
#
foreach( f ${with_dictionnaries} )
GWROOT_GENERATE_DICTIONARY("${CMAKE_CURRENT_SOURCE_DIR}/${f}.h"
"${CMAKE_CURRENT_SOURCE_DIR}/${f}LinkDef.h"
"${f}Dict.cpp"
"${ALL_GW_INCLUDES}")
set(sources ${sources} ${f}Dict.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${f}.cpp)
set(headers ${headers} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.h)
set(dictionnaries ${dictionnaries} ${f}Dict.h)
set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}LinkDef.h)
endforeach()
#
foreach( f ${without_dictionnaries} )
set(sources ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.cpp)
set(headers ${headers} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.h)
endforeach()
#
#MESSAGE("headers ${headers}")
#MESSAGE("sources ${sources}")
#MESSAGE("dictionnaries ${dictionnaries}")
#MESSAGE("ROOT ${ROOT_INCLUDES}")
#MESSAGE("ROOT ${ROOT_LIBRARY_DIR}")
#----------------------------------------------------------------------------
#
# Use root functions to generate the library and the root map file
#
ROOT_LINKER_LIBRARY(${GWLIBNAME} ${sources} LIBRARIES ${EXTRA_INTERNAL_LIBRARIES} ${EXTRA_EXTERNAL_LIBRARIES})
ROOT_GENERATE_ROOTMAP(${GWLIBNAME} LINKDEF ${linkdefs} DEPENDENCIES ${EXTRA_INTERNAL_LIBRARIES} ${EXTRA_EXTERNAL_LIBRARIES})
#
# copy headers file in a single directory so that is becomes available for ohers sub-projects
#
# because cmake2.6 does not provide COPY in file, do it another way
if( ${CMAKE_VERSION} VERSION_GREATER "2.8.0" )
file(COPY ${headers} DESTINATION ${CMAKE_BINARY_DIR}/include)
else()
if ( EXISTS ${CMAKE_BINARY_DIR}/include )
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/ )
endif()
foreach ( f ${headers} )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${f} ${CMAKE_BINARY_DIR}/include/ )
endforeach()
endif()
#
# Install lib and headers
#
install(TARGETS ${GWLIBNAME} RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT libraries)
#
install(FILES ${headers} DESTINATION include COMPONENT headers )