From 36a936fff1b86c35d6ae210f8c936fdb5c0f606e Mon Sep 17 00:00:00 2001 From: Liu Yunhuang <1369215984@qq.com> Date: Mon, 15 Apr 2024 12:41:54 +0800 Subject: [PATCH] fix(issue#10): fix multiply PCL_LIBRARIES import. 1. fix a bug which leads to 'FLANN::FLANN-NOTFOUND' in Visual Studio. 2. more clearly CMakeLists.txt. --- CMakeLists.txt | 2 +- gui/CMakeLists.txt | 18 ++++-------------- src/algorithm/CMakeLists.txt | 2 +- src/cameras/CMakeLists.txt | 5 ----- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a7de7c..4cea52a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(SLMaster) set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) set(CMAKE_BUILD_TYPE Release) -#Release模式必须使用以下属性 +set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build) set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} /O2 /Zi") add_subdirectory(src) diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 8e1e286..7311723 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -3,30 +3,20 @@ project(SLMasterGui) add_subdirectory(thirdParty/FluentUI) add_subdirectory(thirdParty/QuickQanava) -find_package(PCL REQUIRED) find_package(VTK REQUIRED) find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core Gui Quick Qml QuickControls2) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Quick Qml QuickControls2) -find_package(OpenCV COMPONENTS core cudev) - -if(OpenCV_cudev_FOUND) - add_definitions(-DOPENCV_WITH_CUDA_MODULE) -endif() set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) -set(CMAKE_OBJCXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD_REQUIRED ON) file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/qml/*.h ${CMAKE_CURRENT_SOURCE_DIR}/qml/*.cpp) file(GLOB_RECURSE QML ${CMAKE_CURRENT_SOURCE_DIR}/qml/*.qml) file(GLOB_RECURSE QRC ${CMAKE_CURRENT_SOURCE_DIR}/qml/*.qrc ${CMAKE_CURRENT_SOURCE_DIR}/qml/qmldir* ${CMAKE_CURRENT_SOURCE_DIR}/qml/*.rc) -set(SLMasterGuiDEPLIBS slmaster Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::QuickControls2 QuickQanava) -if(CUDA_FOUND) - message("cuda found...") - list(APPEND SLMasterGuiDEPLIBS ${CUDA_LIBRARIES}) -endif() +set(SLMasterGuiDEPLIBS slmaster ${VTK_LIBRARIES} Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::QuickControls2 QuickQanava) if (FLUENTUI_BUILD_STATIC_LIB AND (QT_VERSION VERSION_GREATER_EQUAL "6.2")) list(APPEND SLMasterGuiDEPLIBS fluentui) @@ -37,9 +27,9 @@ endif() add_executable(SLMasterGui WIN32) target_sources(SLMasterGui PRIVATE ${SOURCES} ${QML} ${QRC}) target_include_directories(SLMasterGui PRIVATE QuickQanava ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/calibrationMaster ${CMAKE_CURRENT_SOURCE_DIR}/src/nodes Qt${QT_VERSION_MAJOR}::QuickControls2) -target_link_libraries(SLMasterGui PRIVATE ${SLMasterGuiDEPLIBS} ${VTK_LIBRARIES} ${PCL_LIBRARIES}) +target_link_libraries(SLMasterGui PRIVATE ${SLMasterGuiDEPLIBS}) vtk_module_autoinit( TARGETS SLMasterGui MODULES ${VTK_LIBRARIES} -) +) \ No newline at end of file diff --git a/src/algorithm/CMakeLists.txt b/src/algorithm/CMakeLists.txt index 45a96e9..24e931d 100644 --- a/src/algorithm/CMakeLists.txt +++ b/src/algorithm/CMakeLists.txt @@ -12,7 +12,6 @@ FILE(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cpuStructuredLight/*.h ${C if(OpenCV_cudev_FOUND) message(NOTICE "[SLMaster]: OpenCV With CUDA module.") - add_definitions(-DOPENCV_WITH_CUDA_MODULE) enable_language(CUDA) FILE(GLOB_RECURSE GPU_ALGORITHMS ${CMAKE_CURRENT_SOURCE_DIR}/gpuStructuredLight/*.h ${CMAKE_CURRENT_SOURCE_DIR}/gpuStructuredLight/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/gpuStructuredLight/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gpuStructuredLight/*.cu) list(APPEND SOURCES ${GPU_ALGORITHMS}) @@ -20,6 +19,7 @@ if(OpenCV_cudev_FOUND) add_library(algorithm ${SOURCES}) target_include_directories(algorithm PUBLIC {CMAKE_CURRENT_SOURCE_DIR} ${EIGEN3_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS}) target_link_libraries(algorithm PUBLIC ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${CUDA_LIBRARIES}) + target_compile_definitions(algorithm PUBLIC -DOPENCV_WITH_CUDA_MODULE) set_target_properties(algorithm PROPERTIES CUDA_STANDARD 11) else() message(WARNING "[SLMaster]: OpenCV dosn't With CUDA module! Just complier CPU Version.") diff --git a/src/cameras/CMakeLists.txt b/src/cameras/CMakeLists.txt index 5c61e14..9800d5f 100644 --- a/src/cameras/CMakeLists.txt +++ b/src/cameras/CMakeLists.txt @@ -2,11 +2,6 @@ cmake_minimum_required(VERSION 3.20) project(cameras) -find_package(OpenCV COMPONENTS core cudev) -if(OpenCV_cudev_FOUND) - add_definitions(-DOPENCV_WITH_CUDA_MODULE) -endif() - file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) if(BUILD_SLMASTER_SHARED)