From b917d6e0eae3cfa30189ce59693771682c21ccc2 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 2 Nov 2023 14:54:42 +0100 Subject: [PATCH 01/10] Improve cxx17 standard detection - On Fedora 25 with g++ 6.3.1 "optional" header ans std::clamp() cannot be found even if CMAKE_CXX17_COMPILE_FEATURES contains cxx17_standard - Additionnal checks were introduced using vp_check_compiler_flag() to detect if the corresponding standard is incomplete --- cmake/VISPDetectCXXStandard.cmake | 58 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/cmake/VISPDetectCXXStandard.cmake b/cmake/VISPDetectCXXStandard.cmake index ab040d821c..3bbc43dc16 100644 --- a/cmake/VISPDetectCXXStandard.cmake +++ b/cmake/VISPDetectCXXStandard.cmake @@ -30,19 +30,43 @@ else() # That's why we check more in depth for cxx_override that is not available with g++ 4.6.3 list (FIND CMAKE_CXX11_COMPILE_FEATURES "cxx_override" _index) if (${_index} GREATER -1) - set(CXX11_STANDARD_FOUND ON CACHE STRING "cxx11 standard") - mark_as_advanced(CXX11_STANDARD_FOUND) + # Setting CMAKE_CXX_STANDARD doesn't affect check_cxx_source_compiles() used to detect isnan() in FindIsNaN.cmake + # or erfc() in FindErfc.cmake. + # That's why we have the following lines that are used to set cxx flags corresponding to the c++ standard + vp_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx11.cpp") + if(HAVE_STD_CXX11_FLAG) + set(CXX11_CXX_FLAGS "-std=c++11" CACHE STRING "C++ compiler flags for C++11 support") + set(CXX11_STANDARD_FOUND ON CACHE STRING "cxx11 standard") + mark_as_advanced(CXX11_STANDARD_FOUND) + mark_as_advanced(CXX11_CXX_FLAGS) + mark_as_advanced(HAVE_STD_CXX11_FLAG) + endif() endif() endif() if(CMAKE_CXX14_COMPILE_FEATURES) - set(CXX14_STANDARD_FOUND ON CACHE STRING "cxx14 standard") - mark_as_advanced(CXX14_STANDARD_FOUND) + # Additionnal check in case of c++14 is incomplete and also needed to set CXX14_CXX_FLAGS + vp_check_compiler_flag(CXX "-std=c++14" HAVE_STD_CXX14_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx14.cpp") + if(HAVE_STD_CXX14_FLAG) + set(CXX14_CXX_FLAGS "-std=c++14" CACHE STRING "C++ compiler flags for C++14 support") + set(CXX14_STANDARD_FOUND ON CACHE STRING "cxx14 standard") + mark_as_advanced(CXX14_STANDARD_FOUND) + mark_as_advanced(CXX14_CXX_FLAGS) + mark_as_advanced(HAVE_STD_CXX14_FLAG) + endif() endif() if(CMAKE_CXX17_COMPILE_FEATURES) - set(CXX17_STANDARD_FOUND ON CACHE STRING "cxx17 standard") - mark_as_advanced(CXX17_STANDARD_FOUND) + # c++17 seems available, but on Fedora 25 and g++ 6.3.1 it seems incomplete where + # optional header is not found as well as std::clamp() + vp_check_compiler_flag(CXX "-std=c++17" HAVE_STD_CXX17_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx17.cpp") + if(HAVE_STD_CXX17_FLAG) + set(CXX17_CXX_FLAGS "-std=c++17" CACHE STRING "C++ compiler flags for C++17 support") + set(CXX17_STANDARD_FOUND ON CACHE STRING "cxx17 standard") + mark_as_advanced(CXX17_STANDARD_FOUND) + mark_as_advanced(CXX17_CXX_FLAGS) + mark_as_advanced(HAVE_STD_CXX17_FLAG) + endif() endif() # Set default c++ standard to 17, the first in the list @@ -83,26 +107,4 @@ else() set(VISP_CXX_STANDARD ${VISP_CXX_STANDARD_17}) endif() endif() - -endif() - -# Setting CMAKE_CXX_STANDARD doesn't affect check_cxx_source_compiles() used to detect isnan() in FindIsNaN.cmake -# or erfc() in FindErfc.cmake. -# That's why we have the following lines that are used to set cxx flags corresponding to the c++ standard -vp_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx11.cpp") -if(HAVE_STD_CXX11_FLAG) - set(CXX11_CXX_FLAGS "-std=c++11" CACHE STRING "C++ compiler flags for C++11 support") - mark_as_advanced(CXX11_CXX_FLAGS) -endif() - -vp_check_compiler_flag(CXX "-std=c++14" HAVE_STD_CXX14_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx14.cpp") -if(HAVE_STD_CXX14_FLAG) - set(CXX14_CXX_FLAGS "-std=c++14" CACHE STRING "C++ compiler flags for C++14 support") - mark_as_advanced(CXX14_CXX_FLAGS) -endif() - -vp_check_compiler_flag(CXX "-std=c++17" HAVE_STD_CXX17_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx17.cpp") -if(HAVE_STD_CXX17_FLAG) - set(CXX17_CXX_FLAGS "-std=c++17" CACHE STRING "C++ compiler flags for C++17 support") - mark_as_advanced(CXX17_CXX_FLAGS) endif() From 1ea13669ebcf997f9d169c42c390f4562a33b5f6 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Sat, 4 Nov 2023 16:04:12 +0100 Subject: [PATCH 02/10] Fix build when USE_CXX_STANDARD is used --- cmake/VISPDetectCXXStandard.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmake/VISPDetectCXXStandard.cmake b/cmake/VISPDetectCXXStandard.cmake index 3bbc43dc16..6169763899 100644 --- a/cmake/VISPDetectCXXStandard.cmake +++ b/cmake/VISPDetectCXXStandard.cmake @@ -8,12 +8,27 @@ if(DEFINED USE_CXX_STANDARD) if(USE_CXX_STANDARD STREQUAL "11") set(CMAKE_CXX_STANDARD 11) set(VISP_CXX_STANDARD ${VISP_CXX_STANDARD_11}) + vp_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx11.cpp") + if(HAVE_STD_CXX11_FLAG) + set(CXX11_CXX_FLAGS "-std=c++11" CACHE STRING "C++ compiler flags for C++11 support") + mark_as_advanced(HAVE_STD_CXX11_FLAG) + endif() elseif(USE_CXX_STANDARD STREQUAL "14") set(CMAKE_CXX_STANDARD 14) set(VISP_CXX_STANDARD ${VISP_CXX_STANDARD_14}) + vp_check_compiler_flag(CXX "-std=c++14" HAVE_STD_CXX14_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx14.cpp") + if(HAVE_STD_CXX14_FLAG) + set(CXX14_CXX_FLAGS "-std=c++14" CACHE STRING "C++ compiler flags for C++14 support") + mark_as_advanced(HAVE_STD_CXX14_FLAG) + endif() elseif(USE_CXX_STANDARD STREQUAL "17") set(CMAKE_CXX_STANDARD 17) set(VISP_CXX_STANDARD ${VISP_CXX_STANDARD_17}) + vp_check_compiler_flag(CXX "-std=c++17" HAVE_STD_CXX17_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx17.cpp") + if(HAVE_STD_CXX17_FLAG) + set(CXX17_CXX_FLAGS "-std=c++17" CACHE STRING "C++ compiler flags for C++17 support") + mark_as_advanced(HAVE_STD_CXX17_FLAG) + endif() endif() set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11 From c6ef59fe4a26ba0b278517e366531f3dd1c422bf Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 2 Nov 2023 15:16:44 +0100 Subject: [PATCH 03/10] Update ChangeLog file --- ChangeLog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 55ca45d97c..30adc1cddd 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -25,6 +25,8 @@ ViSP 3.x.x (Version in development) https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-tracking-mb-generic-rgbd-Blender.html - Bug fixed . [#1251] Bug in vpDisplay::displayFrame() + . [#1270] Build issue around std::clamp and optional header which are not found with cxx17 + standard enabled ---------------------------------------------- ViSP 3.6.0 (released September 22, 2023) - Contributors: From c30d2650fad6c4588bb9a1fbbca7cb03e11c1814 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Sat, 4 Nov 2023 17:45:42 +0100 Subject: [PATCH 04/10] Use libjpeg-turbo in github actions An issue occurs on macos ci jpeg is keg-only, which means it was not symlinked into /usr/local, because it conflicts with `jpeg-turbo`. --- .github/workflows/macos-ustk.yml | 2 +- .github/workflows/macos.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos-ustk.yml b/.github/workflows/macos-ustk.yml index 7590fe1878..3a35e6982f 100644 --- a/.github/workflows/macos-ustk.yml +++ b/.github/workflows/macos-ustk.yml @@ -34,7 +34,7 @@ jobs: run: system_profiler SPSoftwareDataType - name: Install dependencies - run: brew install libpng libjpeg libdc1394 opencv pcl librealsense zbar vtk fftw armadillo nlohmann-json + run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar vtk fftw armadillo nlohmann-json - name: Clone visp-images env: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2f4e351f10..3ccfd55b72 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -34,7 +34,7 @@ jobs: run: system_profiler SPSoftwareDataType - name: Install dependencies - run: brew install libpng libjpeg libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json + run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json - name: Install java dependencies run: | From 9d4d18fa49a483a80f7c79cebca355cdebc22713 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Wed, 8 Nov 2023 10:02:21 +0100 Subject: [PATCH 05/10] Attempt to add protobuf dependency installation on macos-11 Since the Qt5 build seems failing because protobuf is not found /tmp/qt-20231104-5483-1fey0cz/qt-everywhere-src-6.5.2/qtgrpc/src/tools/qtprotoccommon/generatorbase.cpp:8:10: fatal error: 'google/protobuf/stubs/logging.h' file not found --- .github/workflows/macos-ustk.yml | 9 +++++++-- .github/workflows/macos.yml | 19 ++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/macos-ustk.yml b/.github/workflows/macos-ustk.yml index 3a35e6982f..1bcdcf6589 100644 --- a/.github/workflows/macos-ustk.yml +++ b/.github/workflows/macos-ustk.yml @@ -33,8 +33,13 @@ jobs: - name: Print OS information run: system_profiler SPSoftwareDataType - - name: Install dependencies - run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar vtk fftw armadillo nlohmann-json + - name: Install dependencies for macos-11 + if: matrix.os == 'macos-11' + run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json protobuf + + - name: Install dependencies for macos-12 + if: matrix.os == 'macos-12' + run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json - name: Clone visp-images env: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 3ccfd55b72..47a236f54f 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -33,7 +33,12 @@ jobs: - name: Print OS information run: system_profiler SPSoftwareDataType - - name: Install dependencies + - name: Install dependencies for macos-11 + if: matrix.os == 'macos-11' + run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json protobuf + + - name: Install dependencies for macos-12 + if: matrix.os == 'macos-12' run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json - name: Install java dependencies @@ -87,18 +92,7 @@ jobs: make -j$(sysctl -n hw.logicalcpu) - name: ViSP as 3rdparty with visp.pc and pkg-config - if: matrix.os != 'macOS-10.15' run: | - # With macOS 10.15 there is the following build error: - # /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: - # error: no member named 'signbit' in the global namespace - # using ::signbit; - # also reported here https://stackoverflow.com/questions/58313047/cannot-compile-r-packages-with-c-code-after-updating-to-macos-catalina - # As suggested adding -isysroot build flag in VISPGenerateConfigScript.cmake around line 149 with - # execute_process(COMMAND xcrun --show-sdk-path - # OUTPUT_VARIABLE SDK_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) - # list(APPEND _cxx_flags "-isysroot ${SDK_PATH}") - # doesn't fix the build issue. That's why here the test is only done for macOS 11.0 cd ${HOME}/visp_sample export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig pkg-config --cflags visp @@ -107,7 +101,6 @@ jobs: make -j$(sysctl -n hw.logicalcpu) -f Makefile.visp.pc clean - name: ViSP as 3rdparty with visp-config - if: matrix.os != 'macos-10.15' run: | cd ${HOME}/visp_sample export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig From cfc26dd77cfef9bda600fad1dec32679a6ed219d Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Wed, 8 Nov 2023 11:06:19 +0100 Subject: [PATCH 06/10] Remove macos-11 ci - previous commit doesn't fix Qt 3rdparty installation - It seems also that macos-11 is end-of-life Warning: You are using macOS 11. We (and Apple) do not provide support for this old version. It is expected behaviour that some formulae will fail to build in this old version. It is expected behaviour that Homebrew will be buggy and slow. Do not create any issues about this on Homebrew's GitHub repositories. Do not create any issues even if you think this message is unrelated. Any opened issues will be immediately closed without response. Do not ask for help from Homebrew or its maintainers on social media. You may ask for help in Homebrew's discussions but are unlikely to receive a response. Try to figure out the problem yourself and submit a fix as a pull request. We will review it but may or may not accept it. --- .github/workflows/macos-ustk.yml | 9 ++------- .github/workflows/macos.yml | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/macos-ustk.yml b/.github/workflows/macos-ustk.yml index 1bcdcf6589..120d6211e2 100644 --- a/.github/workflows/macos-ustk.yml +++ b/.github/workflows/macos-ustk.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-11, macos-12] + os: [macos-12] steps: # https://github.com/marketplace/actions/cancel-workflow-action @@ -33,12 +33,7 @@ jobs: - name: Print OS information run: system_profiler SPSoftwareDataType - - name: Install dependencies for macos-11 - if: matrix.os == 'macos-11' - run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json protobuf - - - name: Install dependencies for macos-12 - if: matrix.os == 'macos-12' + - name: Install dependencies run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json - name: Clone visp-images diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 47a236f54f..2e9ea34b43 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-11, macos-12] + os: [macos-12] steps: # https://github.com/marketplace/actions/cancel-workflow-action @@ -33,12 +33,7 @@ jobs: - name: Print OS information run: system_profiler SPSoftwareDataType - - name: Install dependencies for macos-11 - if: matrix.os == 'macos-11' - run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json protobuf - - - name: Install dependencies for macos-12 - if: matrix.os == 'macos-12' + - name: Install dependencies run: brew install libpng libjpeg-turbo libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json - name: Install java dependencies From 98a443ba0b1fe2aef0e59dda667b5d1f7b0a0e8c Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Tue, 14 Nov 2023 09:33:07 +0100 Subject: [PATCH 07/10] Improve PCL 3rd-party detection - vp_find_pcl() is now used in main CMakeLists.txt to avoid calling this macro 3 times in modules gui, sensor and mbt - allows also to have VTK_FOUND var that can be used in main CMakeLists.txt --- .github/workflows/ubuntu-dep-src.yml | 9 ++++++++- CMakeLists.txt | 10 ++++++++++ cmake/PCLTools.cmake | 12 ++++++++++++ modules/gui/CMakeLists.txt | 18 ++---------------- modules/sensor/CMakeLists.txt | 18 ++---------------- modules/tracker/mbt/CMakeLists.txt | 18 ++---------------- 6 files changed, 36 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ubuntu-dep-src.yml b/.github/workflows/ubuntu-dep-src.yml index c481c39a38..af526068c8 100644 --- a/.github/workflows/ubuntu-dep-src.yml +++ b/.github/workflows/ubuntu-dep-src.yml @@ -128,7 +128,14 @@ jobs: cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/install cat ViSP-third-party.txt - - name: Compile + - name: Build visp-config script + working-directory: build + run: | + make -j$(nproc) developer_scripts + ./bin/visp-config --cflags + ./bin/visp-config --libs + + - name: Build and install ViSP working-directory: build run: | make -j$(nproc) install diff --git a/CMakeLists.txt b/CMakeLists.txt index b15c567720..9b9146d19d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -600,6 +600,16 @@ endif() # Upgrade c++ standard to 14 for pcl 1.9.1.99 that enables by default c++ 14 standard if(USE_PCL) + # PCL is used in modules gui, sensor and mbt. + # In these modules we cannot directly use PCL_INCLUDE_DIRS and PCL_LIBRARIES using: + # list(APPEND opt_incs ${PCL_INCLUDE_DIRS}) + # list(APPEND opt_libs ${PCL_LIBRARIES}) + # Using PCL_LIBRARIES works to build visp libraries, embedded examples, demos, tests and tutorials thanks to the + # components. But when examples, demos, tests and tutorials are build outside ViSP workspace as independent projects + # that are using ViSP as 3rd-party we lead to build issues due to VTK headers and libraries that are not found. + # That's why here, we are using vp_find_pcl() macro that will set PCL_DEPS_INCLUDE_DIRS and PCL_DEPS_LIBRARIES + # that contains also VTK material location. + vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES) if(PCL_VERSION VERSION_GREATER 1.9.1) # pcl > 1.9.1 requires c++14 # if c++14 option is OFF, force to c++14 diff --git a/cmake/PCLTools.cmake b/cmake/PCLTools.cmake index 067620172b..91f44645e1 100644 --- a/cmake/PCLTools.cmake +++ b/cmake/PCLTools.cmake @@ -37,6 +37,18 @@ # IN: pcl_libraries # OUT: pcl_deps_include_dirs # OUT: pcl_deps_libraries +# +# PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib +# full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies. +# The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake +# is able to find the real name and location of the libraries. +# But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with +# PCL_LIBRARIES and especially with VTK_LIBRARIES. +# The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link +# with these names. +# An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc +# will be not able to give the names of PCL libraries when used without CMake. +# macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) foreach(lib_ ${${pcl_libraries}}) mark_as_advanced(${lib_}_LOCATION) diff --git a/modules/gui/CMakeLists.txt b/modules/gui/CMakeLists.txt index 8972c4037b..406893195e 100644 --- a/modules/gui/CMakeLists.txt +++ b/modules/gui/CMakeLists.txt @@ -65,22 +65,8 @@ endif() if(USE_PCL) list(APPEND opt_incs ${PCL_INCLUDE_DIRS}) - - # list(APPEND opt_libs ${PCL_LIBRARIES}) - # Using PCL_LIBRARIES works to build visp library, examples, demos and test thanks to the components, - # but not tutorials when they are build outside ViSP as they are stand alone CMake projects that use - # ViSP as a 3rd party. - # To be clear PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib - # full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies. - # The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake - # is able to find the real name and location of the libraries. - # But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with - # PCL_LIBRARIES and especially with VTK_LIBRARIES. - # The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link - # with these names. - # An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc - # will be not able to give the names of PCL libraries when used without CMake. - vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES) + # To ensure to build with VTK and other PCL 3rd parties we are not using PCL_LIBRARIES but PCL_DEPS_INCLUDE_DIRS + # and PCL_DEPS_LIBRARIES instead list(APPEND opt_incs ${PCL_DEPS_INCLUDE_DIRS}) list(APPEND opt_libs ${PCL_DEPS_LIBRARIES}) endif() diff --git a/modules/sensor/CMakeLists.txt b/modules/sensor/CMakeLists.txt index 4529046650..be27453fca 100644 --- a/modules/sensor/CMakeLists.txt +++ b/modules/sensor/CMakeLists.txt @@ -99,22 +99,8 @@ if(USE_FTIITSDK) endif() if(USE_PCL) list(APPEND opt_incs ${PCL_INCLUDE_DIRS}) - - # list(APPEND opt_libs ${PCL_LIBRARIES}) - # Using PCL_LIBRARIES works to build visp library, examples, demos and test thanks to the components, - # but not tutorials when they are build outside ViSP as they are stand alone CMake projects that use - # ViSP as a 3rd party. - # To be clear PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib - # full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies. - # The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake - # is able to find the real name and location of the libraries. - # But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with - # PCL_LIBRARIES and especially with VTK_LIBRARIES. - # The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link - # with these names. - # An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc - # will be not able to give the names of PCL libraries when used without CMake. - vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES) + # To ensure to build with VTK and other PCL 3rd parties we are not using PCL_LIBRARIES but PCL_DEPS_INCLUDE_DIRS + # and PCL_DEPS_LIBRARIES instead list(APPEND opt_incs ${PCL_DEPS_INCLUDE_DIRS}) list(APPEND opt_libs ${PCL_DEPS_LIBRARIES}) endif() diff --git a/modules/tracker/mbt/CMakeLists.txt b/modules/tracker/mbt/CMakeLists.txt index 82d2106226..c5e5e7cb72 100644 --- a/modules/tracker/mbt/CMakeLists.txt +++ b/modules/tracker/mbt/CMakeLists.txt @@ -108,22 +108,8 @@ endif() if(USE_PCL) list(APPEND opt_incs ${PCL_INCLUDE_DIRS}) - - # list(APPEND opt_libs ${PCL_LIBRARIES}) - # Using PCL_LIBRARIES works to build visp library, examples, demos and test thanks to the components, - # but not tutorials when they are build outside ViSP as they are stand alone CMake projects that use - # ViSP as a 3rd party. - # To be clear PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib - # full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies. - # The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake - # is able to find the real name and location of the libraries. - # But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with - # PCL_LIBRARIES and especially with VTK_LIBRARIES. - # The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link - # with these names. - # An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc - # will be not able to give the names of PCL libraries when used without CMake. - vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES) + # To ensure to build with VTK and other PCL 3rd parties we are not using PCL_LIBRARIES but PCL_DEPS_INCLUDE_DIRS + # and PCL_DEPS_LIBRARIES instead list(APPEND opt_incs ${PCL_DEPS_INCLUDE_DIRS}) list(APPEND opt_libs ${PCL_DEPS_LIBRARIES}) endif() From 44d06319430c4933127e8dc31094259d92c63c2e Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Tue, 14 Nov 2023 16:39:12 +0100 Subject: [PATCH 08/10] Add debug info for vtk --- cmake/PCLTools.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/PCLTools.cmake b/cmake/PCLTools.cmake index 91f44645e1..6b63f7f474 100644 --- a/cmake/PCLTools.cmake +++ b/cmake/PCLTools.cmake @@ -93,6 +93,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) # Get pcl link libraries like opengl vp_list_unique(PCL_VTK_LIBRARIES) if(NOT VTK_ENABLE_KITS) + message("--- DEBUG VTK: case 1: NOT VTK_ENABLE_KITS") foreach(lib_ ${PCL_VTK_LIBRARIES}) get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES) if(imported_libs_) @@ -103,6 +104,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endif() get_target_property(imported_incs_ ${lib_} INTERFACE_INCLUDE_DIRECTORIES) + message("--- DEBUG VTK: ${lib_} imported_incs_: ${imported_incs_}") if(imported_incs_) list(APPEND PCL_VTK_IMPORTED_INCS ${imported_incs_}) endif() @@ -153,6 +155,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endwhile() vp_list_unique(PCL_VTK_LIBS) else() + message("--- DEBUG VTK: case 2: VTK_ENABLE_KITS") foreach(lib_ ${PCL_VTK_LIBRARIES}) get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES) if(imported_libs_) @@ -165,6 +168,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endif() get_target_property(imported_incs_ ${lib_} INTERFACE_INCLUDE_DIRECTORIES) + message("--- DEBUG VTK: ${lib_} imported_incs_: ${imported_incs_}") if(imported_incs_) list(APPEND PCL_VTK_IMPORTED_INCS ${imported_incs_}) endif() From 09c900480c5b9d3b2d97244fe3b109e48f8e2d27 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Tue, 14 Nov 2023 16:47:39 +0100 Subject: [PATCH 09/10] Add more debug info for VTK --- .github/workflows/ubuntu-dep-src.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ubuntu-dep-src.yml b/.github/workflows/ubuntu-dep-src.yml index af526068c8..6972064f5e 100644 --- a/.github/workflows/ubuntu-dep-src.yml +++ b/.github/workflows/ubuntu-dep-src.yml @@ -79,6 +79,12 @@ jobs: echo "VTK_DIR=$(pwd)/install" >> $GITHUB_ENV echo $VTK_DIR + - name: DEBUG VTK + run: | + cd $VTK_DIR + ls lib/cmake/vtk-9.3 + grep -R INCLUDE_DIRECTORIES lib/cmake/vtk-9.3/VTK-targets.cmake + - name: Build OpenCV from source run: | pwd From d6aebe3af2700c95c17c75aafb4f25d478a8f853 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Wed, 15 Nov 2023 11:08:41 +0100 Subject: [PATCH 10/10] Fix vtk interface include directories detection - occurs since vtk (ver 9.3.20231115) with cmake 3.27.7 on Ubuntu 22.04 - seems not occuring with cmake 3.22.1 that comes with Ubuntu 22.04 - Retrieving interface include directories on any VTK component with get_target_property(imported_incs_ VTK::ChartsCore INTERFACE_INCLUDE_DIRECTORIES) lead to retrieve $ instead of /home/VTK/install/include/vtk-9.3 - Here the fix consists in removing "$" strings --- .github/workflows/ubuntu-dep-src.yml | 6 ------ cmake/PCLTools.cmake | 30 ++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ubuntu-dep-src.yml b/.github/workflows/ubuntu-dep-src.yml index 6972064f5e..af526068c8 100644 --- a/.github/workflows/ubuntu-dep-src.yml +++ b/.github/workflows/ubuntu-dep-src.yml @@ -79,12 +79,6 @@ jobs: echo "VTK_DIR=$(pwd)/install" >> $GITHUB_ENV echo $VTK_DIR - - name: DEBUG VTK - run: | - cd $VTK_DIR - ls lib/cmake/vtk-9.3 - grep -R INCLUDE_DIRECTORIES lib/cmake/vtk-9.3/VTK-targets.cmake - - name: Build OpenCV from source run: | pwd diff --git a/cmake/PCLTools.cmake b/cmake/PCLTools.cmake index 6b63f7f474..ee1099c80a 100644 --- a/cmake/PCLTools.cmake +++ b/cmake/PCLTools.cmake @@ -33,6 +33,24 @@ # ############################################################################# +# Remove BUILD_INTERFACE from __include_dirs +# IN/OUT: __include_dirs +# +# If __include_dirs contains "$" as input, +# it will be filtered as output to /home/VTK/install/include/vtk-9.3 +macro(vp_filter_build_interface __include_dirs) + if(${__include_dirs}) + set(__include_dirs_filtered) + foreach(inc_ ${${__include_dirs}}) + string(REGEX REPLACE "\\$" "" inc_ ${inc_}) + list(APPEND __include_dirs_filtered ${inc_}) + endforeach() + + set(${__include_dirs} ${__include_dirs_filtered}) + endif() +endmacro() + # Find pcl libraries and dependencies # IN: pcl_libraries # OUT: pcl_deps_include_dirs @@ -93,7 +111,6 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) # Get pcl link libraries like opengl vp_list_unique(PCL_VTK_LIBRARIES) if(NOT VTK_ENABLE_KITS) - message("--- DEBUG VTK: case 1: NOT VTK_ENABLE_KITS") foreach(lib_ ${PCL_VTK_LIBRARIES}) get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES) if(imported_libs_) @@ -104,13 +121,16 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endif() get_target_property(imported_incs_ ${lib_} INTERFACE_INCLUDE_DIRECTORIES) - message("--- DEBUG VTK: ${lib_} imported_incs_: ${imported_incs_}") if(imported_incs_) list(APPEND PCL_VTK_IMPORTED_INCS ${imported_incs_}) endif() endforeach() vp_list_unique(PCL_VTK_IMPORTED_LIBS) vp_list_unique(PCL_VTK_IMPORTED_INCS) + + # Filter "$" into /home/VTK/install/include/vtk-9.3 + vp_filter_build_interface(PCL_VTK_IMPORTED_INCS) + list(APPEND ${pcl_deps_include_dirs} ${PCL_VTK_IMPORTED_INCS}) # Filter "\$;\$;\$" into "vtkCommonMath;opengl32;glu32" @@ -155,7 +175,6 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endwhile() vp_list_unique(PCL_VTK_LIBS) else() - message("--- DEBUG VTK: case 2: VTK_ENABLE_KITS") foreach(lib_ ${PCL_VTK_LIBRARIES}) get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES) if(imported_libs_) @@ -168,13 +187,16 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endif() get_target_property(imported_incs_ ${lib_} INTERFACE_INCLUDE_DIRECTORIES) - message("--- DEBUG VTK: ${lib_} imported_incs_: ${imported_incs_}") if(imported_incs_) list(APPEND PCL_VTK_IMPORTED_INCS ${imported_incs_}) endif() endforeach() vp_list_unique(PCL_VTK_IMPORTED_LIBS) vp_list_unique(PCL_VTK_IMPORTED_INCS) + + # Filter "$" into /home/VTK/install/include/vtk-9.3 + vp_filter_build_interface(PCL_VTK_IMPORTED_INCS) + list(APPEND ${pcl_deps_include_dirs} ${PCL_VTK_IMPORTED_INCS}) while(PCL_VTK_IMPORTED_LIBS)