Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
cmake: proparage CV_TYPE_SAFE_API/CV_COMPATIBLE_API for user apps
Browse files Browse the repository at this point in the history
- including special fix for CUDA
  • Loading branch information
alalek committed Sep 14, 2018
1 parent 2fb9b04 commit a6d720e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,8 @@ OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON)
OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )

if(ENABLE_TYPE_SAFE_API)
add_definitions(-DCV_TYPE_SAFE_API)
else()
set(ENABLE_COMPATIBLE_API OFF)
endif()

if(ENABLE_COMPATIBLE_API)
add_definitions(-DCV_COMPATIBLE_API)
if(NOT ENABLE_TYPE_SAFE_API)
ocv_assert(NOT ENABLE_COMPATIBLE_API)
endif()

if(ENABLE_IMPL_COLLECTION)
Expand Down
7 changes: 7 additions & 0 deletions cmake/OpenCVDetectCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ if(CUDA_FOUND)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-but-set-variable)
endif()

if(ENABLE_TYPE_SAFE_API)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCV_TYPE_SAFE_API=1)
if(ENABLE_COMPATIBLE_API)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCV_COMPATIBLE_API=1)
endif()
endif()

CUDA_COMPILE(${VAR} ${ARGN})

foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
Expand Down
7 changes: 7 additions & 0 deletions modules/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ if(HAVE_CUDA)
ocv_target_compile_definitions(${the_module} PUBLIC OPENCV_TRAITS_ENABLE_DEPRECATED)
endif()

if(ENABLE_TYPE_SAFE_API)
ocv_target_compile_definitions(${the_module} PUBLIC CV_TYPE_SAFE_API=1)
if(ENABLE_COMPATIBLE_API)
ocv_target_compile_definitions(${the_module} PUBLIC CV_COMPATIBLE_API=1)
endif()
endif()

ocv_add_accuracy_tests()
ocv_add_perf_tests()

Expand Down
7 changes: 7 additions & 0 deletions modules/cudev/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ if(OCV_DEPENDENCIES_FOUND)

ocv_cuda_filter_options()

if(ENABLE_TYPE_SAFE_API)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCV_TYPE_SAFE_API=1")
if(ENABLE_COMPATIBLE_API)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCV_COMPATIBLE_API=1")
endif()
endif()

CUDA_ADD_EXECUTABLE(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} OPTIONS -std=c++11)
ocv_target_link_libraries(${the_target} LINK_PRIVATE
${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES}
Expand Down
8 changes: 8 additions & 0 deletions modules/java/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ endif()

set(__install_export "")
if(BUILD_FAT_JAVA_LIB)
# libopencv_java.so is used during native Android builds (without opencv_core)
if(ENABLE_TYPE_SAFE_API)
ocv_target_compile_definitions(${the_module} PUBLIC CV_TYPE_SAFE_API=1)
if(ENABLE_COMPATIBLE_API)
ocv_target_compile_definitions(${the_module} PUBLIC CV_COMPATIBLE_API=1)
endif()
endif()

set(__install_export EXPORT OpenCVModules)
endif()

Expand Down

0 comments on commit a6d720e

Please sign in to comment.