Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
add_subdirectory(googletest)

file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build")
# Unified TBB Configuration
option(TBB_TEST "Build TBB tests" OFF)
option(TBB_EXAMPLES "Build TBB examples" OFF)
set(TBB_STRICT OFF CACHE BOOL "Treat compiler warnings as errors")

execute_process(
COMMAND ${CMAKE_COMMAND} -S "${CMAKE_SOURCE_DIR}/3rdparty/TBB" -B "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build" -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DTBB_OUTPUT_DIR_BASE=tbb
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build"
)
execute_process(
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build" --config "${CMAKE_BUILD_TYPE}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build"
)

option(TBB_TEST OFF)
# Configure TBB with unified settings
add_subdirectory(TBB)

# Create a unified TBB interface target
if(NOT TARGET TBB_unified)
add_library(TBB_unified INTERFACE)
target_link_libraries(TBB_unified INTERFACE TBB::tbb)
target_include_directories(TBB_unified INTERFACE
$<TARGET_PROPERTY:TBB::tbb,INTERFACE_INCLUDE_DIRECTORIES>
)

# Platform-specific runtime library handling for Windows
if(WIN32)
# Get the TBB library directory based on build type
if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build)
set(TBB_LIB_DIR "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build/tbb_${lower_build}")
else()
set(TBB_LIB_DIR "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build/tbb_debug")
endif()

# Create a custom target to copy TBB runtime libraries
add_custom_target(copy_tbb_runtime ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:TBB::tbb>"
"${CMAKE_BINARY_DIR}/bin/"
COMMENT "Copying TBB runtime libraries"
)
add_dependencies(TBB_unified copy_tbb_runtime)
endif()
endif()
2 changes: 1 addition & 1 deletion app/Accuracy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set_target_properties(ReadLib PROPERTIES LINKER_LANGUAGE CXX)
find_package( OpenCV REQUIRED PATHS "${CMAKE_SOURCE_DIR}/3rdparty/opencv/build" )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( ACCLib ${OpenCV_LIBS} )
target_link_libraries( ACCLib TBB::tbb)
target_link_libraries( ACCLib TBB_unified)
target_link_libraries( ACCLib layers_lib)
target_link_libraries( ACCLib gtest_main)

Expand Down
2 changes: 1 addition & 1 deletion app/AccuracyImgNet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ add_executable(ACCImgNet accimgnet.cpp)
find_package( OpenCV REQUIRED PATHS "${CMAKE_SOURCE_DIR}/3rdparty/opencv/build" )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( ACCImgNet ${OpenCV_LIBS} )
target_link_libraries( ACCImgNet TBB::tbb)
target_link_libraries( ACCImgNet TBB_unified)
target_link_libraries( ACCImgNet layers_lib)
target_link_libraries( ACCImgNet gtest_main)
2 changes: 1 addition & 1 deletion app/Graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include_directories(${OpenCV_INCLUDE_DIRS})

target_link_libraries(BuildGraph PUBLIC ${OpenCV_LIBS})
target_link_libraries(BuildGraph PUBLIC reader_lib)
target_link_libraries(BuildGraph PUBLIC TBB::tbb)
target_link_libraries(BuildGraph PUBLIC TBB_unified)
target_link_libraries(BuildGraph PUBLIC layers_lib)
target_link_libraries(BuildGraph PUBLIC gtest_main)

Expand Down
2 changes: 1 addition & 1 deletion app/ReaderImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set_target_properties(ReadLib PROPERTIES LINKER_LANGUAGE CXX)
find_package( OpenCV REQUIRED PATHS "${CMAKE_SOURCE_DIR}/3rdparty/opencv/build" )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( ReadLib ${OpenCV_LIBS} )
target_link_libraries( ReadLib TBB::tbb)
target_link_libraries( ReadLib TBB_unified)

add_executable(Reader reader_img.cpp)
target_link_libraries(Reader ReadLib)
Expand Down
2 changes: 1 addition & 1 deletion src/graph/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file(GLOB_RECURSE graph_src *.cpp)
add_library(graph_lib STATIC "${GRAPH_HEADERS}" "${graph_src}")
target_link_libraries(graph_lib PUBLIC TBB::tbb)
target_link_libraries(graph_lib PUBLIC TBB_unified)
18 changes: 1 addition & 17 deletions src/layers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
file(GLOB_RECURSE layers_src *.cpp)
add_library(layers_lib STATIC "${LAYERS_HEADERS}" "${layers_src}")
target_link_libraries(layers_lib PUBLIC TBB::tbb)
if (WIN32)
if (CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build)
file(GLOB_RECURSE tbb_files "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build/tbb_${lower_build}/tbb*")
add_custom_command(TARGET layers_lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${tbb_files}
"${CMAKE_BINARY_DIR}/bin/")
else()
file(GLOB_RECURSE tbb_files "${CMAKE_SOURCE_DIR}/3rdparty/TBB/build/tbb_debug/tbb*")
add_custom_command(TARGET layers_lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${tbb_files}
"${CMAKE_BINARY_DIR}/bin/")
endif()
endif()
target_link_libraries(layers_lib PUBLIC TBB_unified)
Loading