Commit be489c2247c99d1803eeb449cb65ba43e2456359
1 parent
eac782df
added build option for CUDA
Showing
2 changed files
with
30 additions
and
8 deletions
openbr/CMakeLists.txt
| @@ -9,11 +9,6 @@ set(SRC openbr.cpp | @@ -9,11 +9,6 @@ set(SRC openbr.cpp | ||
| 9 | aux_source_directory(core BR_CORE) | 9 | aux_source_directory(core BR_CORE) |
| 10 | include(plugins/plugins.cmake) | 10 | include(plugins/plugins.cmake) |
| 11 | 11 | ||
| 12 | -# CUDA shit | ||
| 13 | -FIND_PACKAGE(CUDA REQUIRED) | ||
| 14 | -SET(CUDA_SEPARABLE_COMPILATION ON) | ||
| 15 | -SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=sm_20;--compiler-options "-fPIC") | ||
| 16 | -SET(CUDA_VERBOSE_BUILD ON) | ||
| 17 | 12 | ||
| 18 | # Janus API | 13 | # Janus API |
| 19 | option(BR_WITH_JANUS "Build IARPA Janus related applications." ON) | 14 | option(BR_WITH_JANUS "Build IARPA Janus related applications." ON) |
| @@ -34,13 +29,30 @@ if(NOT BR_EMBEDDED) | @@ -34,13 +29,30 @@ if(NOT BR_EMBEDDED) | ||
| 34 | install(FILES ${HEADERS} DESTINATION include/openbr/gui) | 29 | install(FILES ${HEADERS} DESTINATION include/openbr/gui) |
| 35 | endif() | 30 | endif() |
| 36 | 31 | ||
| 37 | -cuda_add_library(openbr SHARED ${SRC} ${BR_CORE} ${BR_JANUS} ${BR_GUI} ${BR_ICONS} ${BR_THIRDPARTY_SRC} ${BR_RESOURCES} ${NATURALSTRINGCOMPARE_SRC} ${THIRDPARTY_RESOURCES}) | 32 | +# add CUDA compiler flags if CUDA support is enabled |
| 33 | +option(BR_WITH_CUDA "Build CUDA-accelerate plugins." OFF) | ||
| 34 | +if (BR_WITH_CUDA) | ||
| 35 | + FIND_PACKAGE(CUDA REQUIRED) | ||
| 36 | + SET(CUDA_SEPARABLE_COMPILATION ON) | ||
| 37 | + SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=sm_20;--compiler-options "-fPIC") | ||
| 38 | + | ||
| 39 | + cuda_add_library(openbr SHARED ${SRC} ${BR_CORE} ${BR_JANUS} ${BR_GUI} ${BR_ICONS} ${BR_THIRDPARTY_SRC} ${BR_RESOURCES} ${NATURALSTRINGCOMPARE_SRC} ${THIRDPARTY_RESOURCES}) | ||
| 40 | +else() | ||
| 41 | + # otherwise, build with normal system | ||
| 42 | + add_library(openbr SHARED ${SRC} ${BR_CORE} ${BR_JANUS} ${BR_GUI} ${BR_ICONS} ${BR_THIRDPARTY_SRC} ${BR_RESOURCES} ${NATURALSTRINGCOMPARE_SRC} ${THIRDPARTY_RESOURCES}) | ||
| 43 | +endif() | ||
| 38 | qt5_use_modules(openbr ${QT_DEPENDENCIES}) | 44 | qt5_use_modules(openbr ${QT_DEPENDENCIES}) |
| 39 | set_target_properties(openbr PROPERTIES | 45 | set_target_properties(openbr PROPERTIES |
| 40 | DEFINE_SYMBOL BR_LIBRARY | 46 | DEFINE_SYMBOL BR_LIBRARY |
| 41 | VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} | 47 | VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} |
| 42 | SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}) | 48 | SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}) |
| 43 | -target_link_libraries(openbr ${BR_THIRDPARTY_LIBS} ${CUDA_LIBRARIES}) | 49 | +target_link_libraries(openbr ${BR_THIRDPARTY_LIBS}) |
| 50 | + | ||
| 51 | +# include CUDA dependencies | ||
| 52 | +if (BR_WITH_CUDA) | ||
| 53 | + target_link_libraries(openbr ${CUDA_LIBRARIES}) | ||
| 54 | +endif() | ||
| 55 | + | ||
| 44 | add_cppcheck(openbr) | 56 | add_cppcheck(openbr) |
| 45 | 57 | ||
| 46 | # Janus implementation | 58 | # Janus implementation |
openbr/plugins/plugins.cmake
| @@ -12,6 +12,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${BR_THIRDPARTY_PLUGINS_DIR}) | @@ -12,6 +12,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${BR_THIRDPARTY_PLUGINS_DIR}) | ||
| 12 | file(GLOB SUBFILES plugins/*) | 12 | file(GLOB SUBFILES plugins/*) |
| 13 | foreach(FILE ${SUBFILES}) | 13 | foreach(FILE ${SUBFILES}) |
| 14 | if(IS_DIRECTORY ${FILE}) | 14 | if(IS_DIRECTORY ${FILE}) |
| 15 | + # don't add the CUDA directory in plugins folder if we have disabled CUDA | ||
| 16 | + get_filename_component(FILE_NAME ${FILE} NAME) | ||
| 17 | + if (NOT ${BR_WITH_CUDA} AND ${FILE_NAME} STREQUAL "cuda") | ||
| 18 | + continue() | ||
| 19 | + endif() | ||
| 20 | + | ||
| 15 | set(BR_PLUGINS_DIR ${BR_PLUGINS_DIR} ${FILE}) | 21 | set(BR_PLUGINS_DIR ${BR_PLUGINS_DIR} ${FILE}) |
| 16 | endif() | 22 | endif() |
| 17 | endforeach() | 23 | endforeach() |
| @@ -31,7 +37,11 @@ endforeach() | @@ -31,7 +37,11 @@ endforeach() | ||
| 31 | # Collect all source files except for excluded plugins | 37 | # Collect all source files except for excluded plugins |
| 32 | foreach(DIR ${BR_PLUGINS_DIR} ${BR_THIRDPARTY_PLUGINS_DIR}) | 38 | foreach(DIR ${BR_PLUGINS_DIR} ${BR_THIRDPARTY_PLUGINS_DIR}) |
| 33 | get_filename_component(DIR_NAME ${DIR} NAME) | 39 | get_filename_component(DIR_NAME ${DIR} NAME) |
| 34 | - file(GLOB PLUGINS ${DIR}/*.cpp ${DIR}/*.cu ${DIR}/*.h) | 40 | + if (BR_WITH_CUDA) |
| 41 | + file(GLOB PLUGINS ${DIR}/*.cpp ${DIR}/*.cu ${DIR}/*.h) | ||
| 42 | + else() | ||
| 43 | + file(GLOB PLUGINS ${DIR}/*.cpp ${DIR}/*.h) | ||
| 44 | + endif() | ||
| 35 | foreach(PLUGIN ${PLUGINS}) | 45 | foreach(PLUGIN ${PLUGINS}) |
| 36 | get_filename_component(PLUGIN_NAME ${PLUGIN} NAME) | 46 | get_filename_component(PLUGIN_NAME ${PLUGIN} NAME) |
| 37 | set(EXCLUDE FALSE) | 47 | set(EXCLUDE FALSE) |