You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.3 KiB
69 lines
2.3 KiB
cmake_minimum_required(VERSION 3.18)
|
|
project(cpp_tracker LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Look for existing LibTorch installation (for systems with PyTorch already installed)
|
|
list(APPEND CMAKE_PREFIX_PATH "/usr/local/libtorch" "$ENV{HOME}/libtorch")
|
|
|
|
# Find dependencies
|
|
find_package(Torch REQUIRED)
|
|
|
|
message(STATUS "Found LibTorch: ${TORCH_LIBRARIES}")
|
|
|
|
# Always use CUDA implementation (no CPU fallback)
|
|
message(STATUS "Building with CUDA support")
|
|
|
|
# Define source files for the libraries
|
|
set(BB_REGRESSOR_SOURCES
|
|
cimp/bb_regressor/bb_regressor.cpp
|
|
cimp/bb_regressor/prroi_pooling/prroi_pooling_gpu.cpp
|
|
)
|
|
|
|
set(CLASSIFIER_SOURCES
|
|
cimp/classifier/classifier.cpp
|
|
)
|
|
|
|
# Create static libraries
|
|
add_library(bb_regressor STATIC ${BB_REGRESSOR_SOURCES})
|
|
add_library(classifier STATIC ${CLASSIFIER_SOURCES})
|
|
|
|
# Set include directories
|
|
target_include_directories(bb_regressor PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cimp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cimp/bb_regressor/prroi_pooling
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src
|
|
)
|
|
target_include_directories(classifier PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/cimp)
|
|
|
|
# Link with LibTorch
|
|
target_link_libraries(bb_regressor PRIVATE ${TORCH_LIBRARIES})
|
|
target_link_libraries(classifier PRIVATE ${TORCH_LIBRARIES})
|
|
|
|
# Create the demo executable
|
|
add_executable(tracking_demo cimp/demo.cpp)
|
|
|
|
# Link the demo with the libraries
|
|
target_link_libraries(tracking_demo PRIVATE bb_regressor classifier ${TORCH_LIBRARIES})
|
|
|
|
# Create the test models executable
|
|
add_executable(test_models test/test_models.cpp)
|
|
|
|
# Link the test with the libraries
|
|
target_link_libraries(test_models PRIVATE bb_regressor classifier ${TORCH_LIBRARIES})
|
|
|
|
# Create the test sample generator executable (without dependencies on our libraries)
|
|
add_executable(generate_test_samples test/generate_test_samples.cpp)
|
|
|
|
# Link the test sample generator only with LibTorch
|
|
target_link_libraries(generate_test_samples PRIVATE ${TORCH_LIBRARIES})
|
|
|
|
# Copy the executable to the binary directory
|
|
install(TARGETS tracking_demo DESTINATION bin)
|
|
install(TARGETS test_models DESTINATION bin)
|
|
install(TARGETS generate_test_samples DESTINATION bin)
|
|
|
|
# Print some info during the build
|
|
message(STATUS "LibTorch found at: ${TORCH_INCLUDE_DIRS}")
|
|
message(STATUS "Using CUDA-enabled build")
|