CMakeLists.txt 3.56 KB
Newer Older
Stezowski Olivier's avatar
Stezowski Olivier committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
# CMake for GammaWare/CORE
# O. Stezowski
#
project (core)
#
MESSAGE("[GW]  + root/${PROJECT_NAME}")
#
#
set(GWLIBNAME GWCORE)
#
# internal and external dependencies
#
set( EXTRA_INTERNAL_LIBRARIES GWCORE)
set( EXTRA_EXTERNAL_LIBRARIES Core Cint Graf MathCore XMLParser Hist)
#
# 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
	BaseNucleus
	Data
	Env
	GammaTracker
	InfoData
	Measure
	PadManager
	RandObj
	Random
)
set( without_dictionnaries
	CentralLog
	LogCollector
	LogMessage
	XtermProgressBar
)
# 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}/GwConfig.h.cmake"
  "${CMAKE_BINARY_DIR}/include/GwConfig.h"
)
#
# headers / linkdef etc ... 
#
set(headers ${CMAKE_BINARY_DIR}/include/GwConfig.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_EXTERNAL_LIBRARIES})
ROOT_GENERATE_ROOTMAP(${GWLIBNAME} LINKDEF ${linkdefs} DEPENDENCIES ${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 )