Skip to content

Commit

Permalink
Merge branch 'fix246_vscodebuild' into dp-release
Browse files Browse the repository at this point in the history
* enable build in vscode, custom toolchain+include - fixes luxonis#246
  • Loading branch information
diablodale committed Nov 12, 2021
2 parents c1b697a + bada0ee commit cf360a1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ endif()

# Read the BUILD_SHARED_LIBS option and select PIC toolchain
if(BUILD_SHARED_LIBS)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/pic.cmake" CACHE STRING "")
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/pic.cmake" CACHE STRING "")
endif()
# Specify exporting all symbols on Windows
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "")
endif()
Expand Down Expand Up @@ -427,7 +429,7 @@ if(DEPTHAI_OPENCV_SUPPORT)
add_flag(${TARGET_OPENCV_NAME} -Wno-switch-enum)

# Link to OpenCV (publically)
target_link_libraries(${TARGET_OPENCV_NAME} PUBLIC ${REQUIRED_OPENCV_LIBRARIES})
target_link_libraries(${TARGET_OPENCV_NAME} PUBLIC ${REQUIRED_OPENCV_LIBRARIES} ${THIRDPARTY_OPENCV_LIBRARIES})

# Add public compile definition indicating that OpenCV support is available
set(DEPTHAI_HAVE_OPENCV_SUPPORT ON)
Expand All @@ -439,7 +441,9 @@ if(DEPTHAI_OPENCV_SUPPORT)
target_link_libraries(${TARGET_OPENCV_NAME} PUBLIC ${TARGET_CORE_NAME})

# Add to clangformat target
target_clangformat_setup(${TARGET_OPENCV_NAME} "")
if(COMMAND target_clangformat_setup)
target_clangformat_setup(${TARGET_OPENCV_NAME} "")
endif()

# Add to list of targets to export and install
list(APPEND targets_to_export ${TARGET_OPENCV_NAME})
Expand All @@ -457,9 +461,9 @@ endif()
if(DEPTHAI_SANITIZE)
set(SANITIZE_ADDRESS ON CACHE BOOL "Enable AddressSanitizer for sanitized targets." FORCE)
set(SANITIZE_UNDEFINED ON CACHE BOOL "Enable UndefinedBehaviorSanitizer for sanitized targets." FORCE)
find_package(Sanitizers)
add_sanitizers(${TARGET_CORE_NAME} ${TARGET_OPENCV_NAME})
endif()
find_package(Sanitizers)
add_sanitizers(${TARGET_CORE_NAME} ${TARGET_OPENCV_NAME})

########################
# Testing infrastructure
Expand Down
5 changes: 5 additions & 0 deletions cmake/depthaiDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ endif()
# OpenCV 4 - (optional, quiet always)
find_package(OpenCV 4 QUIET CONFIG)

# include optional dependency cmake
if(DEFINED DEPTHAI_DEPENDENCY_INCLUDE)
include(${DEPTHAI_DEPENDENCY_INCLUDE} OPTIONAL)
endif()

# Cleanup
if(CONFIG_MODE)
set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH_ORIGINAL})
Expand Down
8 changes: 6 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ function(dai_add_example example_name example_src enable_test)
target_link_libraries(${example_name} PRIVATE utility depthai::opencv ${OpenCV_LIBS})

# Add sanitizers for example
add_sanitizers(${example_name})
if(COMMAND add_sanitizers)
add_sanitizers(${example_name})
endif()
# Add to clangformat target
target_clangformat_setup(${example_name} "")
if(COMMAND target_clangformat_setup)
target_clangformat_setup(${example_name} "")
endif()

# parse the rest of the arguments
set(arguments ${ARGV})
Expand Down
8 changes: 6 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ function(dai_add_test test_name test_src)
add_executable(${test_name} ${test_src})

# Add to clangformat target
target_clangformat_setup(${test_name} "")
if(COMMAND target_clangformat_setup)
target_clangformat_setup(${test_name} "")
endif()

# Link to core and Catch2 testing framework
target_link_libraries(${test_name} PRIVATE depthai-core Catch2::Catch2)
Expand All @@ -22,7 +24,9 @@ function(dai_add_test test_name test_src)
add_test(${test_name} ${test_name})

# Add sanitizers for tests as well
add_sanitizers(${test_name})
if(COMMAND add_sanitizers)
add_sanitizers(${test_name})
endif()

# Add ubsan halt on error
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "UBSAN_OPTIONS=halt_on_error=1")
Expand Down

0 comments on commit cf360a1

Please sign in to comment.