diff --git a/.github/workflows/macos-ustk.yml b/.github/workflows/macos-ustk.yml index 7590fe1878..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 @@ -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 pkg-config nlohmann-json - name: Clone visp-images env: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2f4e351f10..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 @@ -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: | @@ -87,18 +87,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 +96,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 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/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: diff --git a/cmake/PCLTools.cmake b/cmake/PCLTools.cmake index 067620172b..ee1099c80a 100644 --- a/cmake/PCLTools.cmake +++ b/cmake/PCLTools.cmake @@ -33,10 +33,40 @@ # ############################################################################# +# 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 # 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) @@ -97,6 +127,10 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) 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" @@ -159,6 +193,10 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) 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) diff --git a/cmake/VISPDetectCXXStandard.cmake b/cmake/VISPDetectCXXStandard.cmake index ab040d821c..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 @@ -30,19 +45,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 +122,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() 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()