Commit 53cab7ba6f34da97106d1846cd0855b5fe82db54

Authored by DepthDeluxe
1 parent baa0b76e

committing forgotten module.cmake file

openbr/plugins/cuda/module.cmake 0 → 100644
  1 +# add WITH_CUDA option
  2 +option(BR_WITH_CUDA "Build CUDA-accelerated plugins." OFF)
  3 +set(BR_CUDA_ARCH "sm_20" CACHE STRING "CUDA Architecture")
  4 +
  5 +# only build this module if explicitly OK'ed
  6 +if(BR_WITH_CUDA)
  7 + message(STATUS "Building with CUDA Support")
  8 + find_package(CUDA REQUIRED)
  9 +
  10 + set(CUDA_SRC_DIR ${PROJECT_SOURCE_DIR}/openbr/plugins/cuda)
  11 +
  12 + # configure the compiler, need -fPIC for shared library
  13 + set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=${BR_CUDA_ARCH} --compiler-options -fPIC)
  14 + include_directories(${CUDA_INCLUDE_DIRS})
  15 +
  16 + # glob sources
  17 + file(GLOB CUDA_CU_SRC ${CUDA_SRC_DIR}/*.cu)
  18 + file(GLOB CUDA_CPP_SRC ${CUDA_SRC_DIR}/*.cpp)
  19 +
  20 + # compile each of the object files and append to CUDA_CU_OBJ
  21 + foreach(FILE ${CUDA_CU_SRC})
  22 + cuda_compile(FILE_O ${FILE})
  23 + set(CUDA_CU_OBJ ${CUDA_CU_OBJ} ${FILE_O})
  24 + endforeach()
  25 +
  26 + # ensure add_library knows these are external object file
  27 + set_source_files_properties(${CUDA_CU_OBJ} PROPERTIES EXTERNAL_OBJECT true)
  28 +
  29 + # add the compiled source and libs into the build system
  30 + set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} ${CUDA_CPP_SRC} ${CUDA_CU_OBJ})
  31 + set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${CUDA_LIBRARIES})
  32 +
  33 +endif()