]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/cagpu/cuda/CMakeLists.txt
Correct use of ROOT_INCLUDE_DIR
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / cagpu / cuda / CMakeLists.txt
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
16 # Module
17 set(MODULE AliHLTTPCCAGPU)
18
19 find_package(CUDA)
20 if(NOT CUDA_FOUND)
21     message( FATAL_ERROR "NVIDIA CUDA package not found. Please install or set HLT_CUDA=OFF" )
22 endif(NOT CUDA_FOUND)
23
24 #set nvcc flags
25 set(CUDA_NVCC_FLAGS --use_fast_math --maxrregcount 64 -O4 -Xptxas -O4 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35)
26
27 #for convenience
28 set(CAGPUDIR ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu)
29
30 # Module include folder
31 include_directories(${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu/cuda
32                     ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu
33                     ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
34                    )
35
36 # Additional include folders in alphabetical order except ROOT
37 include_directories(${ROOT_INCLUDE_DIR}
38                     ${AliRoot_SOURCE_DIR}/HLT/BASE
39                    )
40
41 #nvcc fails with std=c++11, remove it temporarily
42 string(FIND ${CMAKE_CXX_FLAGS} "-std=c++11" STDCXX11FOUND )
43 if(STDCXX11FOUND GREATER -1)
44   string(REPLACE "-std=c++11" "-std=c++98" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
45 endif()
46
47 #compile CUDA object file
48 cuda_compile(CAGPU_O AliHLTTPCCAGPUTrackerNVCC.cu)
49
50 #set it back
51 if(STDCXX11FOUND GREATER -1)
52   string ( REPLACE "-std=c++98" "-std=c++11" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
53 endif()
54 #end of CUDA specific stuff; from here on build usual library
55
56
57 # bit of a hack, but otherwise dictionary compilation fails:
58 # defines cudaError_t to make it known
59 # defines __ROOT__; triggers "ifdef" in source code to circumvent broken cint behaviour with "volatile" keyword
60 # not sure why __ROOT__ is used here, could just as well be something else
61 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/G__AliHLTTPCCAGPU.cxx PROPERTIES COMPILE_DEFINITIONS "cudaError_t=int;__ROOT__")
62
63 # Sources in alphabetical order
64 set(SRCS
65     ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.cxx
66     ${CAGPU_O}
67    )
68
69 # Headers from sources
70 set(CINTHDRS
71     ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.h
72     AliHLTTPCCAGPUTrackerNVCC.h
73     )
74   
75 set(HDRS
76     ${CINTHDRS}
77     ${CAGPUDIR}/AliHLTTPCCAGPUTrackerCommon.h
78   )
79
80 # Generate the dictionary
81 # It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
82 get_directory_property(incdirs INCLUDE_DIRECTORIES)
83 generate_dictionary("${MODULE}" "" "${CINTHDRS}" "${incdirs}")
84
85 # Generate the ROOT map
86 # Dependecies
87 generate_rootmap("${MODULE}" "" "")
88
89 # Add a library to the project using the specified source files
90 add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
91 #CUDA run-time and driver
92 target_link_libraries(${MODULE} ${CUDA_LIBRARIES})
93
94 # Additional compilation flags
95 set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "")
96
97 # Installation
98 install(TARGETS ${MODULE}
99         ARCHIVE DESTINATION lib
100         LIBRARY DESTINATION lib)
101
102 install(FILES ${HDRS} DESTINATION include)