Revision = short SHA1
[u/mrichter/AliRoot.git] / cmake / CMakeALICE.cmake
CommitLineData
b22a7396 1# **************************************************************************
2# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3# * *
4# * Author: The ALICE Off-line Project. *
5# * Contributors are mentioned in the code where appropriate. *
6# * *
7# * Permission to use, copy, modify and distribute this software and its *
8# * documentation strictly for non-commercial purposes is hereby granted *
9# * without fee, provided that the above copyright notice appears in all *
10# * copies and that both the copyright notice and this permission notice *
11# * appear in the supporting documentation. The authors make no claims *
12# * about the suitability of this software for any purpose. It is *
13# * provided "as is" without express or implied warranty. *
14# **************************************************************************
15
fffaf6a5 16# General purpose functions
17
18# Generation of the dictionaries
19# @DNAME Dictionary name
20# @LDNAME LinkDef file name, ex: LinkDef.h
21# @DHDRS Dictionary headers
22# @DINCDIR Include folders that need to be passed to cint/cling
23macro(generate_dictionary DNAME LDNAME DHDRS DINCDIRS)
24 # Creating the INCLUDE path for cint/cling
25 foreach( dir ${DINCDIRS})
26 set(INCLUDE_PATH -I${dir} ${INCLUDE_PATH})
27 endforeach()
28
29 # Generate the dictionary
b22a7396 30# message(STATUS "Generating dictionary ${DNAME} for ${LDNAME}")
fffaf6a5 31
32# message(STATUS "${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx")
33# message(STATUS "${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.h")
34# message(STATUS "bbb${INCLUDE_PATH}bbb")
35# message(STATUS "${DHDRS} ${LDNAME}")
36# message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}")
37
b168bfa8 38 # Get the definitions from the directory to be sent to CINT
39 get_directory_property(tmpdirdefs DEFINITIONS)
40 string(REPLACE " " ";" tmpdirdefs ${tmpdirdefs})
41
fffaf6a5 42 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.h
43 COMMAND LD_LIBRARY_PATH=${ROOT_LIBDIR}:$ENV{LD_LIBRARY_PATH} ${ROOT_CINT}
44 ARGS -f ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx -c -p
b168bfa8 45 ${tmpdirdefs} ${INCLUDE_PATH}
fffaf6a5 46 ${DHDRS} ${LDNAME}
0224bae4 47 DEPENDS ${DHDRS} ${LDNAME} ${ROOT_CINT}
fffaf6a5 48 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
49 )
0224bae4 50endmacro(generate_dictionary)
51
52# Generate the ROOTmap files
53# @LIBNAME - library name: libAnalysis.so -> Analysis.rootmap
54# @LIBDEPS - library dependencies
55# @LINKDEF - LinkDef header
56macro(generate_rootmap LIBNAME LIBDEPS LINKDEF)
a0f34e87 57# message(STATUS "LIBNAME = ${LIBNAME}")
58# message(STATUS "LIBDEPS = ${LIBDEPS}")
59# message(STATUS "LINKDEF = ${LINKDEF}")
a0f34e87 60# message(STATUS "ROOT_LIBMAP=${ROOT_LIBMAP}")
5e8fe0e0 61
62 set(LOCAL_DEPS)
a0f34e87 63 foreach(file ${LIBDEPS})
64 get_filename_component(ext ${file} EXT)
65 if(ext)
271875a7 66 set(LOCAL_DEPS ${LOCAL_DEPS} ${file})
0224bae4 67 else()
271875a7 68 set(LOCAL_DEPS ${LOCAL_DEPS} lib${file}.so)
0224bae4 69 endif()
70 endforeach()
5e8fe0e0 71
b22a7396 72# message(STATUS "Generating ROOT map for ${LIBNAME}")
0224bae4 73 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap
74 COMMAND LD_LIBRARY_PATH=${ROOT_LIBDIR}:$ENV{LD_LIBRARY_PATH} ${ROOT_LIBMAP}
a0f34e87 75 ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap -l lib${LIBNAME}.so -d ${LOCAL_DEPS} -c ${LINKDEF}
0224bae4 76 DEPENDS ${LIBNAME}
77 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM
78 )
79 add_custom_target(lib${LIBNAME}.rootmap ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap)
80 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap DESTINATION lib)
81
befa423d 82endmacro(generate_rootmap)
83
84# Generate the static dependecies from dynamic list
85# @ shared_list - list of shared libraries
86# @ static_list - the name of the variable that will contain the list of static libraries
87macro(generate_static_dependencies shared_list static_list)
befa423d 88 set(static_list_tmp "")
89 foreach(shared_lib ${shared_list})
90 set(static_list_tmp ${static_list_tmp} "${shared_lib}-static")
91 endforeach()
92
93 # create the variable with the name received by the macro
94 set(${static_list} ${static_list_tmp})
95 # set the scope to parent in order to be visible in the parent
96 set(${static_list} PARENT_SCOPE)
97endmacro(generate_static_dependencies)