## # @brief CMake file for Circle Hough with optional GPU version # @details This file compiles the Circle Hough algorithm, the object name is isochroneTrackFinder as of writing this lines. Additionally, and this is the reason for all the lengthy statements in this file, a optional support for a GPU version of the Circle Hough is compiled and linked. # # @author Andreas Herten # @author Tobias Stockmanns ## # The check whether or not CUDA is available is three fold: # 1) The default compiler works with CUDA. This reflects in the variable CUDA_BUILD_POSSIBLE. The lines have been written by Florian Uhlig. (Thanks!) # 2) The CMake module CUDA is available. This is done by find_package(CUDA) and reflected in the variable CUDA_FOUND # 3) The nvcc binary is found. I (Andreas) included this because in our institute, the nvcc binary was always at a /usr/bin/ folder, but only added to $PATH selectively. The result was that CMake's CUDA package would find CUDA in the /usr/bin subfolder, although there really was no GPU available in the machine. Searching the $PATH for nvcc fixes this problem. The result is reflected in NVCC_IS_FOUND. # Only if all three variables are TRUE, one unified variable DO_THE_CUDA_DANCE is set if (NOT DEFINED CUDA_HOST_COMPILER AND CMAKE_C_COMPILER_ID STREQUAL "Clang") If (CMAKE_SYSTEM_NAME MATCHES Darwin) Find_Program(Found_host_compiler NAMES 686-apple-darwin10-gcc-4.2.1 i686-apple-darwin11-llvm-gcc-4.2 PATHS /usr/bin/ ) Else (CMAKE_SYSTEM_NAME MATCHES Darwin) Find_Program(Found_host_compiler NAMES gcc PATHS /usr/bin/ ) EndIf (CMAKE_SYSTEM_NAME MATCHES Darwin) If (Found_host_compiler) set(CUDA_HOST_COMPILER ${Found_host_compiler} CACHE FILEPATH "Host side compiler used by NVCC") message(STATUS "Setting CUDA_HOST_COMPILER to ${Found_host_compiler} instead of ${CMAKE_C_COMPILER}.") set (CUDA_BUILD_POSSIBLE TRUE) Else (Found_host_compiler) message(STATUS "The default compiler ${CMAKE_C_COMPILER} does not work together with the CUDA compiler nvcc. We could not find a gcc compiler so we have to switch off the build of the CUDA examples.") set (CUDA_BUILD_POSSIBLE FALSE) EndIf (Found_host_compiler) else() set (CUDA_BUILD_POSSIBLE TRUE) endif() find_package(CUDA) find_file(NVCC_IS_FOUND nvcc) # message(STATUS ${NVCC_IS_FOUND}) # if (NOT NVCC_IS_FOUND) # message(STATUS "NVCC Not Found") # endif (NOT NVCC_IS_FOUND) # if (NVCC_IS_FOUND) # message(STATUS "NVCC FOUND!") # endif (NVCC_IS_FOUND) if (CUDA_BUILD_POSSIBLE AND CUDA_FOUND AND NVCC_IS_FOUND) set(DO_THE_CUDA_DANCE TRUE) endif (CUDA_BUILD_POSSIBLE AND CUDA_FOUND AND NVCC_IS_FOUND) If (DO_THE_CUDA_DANCE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cuda) add_definitions(-DTHERE_IS_CUDA) # propagate a compiler flag , which can be used to trigger stuff in the .cpp source files message(STATUS "Gentlemen, we are running with CUDA") # message(STATUS ${DO_THE_CUDA_DANCE}) # message(STATUS DO_THE_CUDA_DANCE) EndIf (DO_THE_CUDA_DANCE) set(INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIR} ${CLHEP_INCLUDE_DIR} ${BASE_INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR}/pnddata ${CMAKE_SOURCE_DIR}/pnddata/SttData ${CMAKE_SOURCE_DIR}/pnddata/SdsData ${CMAKE_SOURCE_DIR}/pnddata/TrackData ${CMAKE_SOURCE_DIR}/stt ${CMAKE_SOURCE_DIR}/field ${CMAKE_SOURCE_DIR}/passive ${CMAKE_SOURCE_DIR}/genfit ${CMAKE_SOURCE_DIR}/trackbase ${CMAKE_SOURCE_DIR}/PndTools/riemannfit ${CMAKE_SOURCE_DIR}/PndTools/IsochroneTrackFinder ${CMAKE_SOURCE_DIR}/tracking/online/CircleHough ) If (DO_THE_CUDA_DANCE) LIST(APPEND INCLUDE_DIRECTORIES ${CUDA_INCLUDE}) EndIf (DO_THE_CUDA_DANCE) include_directories( ${INCLUDE_DIRECTORIES} ) set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR} ${FAIRROOT_LIBRARY_DIR} ) link_directories( ${LINK_DIRECTORIES} ) set(SRCS PndIsochroneTrackFinder.cxx PndIsochroneTrackFinderTask.cxx PndTrackFromCircle.cxx cuda/PndIsochroneTrackFinderGpuInterfacer.cxx PndIsoTimer.cxx ) set(LINKDEF isochronefitLinkDef.h) set(LIBRARY_NAME isochroneTrackFinder) set(DEPENDENCIES Base ParBase PndData TrkBase Stt) if (CUDA_BUILD_POSSIBLE AND CUDA_FOUND) LIST(APPEND DEPENDENCIES ${PNDHOUGHCUDA}) endif(CUDA_BUILD_POSSIBLE AND CUDA_FOUND) GENERATE_LIBRARY()