From b16de6688f5af4a9099f42cc3057ebb27b4e8022 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Wed, 27 Apr 2022 18:13:42 +0200 Subject: [PATCH 01/12] Make the same adapations as in core and imu --- CMakeLists.txt | 65 ++++++++++------- cmake_modules/wolfvisionConfig.cmake | 94 ------------------------- cmake_modules/wolfvisionConfig.cmake.in | 17 +++++ 3 files changed, 56 insertions(+), 120 deletions(-) delete mode 100644 cmake_modules/wolfvisionConfig.cmake create mode 100644 cmake_modules/wolfvisionConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 22e48a94..267dab43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Pre-requisites about cmake itself -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.10) if(COMMAND cmake_policy) cmake_policy(SET CMP0005 NEW) @@ -10,13 +10,12 @@ SET(CMAKE_MACOSX_RPATH true) # The project name PROJECT(vision) -set(PLUGIN_NAME wolf${PROJECT_NAME}) +set(PLUGIN_NAME "wolf${PROJECT_NAME}") MESSAGE("Starting ${PROJECT_NAME} CMakeLists ...") -SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) -SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib) -SET(CMAKE_INSTALL_PREFIX /usr/local) +set(INCLUDE_INSTALL_DIR include/iri-algorithms/wolf) +set(LIB_INSTALL_DIR lib/) IF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "DEBUG") @@ -81,8 +80,7 @@ option(_WOLF_TRACE "Enable wolf tracing macro" ON) # ============ DEPENDENCIES ================== FIND_PACKAGE(wolfcore REQUIRED) -FIND_PACKAGE(vision_utils REQUIRED) -SET(PRINT_INFO_VU false) +# SET(PRINT_INFO_VU false) FIND_PACKAGE(OpenCV REQUIRED) # ============ config.h ================== @@ -107,9 +105,6 @@ message("CONFIG DIRECTORY ${PROJECT_BINARY_DIR}") include_directories("${PROJECT_BINARY_DIR}/conf") # ============ INCLUDES ================== -INCLUDE_DIRECTORIES(${wolfcore_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${vision_utils_INCLUDE_DIR}) -INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(BEFORE "include") # ============ HEADERS ============ @@ -197,9 +192,9 @@ endif() #Link the created libraries #===============EXAMPLE========================= -TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${wolfcore_LIBRARIES}) -TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${OpenCV_LIBS}) -TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${vision_utils_LIBRARY}) +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} wolfcore) +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} OpenCV) +# TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${vision_utils_LIBRARY}) #Build demos #===============EXAMPLE========================= @@ -222,30 +217,48 @@ INSTALL(TARGETS ${PLUGIN_NAME} EXPORT ${PLUGIN_NAME}Targets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +# Configure the package installation +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_SOURCE_DIR}/cmake_modules/${PLUGIN_NAME}Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}Config.cmake + INSTALL_DESTINATION ${LIB_INSTALL_DIR}/${PLUGIN_NAME}/cmake + PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR +) + +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}Config.cmake + DESTINATION + ${LIB_INSTALL_DIR}/${PLUGIN_NAME}/cmake +) + +# Specifies include directories to use when compiling the plugin target +# This way, include_directories does not need to be called in plugins depending on this one +target_include_directories(${PLUGIN_NAME} INTERFACE + $ +) + + install(EXPORT ${PLUGIN_NAME}Targets DESTINATION lib/cmake/${PLUGIN_NAME}) #install headers INSTALL(FILES ${HDRS_CAPTURE} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/capture) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/capture) INSTALL(FILES ${HDRS_FACTOR} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/factor) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/factor) INSTALL(FILES ${HDRS_FEATURE} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/feature) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/feature) INSTALL(FILES ${HDRS_LANDMARK} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/landmark) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/landmark) INSTALL(FILES ${HDRS_MATH} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/math) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/math) INSTALL(FILES ${HDRS_PROCESSOR} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/processor) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/processor) INSTALL(FILES ${HDRS_SENSOR} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/sensor) + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/sensor) -FILE(WRITE ${PROJECT_NAME}.found "") -INSTALL(FILES ${PROJECT_NAME}.found - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}) INSTALL(FILES "${WOLF_CONFIG_DIR}/config.h" - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/internal) - -INSTALL(FILES "${CMAKE_SOURCE_DIR}/cmake_modules/${PLUGIN_NAME}Config.cmake" DESTINATION "lib/cmake/${PLUGIN_NAME}") + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/internal) INSTALL(DIRECTORY ${SPDLOG_INCLUDE_DIRS} DESTINATION "include/iri-algorithms/") diff --git a/cmake_modules/wolfvisionConfig.cmake b/cmake_modules/wolfvisionConfig.cmake deleted file mode 100644 index 935cc70e..00000000 --- a/cmake_modules/wolfvisionConfig.cmake +++ /dev/null @@ -1,94 +0,0 @@ -#edit the following line to add the librarie's header files -FIND_PATH( - wolfvision_INCLUDE_DIRS - NAMES vision.found - PATHS /usr/local/include/iri-algorithms/wolf/plugin_vision) -IF(wolfvision_INCLUDE_DIRS) - MESSAGE("Found vision include dirs: ${wolfvision_INCLUDE_DIRS}") -ELSE(wolfvision_INCLUDE_DIRS) - MESSAGE("Couldn't find vision include dirs") -ENDIF(wolfvision_INCLUDE_DIRS) - -FIND_LIBRARY( - wolfvision_LIBRARIES - NAMES libwolfvision.so libwolfvision.dylib - PATHS /usr/local/lib) -IF(wolfvision_LIBRARIES) - MESSAGE("Found vision lib: ${wolfvision_LIBRARIES}") -ELSE(wolfvision_LIBRARIES) - MESSAGE("Couldn't find wolf vision lib") -ENDIF(wolfvision_LIBRARIES) - -IF (wolfvision_INCLUDE_DIRS AND wolfvision_LIBRARIES) - SET(wolfvision_FOUND TRUE) - ELSE(wolfvision_INCLUDE_DIRS AND wolfvision_LIBRARIES) - set(wolfvision_FOUND FALSE) -ENDIF (wolfvision_INCLUDE_DIRS AND wolfvision_LIBRARIES) - -IF (wolfvision_FOUND) - IF (NOT wolfvision_FIND_QUIETLY) - MESSAGE(STATUS "Found vision: ${wolfvision_LIBRARIES}") - ENDIF (NOT wolfvision_FIND_QUIETLY) -ELSE (wolfvision_FOUND) - IF (wolfvision_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find wolf vision") - ENDIF (wolfvision_FIND_REQUIRED) -ENDIF (wolfvision_FOUND) - - -macro(wolf_report_not_found REASON_MSG) - set(wolfvision_FOUND FALSE) - unset(wolfvision_INCLUDE_DIRS) - unset(wolfvision_LIBRARIES) - - # Reset the CMake module path to its state when this script was called. - set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) - - # Note _FIND_[REQUIRED/QUIETLY] variables defined by - # FindPackage() use the camelcase library name, not uppercase. - if (wolfvision_FIND_QUIETLY) - message(STATUS "Failed to find wolfvision- " ${REASON_MSG} ${ARGN}) - elseif (wolfvision_FIND_REQUIRED) - message(FATAL_ERROR "Failed to find wolfvision - " ${REASON_MSG} ${ARGN}) - else() - # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error - # that prevents generation, but continues configuration. - message(SEND_ERROR "Failed to find wolfvision - " ${REASON_MSG} ${ARGN}) - endif () - return() -endmacro(wolf_report_not_found) - -if(NOT wolfvision_FOUND) - wolf_report_not_found("Something went wrong while setting up wolf vision.") -endif(NOT wolfvision_FOUND) -# Set the include directories for wolf (itself). -set(wolfvision_FOUND TRUE) - -# Now we gather all the required dependencies for Wolf Laser - -FIND_PACKAGE(vision_utils REQUIRED) -list(APPEND wolfvision_INCLUDE_DIRS ${vision_utils_INCLUDE_DIR}) -list(APPEND wolfvision_LIBRARIES ${vision_utils_LIBRARY}) - -FIND_PACKAGE(OpenCV REQUIRED) -list(APPEND wolfvision_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS}) -list(APPEND wolfvision_LIBRARIES ${OpenCV_LIBS}) - -#Making sure wolf is looked for -if(NOT wolf_FOUND) - FIND_PACKAGE(wolfcore REQUIRED) - - #We reverse in order to insert at the start - list(REVERSE wolfvision_INCLUDE_DIRS) - list(APPEND wolfvision_INCLUDE_DIRS ${wolfcore_INCLUDE_DIRS}) - list(REVERSE wolfvision_INCLUDE_DIRS) - - list(REVERSE wolfvision_LIBRARIES) - list(APPEND wolfvision_LIBRARIES ${wolfcore_LIBRARIES}) - list(REVERSE wolfvision_LIBRARIES) -endif() - -# provide both INCLUDE_DIR and INCLUDE_DIRS -SET(wolfvision_INCLUDE_DIR ${wolfvision_INCLUDE_DIRS}) -# provide both LIBRARY and LIBRARIES -SET(wolfvision_LIBRARY ${wolfvision_LIBRARIES}) \ No newline at end of file diff --git a/cmake_modules/wolfvisionConfig.cmake.in b/cmake_modules/wolfvisionConfig.cmake.in new file mode 100644 index 00000000..6f428e25 --- /dev/null +++ b/cmake_modules/wolfvisionConfig.cmake.in @@ -0,0 +1,17 @@ +set(@PLUGIN_NAME@_VERSION 0.0.1) + + +@PACKAGE_INIT@ + +set_and_check(@PLUGIN_NAME@_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set(@PLUGIN_NAME@_INCLUDE_DIRS @PLUGIN_NAME@_INCLUDE_DIR) +set_and_check(@PLUGIN_NAME@_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@") +set(@PLUGIN_NAME@_LIB_INSTALL_DIRS @PLUGIN_NAME@_LIB_INSTALL_DIR) + +# forwards the correct parameters given to FIND_DEPENDENCIES +include(CMakeFindDependencyMacro) +FIND_DEPENDENCY(OpenCV REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/@PLUGIN_NAME@Targets.cmake") + +check_required_components(@PLUGIN_NAME@) \ No newline at end of file -- GitLab From 375b7932b10507b82a32c609efe9c818ea4c904e Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Fri, 29 Apr 2022 11:25:17 +0200 Subject: [PATCH 02/12] Tested with the new dependencies found in new visual odometry implementation (no visual_utils) --- CMakeLists.txt | 8 +++++++- demos/CMakeLists.txt | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 267dab43..c157c0c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,9 @@ set(PLUGIN_NAME "wolf${PROJECT_NAME}") MESSAGE("Starting ${PROJECT_NAME} CMakeLists ...") +# Paths +SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) +SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib) set(INCLUDE_INSTALL_DIR include/iri-algorithms/wolf) set(LIB_INSTALL_DIR lib/) @@ -193,8 +196,12 @@ endif() #Link the created libraries #===============EXAMPLE========================= TARGET_LINK_LIBRARIES(${PLUGIN_NAME} wolfcore) +<<<<<<< Updated upstream TARGET_LINK_LIBRARIES(${PLUGIN_NAME} OpenCV) # TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${vision_utils_LIBRARY}) +======= +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${OpenCV_LIBRARIES}) +>>>>>>> Stashed changes #Build demos #===============EXAMPLE========================= @@ -240,7 +247,6 @@ target_include_directories(${PLUGIN_NAME} INTERFACE ) -install(EXPORT ${PLUGIN_NAME}Targets DESTINATION lib/cmake/${PLUGIN_NAME}) #install headers INSTALL(FILES ${HDRS_CAPTURE} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/capture) diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index 42a4d304..08e1123d 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -1,3 +1,4 @@ +<<<<<<< Updated upstream if (OpenCV_FOUND) if (${OpenCV_VERSION_MAJOR} GREATER 1) @@ -14,5 +15,9 @@ endif(OpenCV_FOUND) ADD_EXECUTABLE(demo_processor_bundle_adjustment demo_processor_bundle_adjustment.cpp) TARGET_LINK_LIBRARIES(demo_processor_bundle_adjustment ${PLUGIN_NAME} ${OpenCV_LIBS}) +======= +ADD_EXECUTABLE(demo_visual_odometry demo_visual_odometry.cpp) +TARGET_LINK_LIBRARIES(demo_visual_odometry ${PLUGIN_NAME} ${OpenCV_LIBS}) +>>>>>>> Stashed changes -- GitLab From 1e142f67b40ab00781525c914659155c0c742c46 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Tue, 3 May 2022 19:24:06 +0200 Subject: [PATCH 03/12] Fix: Link with OpenCV using COMPONENTS --- CMakeLists.txt | 29 +++++++++++++++++++++---- include/vision/factor/factor_pixel_hp.h | 6 ----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86e5e79b..d0982431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,10 @@ option(_WOLF_TRACE "Enable wolf tracing macro" ON) # ============ DEPENDENCIES ================== FIND_PACKAGE(wolfcore REQUIRED) -SET(PRINT_INFO_VU false) -FIND_PACKAGE(OpenCV REQUIRED) +FIND_PACKAGE(OpenCV REQUIRED + COMPONENTS core imgcodecs highgui features2d calib3d video +) + # ============ config.h ================== string(TOUPPER ${PROJECT_NAME} UPPER_NAME) @@ -184,10 +186,29 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using GCC endif() -#Link the created libraries +# Link the created libraries #===============EXAMPLE========================= TARGET_LINK_LIBRARIES(${PLUGIN_NAME} wolfcore) -TARGET_LINK_LIBRARIES(${PLUGIN_NAME} OpenCV) +# For OpenCV, link with respect to each required components, found in the find_package command +# The required components have the same name as the include files e.g. +# or the opencv2 subdirectory in which they are found, e.g. +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} + opencv_core + opencv_imgcodecs + opencv_highgui + opencv_features2d + opencv_calib3d + opencv_video +) + + +# # TARGET_LINK_LIBRARIES(${PLUGIN_NAME} opencv) +# get_target_property(toto wolfcore INCLUDE_DIRECTORIES) +# message(WARNING ${toto}) +# get_target_property(toto wolfcore INTERFACE_INCLUDE_DIRECTORIES) +# message(WARNING ${toto}) +# get_target_property(toto wolfcore INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) +# message(WARNING ${toto}) #Build demos #===============EXAMPLE========================= diff --git a/include/vision/factor/factor_pixel_hp.h b/include/vision/factor/factor_pixel_hp.h index 8693b5f7..fc92af15 100644 --- a/include/vision/factor/factor_pixel_hp.h +++ b/include/vision/factor/factor_pixel_hp.h @@ -99,15 +99,9 @@ inline FactorPixelHp::FactorPixelHp(const FeatureBasePtr& _ftr_ptr, inline Eigen::VectorXd FactorPixelHp::expectation() const { -<<<<<<< HEAD - FrameBasePtr frm = getFeature()->getCapture()->getFrame(); - SensorBasePtr sen = getFeature()->getCapture()->getSensor(); - LandmarkBasePtr lmk = getLandmarkOther(); -======= auto frm = getFeature()->getCapture()->getFrame(); auto sen = getFeature()->getCapture()->getSensor(); auto lmk = getLandmarkOther(); ->>>>>>> devel const Eigen::MatrixXd frame_pos = frm->getP()->getState(); const Eigen::MatrixXd frame_ori = frm->getO()->getState(); -- GitLab From 245ef65171b705c8920d70f7d33c82f9f33d2b19 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Tue, 3 May 2022 19:26:15 +0200 Subject: [PATCH 04/12] Remove useless include --- include/vision/processor/processor_visual_odometry.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/vision/processor/processor_visual_odometry.h b/include/vision/processor/processor_visual_odometry.h index 9cf5b016..ae8c9425 100644 --- a/include/vision/processor/processor_visual_odometry.h +++ b/include/vision/processor/processor_visual_odometry.h @@ -41,7 +41,6 @@ // Opencv includes #include #include -#include #include #include #include -- GitLab From 0b99e0b97b354a9604334bc469dfe2e669ae5111 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Wed, 4 May 2022 16:50:35 +0200 Subject: [PATCH 05/12] Adapt gtest CMakeLists.txt fix JoanV fix in core --- test/CMakeLists.txt | 28 +--------- test/gtest/CMakeLists.txt | 115 +++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 77 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ffd3390d..7e2209c5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,38 +1,12 @@ # Retrieve googletest from github & compile add_subdirectory(gtest) - -# Include gtest directory. -include_directories(${GTEST_INCLUDE_DIRS}) - wolf_add_gtest(gtest_pinhole gtest_pinhole.cpp) -target_link_libraries(gtest_pinhole ${PLUGIN_NAME}) wolf_add_gtest(gtest_capture_image gtest_capture_image.cpp) -target_link_libraries(gtest_capture_image ${PLUGIN_NAME}) wolf_add_gtest(gtest_feature_point_image gtest_feature_point_image.cpp) -target_link_libraries(gtest_feature_point_image ${PLUGIN_NAME}) - wolf_add_gtest(gtest_sensor_camera gtest_sensor_camera.cpp) -target_link_libraries(gtest_sensor_camera ${PLUGIN_NAME}) - -wolf_add_gtest(gtest_processor_visual_odometry gtest_processor_visual_odometry.cpp) -target_link_libraries(gtest_processor_visual_odometry ${PLUGIN_NAME}) - -# # FactorTrifocal test -# wolf_add_gtest(gtest_factor_trifocal gtest_factor_trifocal.cpp) -# target_link_libraries(gtest_factor_trifocal ${PLUGIN_NAME}) - -# # FactorFeatureEpipolar test -# wolf_add_gtest(gtest_factor_epipolar gtest_factor_epipolar.cpp) -# target_link_libraries(gtest_factor_epipolar ${PLUGIN_NAME}) - -# # ProcessorBundleAdjustment test -# wolf_add_gtest(gtest_processor_bundle_adjustment gtest_processor_bundle_adjustment.cpp) -# target_link_libraries(gtest_processor_bundle_adjustment ${PLUGIN_NAME}) -# # FactorPixelHp test -> depends on processor_bundle_adjustment.cpp -# wolf_add_gtest(gtest_factor_pixel_hp gtest_factor_pixel_hp.cpp) -# target_link_libraries(gtest_factor_pixel_hp ${PLUGIN_NAME}) +wolf_add_gtest(gtest_processor_visual_odometry gtest_processor_visual_odometry.cpp) \ No newline at end of file diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 559756b0..0fe7d7a0 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -1,65 +1,80 @@ -cmake_minimum_required(VERSION 2.8.8) -project(gtest_builder C CXX) +if(${CMAKE_VERSION} VERSION_LESS "3.11.0") + message("CMake version less than 3.11.0") -# We need thread support -#find_package(Threads REQUIRED) + # Enable ExternalProject CMake module + include(ExternalProject) -# Enable ExternalProject CMake module -include(ExternalProject) + set(GTEST_FORCE_SHARED_CRT ON) + set(GTEST_DISABLE_PTHREADS OFF) -set(GTEST_FORCE_SHARED_CRT ON) -set(GTEST_DISABLE_PTHREADS OFF) + # For some reason I need to disable PTHREADS + # with g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3 + # This is a known issue for MinGW : + # https://github.com/google/shaderc/pull/174 + #if(MINGW) + # set(GTEST_DISABLE_PTHREADS ON) + #endif() -# For some reason I need to disable PTHREADS -# with g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3 -# This is a known issue for MinGW : -# https://github.com/google/shaderc/pull/174 -#if(MINGW) - set(GTEST_DISABLE_PTHREADS ON) -#endif() + # Download GoogleTest + ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.8.x + # TIMEOUT 1 # We'll try this + CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs + -DCMAKE_CXX_FLAGS=${MSVC_COMPILER_DEFS} + -Dgtest_force_shared_crt=${GTEST_FORCE_SHARED_CRT} + -Dgtest_disable_pthreads=${GTEST_DISABLE_PTHREADS} + -DBUILD_GTEST=ON + PREFIX "${CMAKE_CURRENT_BINARY_DIR}" + # Disable install step + INSTALL_COMMAND "" + UPDATE_DISCONNECTED 1 # 1: do not update googletest; 0: update googletest via github + ) -# Download GoogleTest -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.8.x - # TIMEOUT 1 # We'll try this - CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs - -DCMAKE_CXX_FLAGS=${MSVC_COMPILER_DEFS} - -Dgtest_force_shared_crt=${GTEST_FORCE_SHARED_CRT} - -Dgtest_disable_pthreads=${GTEST_DISABLE_PTHREADS} - -DBUILD_GTEST=ON - PREFIX "${CMAKE_CURRENT_BINARY_DIR}" - # Disable install step - INSTALL_COMMAND "" - UPDATE_DISCONNECTED 1 # 1: do not update googletest; 0: update googletest via github -) + # Get GTest source and binary directories from CMake project -# Get GTest source and binary directories from CMake project + # Specify include dir + ExternalProject_Get_Property(googletest source_dir) + set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include PARENT_SCOPE) -# Specify include dir -ExternalProject_Get_Property(googletest source_dir) -set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include PARENT_SCOPE) + # Specify MainTest's link libraries + ExternalProject_Get_Property(googletest binary_dir) + set(GTEST_LIBS_DIR ${binary_dir}/googlemock/gtest PARENT_SCOPE) -# Specify MainTest's link libraries -ExternalProject_Get_Property(googletest binary_dir) -set(GTEST_LIBS_DIR ${binary_dir}/googlemock/gtest PARENT_SCOPE) + # Create a libgtest target to be used as a dependency by test programs + add_library(libgtest IMPORTED STATIC GLOBAL) + add_dependencies(libgtest googletest) -# Create a libgtest target to be used as a dependency by test programs -add_library(libgtest IMPORTED STATIC GLOBAL) -add_dependencies(libgtest googletest) + # Set libgtest properties + set_target_properties(libgtest PROPERTIES + "IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a" + "IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}" + ) -# Set libgtest properties -set_target_properties(libgtest PROPERTIES - "IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a" - "IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}" -) +else() + message("CMake version equal or greater than 3.11.0") + + include(FetchContent) + + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG main) + + FetchContent_MakeAvailable(googletest) + +endif() + function(wolf_add_gtest target) add_executable(${target} ${ARGN}) - add_dependencies(${target} libgtest) - target_link_libraries(${target} libgtest) - - #WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin + if(${CMAKE_VERSION} VERSION_LESS "3.11.0") + add_dependencies(${target} libgtest) + target_link_libraries(${target} libgtest ${PLUGIN_NAME}) + target_include_directories(${target} PUBLIC ${GTEST_INCLUDE_DIRS}) + else() + target_link_libraries(${target} PUBLIC gtest_main ${PLUGIN_NAME}) + endif() add_test(NAME ${target} COMMAND ${target}) endfunction() -- GitLab From f8def9d0e7a4e4c7d6e7bd8a7e8c49557b5974ca Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Wed, 4 May 2022 17:36:20 +0200 Subject: [PATCH 06/12] Fix: forgot to tinstall the wolfvisionTargets.cmake file --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00500347..b0002389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,9 +218,12 @@ ENDIF(BUILD_TESTS) #install library #============================================================= INSTALL(TARGETS ${PLUGIN_NAME} EXPORT ${PLUGIN_NAME}Targets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} +) +install(EXPORT ${PLUGIN_NAME}Targets DESTINATION lib/${PLUGIN_NAME}/cmake) + # Configure the package installation include(CMakePackageConfigHelpers) -- GitLab From 84a1c1207a6bc4c2313a581032570a6cd2c38e68 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Wed, 4 May 2022 18:03:39 +0200 Subject: [PATCH 07/12] Remove useless cmake_policy command --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0002389..a0cf6993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,6 @@ # Pre-requisites about cmake itself CMAKE_MINIMUM_REQUIRED(VERSION 3.10) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0005 NEW) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) # MAC OSX RPATH SET(CMAKE_MACOSX_RPATH true) -- GitLab From cdee0d6007490f51a022777400b293f787da5610 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Fri, 6 May 2022 14:12:37 +0200 Subject: [PATCH 08/12] Fix config file creation after having broken it --- CMakeLists.txt | 7 ++----- internal/config.h.in | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0cf6993..e72e49be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,10 +66,6 @@ if(BUILD_TESTS) enable_testing() endif() -#CMAKE modules -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules") -MESSAGE(STATUS ${CMAKE_MODULE_PATH}) - # Some wolf compilation options IF((CMAKE_BUILD_TYPE MATCHES DEBUG) OR (CMAKE_BUILD_TYPE MATCHES debug) OR (CMAKE_BUILD_TYPE MATCHES Debug)) set(_WOLF_DEBUG true) @@ -85,8 +81,9 @@ FIND_PACKAGE(OpenCV REQUIRED # ============ config.h ================== -string(TOUPPER ${PROJECT_NAME} UPPER_NAME) set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR}) +# variable used to compile the config.h.in file +string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) # Define the directory where will be the configured config.h SET(WOLF_CONFIG_DIR ${PROJECT_BINARY_DIR}/conf/${PROJECT_NAME}/internal) diff --git a/internal/config.h.in b/internal/config.h.in index 7014ca32..35f34683 100644 --- a/internal/config.h.in +++ b/internal/config.h.in @@ -24,13 +24,13 @@ // which will be added to the include path for compilation, // and installed with the public wolf headers. -#ifndef WOLF_INTERNAL_${UPPER_NAME}_CONFIG_H_ -#define WOLF_INTERNAL_${UPPER_NAME}_CONFIG_H_ +#ifndef WOLF_INTERNAL_${PROJECT_NAME_UPPER}_CONFIG_H_ +#define WOLF_INTERNAL_${PROJECT_NAME_UPPER}_CONFIG_H_ #cmakedefine _WOLF_DEBUG #cmakedefine _WOLF_TRACE -#define _WOLF_${UPPER_NAME}_ROOT_DIR "${_WOLF_ROOT_DIR}" +#define _WOLF_${PROJECT_NAME_UPPER}_ROOT_DIR "${_WOLF_ROOT_DIR}" #endif /* WOLF_INTERNAL_CONFIG_H_ */ -- GitLab From 6278c83c7be1736cfaa5e428283d8ee2abeb1eda Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Thu, 12 May 2022 15:52:50 +0200 Subject: [PATCH 09/12] [skip-ci] Specify MODULE or CONFIG in find_package --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 570ffaf8..f89a00ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,8 @@ ENDIF() option(_WOLF_TRACE "Enable wolf tracing macro" ON) # ============ DEPENDENCIES ================== -FIND_PACKAGE(wolfcore REQUIRED) -FIND_PACKAGE(OpenCV REQUIRED +FIND_PACKAGE(wolfcore REQUIRED CONFIG) +FIND_PACKAGE(OpenCV REQUIRED CONFIG COMPONENTS core imgcodecs highgui features2d calib3d video ) IF(OpenCV_FOUND) @@ -269,7 +269,7 @@ INSTALL(DIRECTORY ${SPDLOG_INCLUDE_DIRS} DESTINATION "include/iri-algorithms/") export(PACKAGE ${PLUGIN_NAME}) -FIND_PACKAGE(Doxygen) +FIND_PACKAGE(Doxygen MODULE) FIND_PATH(IRI_DOC_DIR doxygen.conf ${CMAKE_SOURCE_DIR}/doc/iri_doc/) IF (IRI_DOC_DIR) -- GitLab From 8eb91c6b5d4a432ce66550ca59fbf3ef76ce315a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= Date: Mon, 16 May 2022 13:31:41 +0200 Subject: [PATCH 10/12] [skip ci] print variables --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 950e7bf0..7e0b7129 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ stages: ############ YAML ANCHORS ############ .print_variables_template: &print_variables_definition # Print variables + - echo $WOLF_CORE_BRANCH - echo $CI_COMMIT_BRANCH - echo $WOLF_VISION_BRANCH -- GitLab From 071f18087d759c0f55d31d7ad3ae179c16e6e4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= Date: Tue, 17 May 2022 14:17:50 +0200 Subject: [PATCH 11/12] disabling gtest pthreads in cmake<3.11 --- test/CMakeLists.txt | 7 +++++++ test/gtest/CMakeLists.txt | 18 ++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7e2209c5..7beb4a96 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,13 @@ # Retrieve googletest from github & compile add_subdirectory(gtest) +############# USE THIS TEST AS AN EXAMPLE ################# +# # +# Create a specific test executable for gtest_example # +# wolf_add_gtest(gtest_example gtest_example.cpp) # +# # +########################################################### + wolf_add_gtest(gtest_pinhole gtest_pinhole.cpp) wolf_add_gtest(gtest_capture_image gtest_capture_image.cpp) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 0fe7d7a0..d7b68ba0 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -5,15 +5,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.11.0") include(ExternalProject) set(GTEST_FORCE_SHARED_CRT ON) - set(GTEST_DISABLE_PTHREADS OFF) - - # For some reason I need to disable PTHREADS - # with g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3 - # This is a known issue for MinGW : - # https://github.com/google/shaderc/pull/174 - #if(MINGW) - # set(GTEST_DISABLE_PTHREADS ON) - #endif() + set(GTEST_DISABLE_PTHREADS ON) # without this in ubuntu 18.04 we get linking errors # Download GoogleTest ExternalProject_Add(googletest @@ -63,7 +55,13 @@ else() GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG main) - FetchContent_MakeAvailable(googletest) + #FetchContent_MakeAvailable(googletest) + # Disable installation of googletest: https://stackoverflow.com/questions/65527126/disable-install-for-fetchcontent + FetchContent_GetProperties(googletest) + if(NOT googletest_POPULATED) + FetchContent_Populate(googletest) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() endif() -- GitLab From 3a5f9101038f1aa6b17ac2641860abd0cadde143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= Date: Tue, 17 May 2022 15:51:37 +0200 Subject: [PATCH 12/12] simpler way of disabling gtest installation --- test/gtest/CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index d7b68ba0..2cae2569 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -55,13 +55,8 @@ else() GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG main) - #FetchContent_MakeAvailable(googletest) - # Disable installation of googletest: https://stackoverflow.com/questions/65527126/disable-install-for-fetchcontent - FetchContent_GetProperties(googletest) - if(NOT googletest_POPULATED) - FetchContent_Populate(googletest) - add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() + SET(INSTALL_GTEST OFF) # Disable installation of googletest + FetchContent_MakeAvailable(googletest) endif() -- GitLab