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