CMakeLists.txt 4.25 KB
Newer Older
Stezowski Olivier's avatar
Stezowski Olivier committed
1 2 3
# CMake for GammaWare/CORE
# O. Stezowski
#
4 5 6 7 8
# To add a file, add it in the with_dictionnary list or in the without_dictionnary list depending
#  whether or not the ROOT dictionnary is to be generated.
#  !! Do not forget to fill the LinkDef file !!
#  !! Do not forget to add EXTRA_INTERNAL_LIBRARIES and EXTRA_EXTERNAL_LIBRARIES with the names of the libraries this one relies on !!
#
Stezowski Olivier's avatar
Stezowski Olivier committed
9 10 11 12 13 14 15
project (core)
#
MESSAGE("[GW]  + root/${PROJECT_NAME}")
#
#
set(GWLIBNAME GWCORE)
#
16
# headers / dictionnary / sources
Stezowski Olivier's avatar
Stezowski Olivier committed
17 18 19 20
#
# 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.
#
21
if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/GwConfig.h ) # in case build with configure has been called previously
22
    file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/GwConfig.h)
23 24
endif()
#
Stezowski Olivier's avatar
Stezowski Olivier committed
25
set( with_dictionnaries
26 27 28 29 30 31 32 33 34
    BaseNucleus
    Data
    Env
    GammaTracker
    InfoData
    Measure
    PadManager
    RandObj
    Random
Stezowski Olivier's avatar
Stezowski Olivier committed
35 36
)
set( without_dictionnaries
37 38 39 40
    SingletonDestroyer
    GwCentralLog
    GwLogCollector
    GwLogMessage
41
    BashColor
42 43 44
#	../../adf/CentralLog  # to avoid having the same file in two directories in the svn
#	../../adf/LogCollector
#	../../adf/LogMessage
45
    XtermProgressBar
Stezowski Olivier's avatar
Stezowski Olivier committed
46
)
47
# add includes : root + current (before to have the latest) + all gw includes copied in CMAKE_BINARY_DIR/include
Stezowski Olivier's avatar
Stezowski Olivier committed
48 49 50 51 52
#
include_directories(${ROOT_INCLUDES})
include_directories(${CMAKE_BINARY_DIR}/include)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
#
53
set (ALL_GW_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/include ${ROOT_INCLUDES})
Stezowski Olivier's avatar
Stezowski Olivier committed
54 55
#
link_directories(${ROOT_LIBRARY_DIR})
56
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
Stezowski Olivier's avatar
Stezowski Olivier committed
57 58 59 60
#
# configure file
#
configure_file (
61 62
    "${CMAKE_CURRENT_SOURCE_DIR}/GwConfig.h.cmake"
    "${CMAKE_BINARY_DIR}/include/GwConfig.h"
Stezowski Olivier's avatar
Stezowski Olivier committed
63 64
)
#
65
# headers / linkdef etc ...
Stezowski Olivier's avatar
Stezowski Olivier committed
66 67 68 69 70
#
set(headers ${CMAKE_BINARY_DIR}/include/GwConfig.h)
set(all_headers "")
set(sources "")
#
71
# set headers/ etc and generate dictionnary for the files which require it
Stezowski Olivier's avatar
Stezowski Olivier committed
72 73
#
foreach( f ${with_dictionnaries} )
74 75
    set(sources ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.cpp)
    set(headers ${headers} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.h)
Stezowski Olivier's avatar
Stezowski Olivier committed
76
endforeach()
77 78 79
#
# Dictionnary from one file only 'a la ROOT' + internal and external dependencies
#
80 81
ROOT_GENERATE_DICTIONARY(G__${GWLIBNAME} ${headers} MODULE ${GWLIBNAME} LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/LinkDef.h OPTIONS "")
set( EXTRA_EXTERNAL_LIBRARIES Core Graf MathCore XMLParser Hist Gui)
Stezowski Olivier's avatar
Stezowski Olivier committed
82 83
#
foreach( f ${without_dictionnaries} )
84 85
    set(sources ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.cpp)
    set(headers ${headers} ${CMAKE_CURRENT_SOURCE_DIR}/${f}.h)
Stezowski Olivier's avatar
Stezowski Olivier committed
86 87 88 89 90
endforeach()
#

#----------------------------------------------------------------------------
#
91
# Use root functions to generate the library and the root map file
Stezowski Olivier's avatar
Stezowski Olivier committed
92
#
93 94 95 96 97 98
if ( with_dictionnaries )
    ROOT_LINKER_LIBRARY(${GWLIBNAME} ${sources} G__${GWLIBNAME}.cxx DEPENDENCIES ${EXTRA_EXTERNAL_LIBRARIES})
    ROOT_GENERATE_ROOTMAP(${GWLIBNAME} LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/LinkDef.h DEPENDENCIES ${EXTRA_EXTERNAL_LIBRARIES})
else ()
    ROOT_LINKER_LIBRARY(${GWLIBNAME} ${sources} DEPENDENCIES ${EXTRA_EXTERNAL_LIBRARIES})
endif()
Stezowski Olivier's avatar
Stezowski Olivier committed
99 100
#
# copy headers file in a single directory	so that is becomes available for ohers sub-projects
101
#
Stezowski Olivier's avatar
Stezowski Olivier committed
102 103
# because cmake2.6 does not provide COPY in file, do it another way
if( ${CMAKE_VERSION} VERSION_GREATER "2.8.0" )
104
    file(COPY ${headers} DESTINATION ${CMAKE_BINARY_DIR}/include)
Stezowski Olivier's avatar
Stezowski Olivier committed
105
else()
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
    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)
#
# special treatments, 
#
install(FILES ${headers} DESTINATION ${GW_INCLUDE_DIR} COMPONENT headers )
if ( with_dictionnaries )
127
    install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${GWLIBNAME}_rdict.pcm DESTINATION lib COMPONENT libraries )
128 129 130 131 132 133 134 135
    install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${GWLIBNAME}.rootmap DESTINATION lib COMPONENT libraries )
endif()






Stezowski Olivier's avatar
Stezowski Olivier committed
136