CMakeLists.txt 2.76 KB
Newer Older
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1 2 3 4 5 6 7
#
# cmake file for a standalone program
#
# J. Dudouet
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

8 9
set(CMAKE_INSTALL_MESSAGE LAZY)

Jérémie Dudouet's avatar
Jérémie Dudouet committed
10 11
#
# NAME OF THE PROGRAM : means main is in PROG_NAME.[c,cpp ...] and it gives exec with name PROG_NAME
12

Jérémie Dudouet's avatar
Jérémie Dudouet committed
13
SET(PROG_NAME Cubix)
14 15
SET(Lib_NAME CubixCore)

Jérémie Dudouet's avatar
Jérémie Dudouet committed
16 17 18 19 20
#
PROJECT(${PROG_NAME})
MESSAGE("[GW]  + root/gui/${PROJECT_NAME}")

#Set C++11
Jérémie Dudouet's avatar
Jérémie Dudouet committed
21
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -Wno-unused-parameter -Wno-sign-compare" )
Jérémie Dudouet's avatar
Jérémie Dudouet committed
22 23

#Set ROOT
24 25 26 27 28 29 30 31 32
#set (ROOT_FIND_COMPONENTS Core MathCore Hist Gui Gpad Graf RIO Matrix Physics Thread MultiProc Spectrum)
#  find_file(ROOT_CONFIG ROOTConfig.cmake HINTS $ENV{ROOTSYS} ${ROOTSYS} ${ROOT_DIR} NO_DEFAULT_PATH PATH_SUFFIXES cmake)
#if (ROOT_CONFIG)
#  include(${ROOT_CONFIG})
#  include(${ROOT_USE_FILE})

#  if(ROOT_LIBRARIES AND ROOT_INCLUDE_DIRS)
#    set(ROOT_FOUND TRUE)
#  endif()
Jérémie Dudouet's avatar
Jérémie Dudouet committed
33

34 35 36 37 38
######################
### Link libraries ###
######################

# root
39 40
INCLUDE_DIRECTORIES( ${ROOT_INCLUDE_DIR} )
LINK_DIRECTORIES( ${ROOT_LIBRARY_DIR} )
41
SET(EXTRA_EXTERNAL_LIBRARIES ${EXTRA_EXTERNAL_LIBRARIES} Matrix)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
42 43

# gw
44
set(EXTRA_INTERNAL_LIBRARIES GWPHYSICS )
Jérémie Dudouet's avatar
Jérémie Dudouet committed
45

46 47 48 49
####################
### define files ###
####################

Jérémie Dudouet's avatar
Jérémie Dudouet committed
50
SET(SourceDir ${CMAKE_CURRENT_SOURCE_DIR}/src)
51
include_directories(${SourceDir})
Jérémie Dudouet's avatar
Jérémie Dudouet committed
52 53 54

SET( PROG_NAME_SRCS ${SourceDir}/Cubix.cpp )

55 56 57
file(GLOB sources ${SourceDir}/*.cpp)
list(REMOVE_ITEM sources ${PROG_NAME_SRCS})

Jérémie Dudouet's avatar
Jérémie Dudouet committed
58 59 60 61 62 63
file(GLOB headers ${SourceDir}/*.h)
list(REMOVE_ITEM headers ${SourceDir}/LinkDef.h)

file(GLOB icons ${CMAKE_CURRENT_SOURCE_DIR}/icons/*)
file(GLOB database ${CMAKE_CURRENT_SOURCE_DIR}/DataBase)

64 65 66
#######################
### Root dictionary ###
#######################
Jérémie Dudouet's avatar
Jérémie Dudouet committed
67

68
ROOT_GENERATE_DICTIONARY(G__${Lib_NAME} ${headers} MODULE ${Lib_NAME} LINKDEF ${SourceDir}/LinkDef.h )
Jérémie Dudouet's avatar
Jérémie Dudouet committed
69

70 71 72
#####################
### Cubix Library ###
#####################
Jérémie Dudouet's avatar
Jérémie Dudouet committed
73

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
#---Create a shared library with geneated dictionary
add_library(${Lib_NAME} SHARED ${sources} G__${Lib_NAME}.cxx)
target_link_libraries(${Lib_NAME} ${EXTRA_EXTERNAL_LIBRARIES} ${EXTRA_INTERNAL_LIBRARIES})

#####################
### Cubix Program ###
#####################

#---Create  a main program using the library
add_executable(${PROG_NAME} ${PROG_NAME_SRCS})
target_link_libraries(${PROG_NAME} ${Lib_NAME})

####################
### Instal Files ###
####################
Jérémie Dudouet's avatar
Jérémie Dudouet committed
89

90
install(TARGETS ${PROG_NAME} ${Lib_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
91

92 93
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${Lib_NAME}_rdict.pcm DESTINATION lib)
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${Lib_NAME}.rootmap DESTINATION lib)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
94 95 96 97

install(FILES ${headers} DESTINATION include COMPONENT headers)
install(FILES ${icons} DESTINATION icons COMPONENT icons)
install(DIRECTORY ${database} DESTINATION ${CMAKE_INSTALL_PREFIX})