diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5779edb4ee6179e92670735fc81c05edfbeee02d..ef29f921fb416b8178f4452a1082ebad5b7b5383 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_IMU_BRANCH diff --git a/CMakeLists.txt b/CMakeLists.txt index ea892d9b6b3b197e573e295313227fcb62286c09..5dc35a87041678cea8d4c047a345d7029f69b3ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,6 @@ # 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) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) # MAC OSX RPATH SET(CMAKE_MACOSX_RPATH 1) @@ -14,9 +10,11 @@ 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(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") @@ -24,7 +22,7 @@ ENDIF (NOT CMAKE_BUILD_TYPE) message(STATUS "Configured to compile in ${CMAKE_BUILD_TYPE} mode.") #Set Flags -SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -O0 -D_REENTRANT") +SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -D_REENTRANT") SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT") #Set compiler according C++14 support @@ -67,10 +65,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) @@ -79,11 +73,13 @@ ENDIF() option(_WOLF_TRACE "Enable wolf tracing macro" ON) # ============ DEPENDENCIES ============ -FIND_PACKAGE(wolfcore REQUIRED) +FIND_PACKAGE(wolfcore REQUIRED CONFIG) +FIND_PACKAGE(Eigen3 3.3 REQUIRED CONFIG) # ============ 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) @@ -103,7 +99,6 @@ message("CONFIG DIRECTORY ${PROJECT_BINARY_DIR}") include_directories("${PROJECT_BINARY_DIR}/conf") # ============ INCLUDES SECTION ============ -INCLUDE_DIRECTORIES(${wolfcore_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(BEFORE "include") # ============ HEADERS ============ @@ -185,7 +180,8 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() #Link the created libraries -TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${wolfcore_LIBRARIES}) +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC wolfcore) +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC Eigen3::Eigen) #===============Build tests========================= IF(BUILD_TESTS) @@ -194,39 +190,58 @@ IF(BUILD_TESTS) 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) +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_INTERFACE:${INCLUDE_INSTALL_DIR}> +) -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_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 imu.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/") 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) diff --git a/cmake_modules/wolfimuConfig.cmake b/cmake_modules/wolfimuConfig.cmake deleted file mode 100644 index 9234912c0a54ff3e5aff5e1a44a27915cda83558..0000000000000000000000000000000000000000 --- a/cmake_modules/wolfimuConfig.cmake +++ /dev/null @@ -1,84 +0,0 @@ -#edit the following line to add the librarie's header files -FIND_PATH( - wolfimu_INCLUDE_DIRS - NAMES imu.found - PATHS /usr/local/include/iri-algorithms/wolf/plugin_imu) -IF(wolfimu_INCLUDE_DIRS) - MESSAGE("Found wolf imu include dirs: ${wolfimu_INCLUDE_DIRS}") -ELSE(wolfimu_INCLUDE_DIRS) - MESSAGE("Couldn't find wolf imu include dirs") -ENDIF(wolfimu_INCLUDE_DIRS) - -FIND_LIBRARY( - wolfimu_LIBRARIES - NAMES libwolfimu.so libwolfimu.dylib - PATHS /usr/local/lib) -IF(wolfimu_LIBRARIES) - MESSAGE("Found wolf imu lib: ${wolfimu_LIBRARIES}") -ELSE(wolfimu_LIBRARIES) - MESSAGE("Couldn't find wolf imu lib") -ENDIF(wolfimu_LIBRARIES) - -IF (wolfimu_INCLUDE_DIRS AND wolfimu_LIBRARIES) - SET(wolfimu_FOUND TRUE) - ELSE(wolfimu_INCLUDE_DIRS AND wolfimu_LIBRARIES) - set(wolfimu_FOUND FALSE) -ENDIF (wolfimu_INCLUDE_DIRS AND wolfimu_LIBRARIES) - -IF (wolfimu_FOUND) - IF (NOT wolfimu_FIND_QUIETLY) - MESSAGE(STATUS "Found wolf imu: ${wolfimu_LIBRARIES}") - ENDIF (NOT wolfimu_FIND_QUIETLY) -ELSE (wolfimu_FOUND) - IF (wolfimu_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find wolf imu") - ENDIF (wolfimu_FIND_REQUIRED) -ENDIF (wolfimu_FOUND) - - -macro(wolf_report_not_found REASON_MSG) - set(wolfimu_FOUND FALSE) - unset(wolfimu_INCLUDE_DIRS) - unset(wolfimu_LIBRARIES) - - # Reset the CMake module path to its state when this script was called. - set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) - - # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by - # FindPackage() use the camelcase library name, not uppercase. - if (wolfimu_FIND_QUIETLY) - message(STATUS "Failed to find wolf imu- " ${REASON_MSG} ${ARGN}) - elseif(wolfimu_FIND_REQUIRED) - message(FATAL_ERROR "Failed to find wolf imu - " ${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 wolf imu - " ${REASON_MSG} ${ARGN}) - endif () - return() -endmacro(wolf_report_not_found) - -if(NOT wolfimu_FOUND) - wolf_report_not_found("Something went wrong while setting up wolf imu.") -endif(NOT wolfimu_FOUND) -# Set the include directories for wolf (itself). -set(wolfimu_FOUND TRUE) - -# Now we gather all the required dependencies for Wolf imu -if(NOT wolf_FOUND) - FIND_PACKAGE(wolfcore REQUIRED) - - #We reverse in order to insert at the start - list(REVERSE wolfimu_INCLUDE_DIRS) - list(APPEND wolfimu_INCLUDE_DIRS ${wolfcore_INCLUDE_DIRS}) - list(REVERSE wolfimu_INCLUDE_DIRS) - - list(REVERSE wolfimu_LIBRARIES) - list(APPEND wolfimu_LIBRARIES ${wolfcore_LIBRARIES}) - list(REVERSE wolfimu_LIBRARIES) -endif() - -# provide both INCLUDE_DIR and INCLUDE_DIRS -SET(wolfimu_INCLUDE_DIR ${wolfimu_INCLUDE_DIRS}) -# provide both LIBRARY and LIBRARIES -SET(wolfimu_LIBRARY ${wolfimu_LIBRARIES}) diff --git a/cmake_modules/wolfimuConfig.cmake.in b/cmake_modules/wolfimuConfig.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..86f0997f2390ebd3ff9d34a73a6a118953c4881e --- /dev/null +++ b/cmake_modules/wolfimuConfig.cmake.in @@ -0,0 +1,12 @@ +set(@PLUGIN_NAME@_VERSION 0.0.1) + + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +FIND_DEPENDENCY(wolfcore REQUIRED) +FIND_DEPENDENCY(Eigen3 3.3 REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/@PLUGIN_NAME@Targets.cmake") + +check_required_components(@PLUGIN_NAME@) \ No newline at end of file diff --git a/include/imu/capture/capture_compass.h b/include/imu/capture/capture_compass.h index dc1fef50b1e6cc25acf4154634da98af698f6e65..a9c164c5804e7d0c09041ef3507cf9f27f9d03d4 100644 --- a/include/imu/capture/capture_compass.h +++ b/include/imu/capture/capture_compass.h @@ -23,7 +23,7 @@ #define CAPTURE_COMPASS_H_ //Wolf includes -#include "core/capture/capture_base.h" +#include <core/capture/capture_base.h> #include "imu/sensor/sensor_compass.h" //std includes diff --git a/include/imu/capture/capture_imu.h b/include/imu/capture/capture_imu.h index 4b4e05a1caf32f4627a7bc78d8fffdc413a1acf8..3a93dec415add904e8715af22911412d8523ef87 100644 --- a/include/imu/capture/capture_imu.h +++ b/include/imu/capture/capture_imu.h @@ -24,7 +24,7 @@ //Wolf includes #include "imu/math/imu_tools.h" -#include "core/capture/capture_motion.h" +#include <core/capture/capture_motion.h> namespace wolf { diff --git a/include/imu/factor/factor_compass_3d.h b/include/imu/factor/factor_compass_3d.h index 3772950880281c9b6e6261192d9ac3edb0f563cd..c58af6e1ae13b5744d24612a900a8986a95d0bf1 100644 --- a/include/imu/factor/factor_compass_3d.h +++ b/include/imu/factor/factor_compass_3d.h @@ -22,7 +22,7 @@ #ifndef FACTOR_COMPASS_3D_H_ #define FACTOR_COMPASS_3D_H_ -#include "core/factor/factor_autodiff.h" +#include <core/factor/factor_autodiff.h> namespace wolf { diff --git a/include/imu/factor/factor_fix_bias.h b/include/imu/factor/factor_fix_bias.h index 2de0cf321f0cf93aefb50808c44afe3301f67fb1..dc6faf4c96fd2b1fa2c99f1cfa751b92f42f9e0a 100644 --- a/include/imu/factor/factor_fix_bias.h +++ b/include/imu/factor/factor_fix_bias.h @@ -26,9 +26,9 @@ //Wolf includes #include "imu/capture/capture_imu.h" #include "imu/feature/feature_imu.h" -#include "core/factor/factor_autodiff.h" -#include "core/frame/frame_base.h" -#include "core/math/rotations.h" +#include <core/factor/factor_autodiff.h> +#include <core/frame/frame_base.h> +#include <core/math/rotations.h> //#include "ceres/jet.h" diff --git a/include/imu/factor/factor_imu.h b/include/imu/factor/factor_imu.h index 8674d4db5792df5d90454fe65531342254a77187..9e752656f10de383513a406538da1f399c2ec1a7 100644 --- a/include/imu/factor/factor_imu.h +++ b/include/imu/factor/factor_imu.h @@ -26,8 +26,8 @@ #include "imu/feature/feature_imu.h" #include "imu/sensor/sensor_imu.h" #include "imu/processor/processor_imu.h" -#include "core/factor/factor_autodiff.h" -#include "core/math/rotations.h" +#include <core/factor/factor_autodiff.h> +#include <core/math/rotations.h> //Eigen include diff --git a/include/imu/factor/factor_imu2d.h b/include/imu/factor/factor_imu2d.h index 5158c590fb2a6ecaf570cf6e0830fbc697437ded..11b87fee551371907a9ac38883d7c0f2c15fb5a2 100644 --- a/include/imu/factor/factor_imu2d.h +++ b/include/imu/factor/factor_imu2d.h @@ -26,9 +26,9 @@ #include "imu/feature/feature_imu2d.h" #include "imu/processor/processor_imu2d.h" #include "imu/sensor/sensor_imu2d.h" -#include "core/factor/factor_autodiff.h" -#include "core/math/rotations.h" #include "imu/math/imu2d_tools.h" +#include <core/factor/factor_autodiff.h> +#include <core/math/rotations.h> //Eigen include diff --git a/include/imu/factor/factor_imu2d_with_gravity.h b/include/imu/factor/factor_imu2d_with_gravity.h index 6356a659e06a4a347607cff564cc8e03d581210b..681eb46c285d45c0e8e33674e37b850ca21890fb 100644 --- a/include/imu/factor/factor_imu2d_with_gravity.h +++ b/include/imu/factor/factor_imu2d_with_gravity.h @@ -26,11 +26,10 @@ #include "imu/feature/feature_imu2d.h" #include "imu/processor/processor_imu2d.h" #include "imu/sensor/sensor_imu2d.h" -#include "core/factor/factor_autodiff.h" -#include "core/math/rotations.h" #include "imu/math/imu2d_tools.h" +#include <core/factor/factor_autodiff.h> +#include <core/math/rotations.h> -//Eigen include namespace wolf { diff --git a/include/imu/feature/feature_imu.h b/include/imu/feature/feature_imu.h index 6aa5f45116edbe33ac4459868cf34b9819af4e3c..4efe5e4ed8e8f82f44c26cbe3c44202bc05ea8f2 100644 --- a/include/imu/feature/feature_imu.h +++ b/include/imu/feature/feature_imu.h @@ -24,8 +24,8 @@ //Wolf includes #include "imu/capture/capture_imu.h" -#include "core/feature/feature_base.h" -#include "core/common/wolf.h" +#include <core/feature/feature_base.h> +#include <core/common/wolf.h> //std includes diff --git a/include/imu/feature/feature_imu2d.h b/include/imu/feature/feature_imu2d.h index 58f64b31afcd6610783359458a1261394d2726fa..0472550d4a60aaec2c398dfc213fe392f42c26c4 100644 --- a/include/imu/feature/feature_imu2d.h +++ b/include/imu/feature/feature_imu2d.h @@ -24,8 +24,8 @@ //Wolf includes #include "imu/capture/capture_imu.h" -#include "core/feature/feature_base.h" -#include "core/common/wolf.h" +#include <core/feature/feature_base.h> +#include <core/common/wolf.h> //std includes diff --git a/include/imu/math/imu2d_tools.h b/include/imu/math/imu2d_tools.h index 4f2a1ef535d9a538c03228a81d6940e67c7439a2..f579ae2dc44fc2f7cd5a6d1b70ba49df21dfdcb7 100644 --- a/include/imu/math/imu2d_tools.h +++ b/include/imu/math/imu2d_tools.h @@ -29,10 +29,10 @@ #ifndef IMU2D_TOOLS_H_ #define IMU2D_TOOLS_H_ -#include "core/common/wolf.h" -#include "core/math/rotations.h" -#include "core/math/SE2.h" -#include "core/state_block/state_composite.h" +#include <core/common/wolf.h> +#include <core/math/rotations.h> +#include <core/math/SE2.h> +#include <core/state_block/state_composite.h> #include <cstdio> diff --git a/include/imu/math/imu_tools.h b/include/imu/math/imu_tools.h index e696966cde5f21034b3e04d464c9c3305f5e4ec7..7101c04eb11afd5285fd2f77dd2f9c281780c5fc 100644 --- a/include/imu/math/imu_tools.h +++ b/include/imu/math/imu_tools.h @@ -29,9 +29,9 @@ #ifndef IMU_TOOLS_H_ #define IMU_TOOLS_H_ -#include "core/common/wolf.h" -#include "core/math/rotations.h" -#include "core/state_block/state_composite.h" +#include <core/common/wolf.h> +#include <core/math/rotations.h> +#include <core/state_block/state_composite.h> #include <cstdio> diff --git a/include/imu/processor/processor_compass.h b/include/imu/processor/processor_compass.h index 71f572e6317be94c99a22d1431ef73be8d7a08cd..ca1cd6e725b63848706fb2f9a25c342fed2277ce 100644 --- a/include/imu/processor/processor_compass.h +++ b/include/imu/processor/processor_compass.h @@ -22,7 +22,7 @@ #ifndef INCLUDE_IMU_PROCESSOR_PROCESSORCOMPASS_H_ #define INCLUDE_IMU_PROCESSOR_PROCESSORCOMPASS_H_ -#include "core/processor/processor_base.h" +#include <core/processor/processor_base.h> namespace wolf { diff --git a/include/imu/processor/processor_imu.h b/include/imu/processor/processor_imu.h index 12ebd1bb39f87ad420005b99b60ff7f11662095c..d8efc7cbd3221654da4721ff8bc21e6c15bc4353 100644 --- a/include/imu/processor/processor_imu.h +++ b/include/imu/processor/processor_imu.h @@ -25,7 +25,7 @@ // Wolf #include "imu/capture/capture_imu.h" #include "imu/feature/feature_imu.h" -#include "core/processor/processor_motion.h" +#include <core/processor/processor_motion.h> namespace wolf { WOLF_STRUCT_PTR_TYPEDEFS(ParamsProcessorImu); diff --git a/include/imu/processor/processor_imu2d.h b/include/imu/processor/processor_imu2d.h index 7ccf86a70690b9936a29be8e32b83ec26a56526c..726666f48ab2878d2f86712a4fc35b79e7f7e31a 100644 --- a/include/imu/processor/processor_imu2d.h +++ b/include/imu/processor/processor_imu2d.h @@ -25,7 +25,7 @@ // Wolf #include "imu/capture/capture_imu.h" #include "imu/feature/feature_imu.h" -#include "core/processor/processor_motion.h" +#include <core/processor/processor_motion.h> namespace wolf { WOLF_STRUCT_PTR_TYPEDEFS(ParamsProcessorImu2d); diff --git a/include/imu/sensor/sensor_compass.h b/include/imu/sensor/sensor_compass.h index a446b8acabf40ace81f7280d931d14eb8faedb32..c9f1d60551ce37ae7c9c5cd46283a832b19faa83 100644 --- a/include/imu/sensor/sensor_compass.h +++ b/include/imu/sensor/sensor_compass.h @@ -23,8 +23,9 @@ #define SENSOR_SENSOR_COMPASS_H_ //wolf includes -#include "core/sensor/sensor_base.h" -#include "core/utils/params_server.h" +#include <core/sensor/sensor_base.h> +#include <core/utils/params_server.h> + #include <iostream> namespace wolf { diff --git a/include/imu/sensor/sensor_imu.h b/include/imu/sensor/sensor_imu.h index dd21d8859880c52758152a445996298cdad08d48..0b9cf145a65d88704296ff7f0dcf54069356595c 100644 --- a/include/imu/sensor/sensor_imu.h +++ b/include/imu/sensor/sensor_imu.h @@ -23,8 +23,9 @@ #define SENSOR_IMU_H //wolf includes -#include "core/sensor/sensor_base.h" -#include "core/utils/params_server.h" +#include <core/sensor/sensor_base.h> +#include <core/utils/params_server.h> + #include <iostream> namespace wolf { diff --git a/include/imu/sensor/sensor_imu2d.h b/include/imu/sensor/sensor_imu2d.h index fb9bc31fab1b4e37322cbd6547dfe59700af5bb8..e1e5321e6d8af18278955fd7e86879a1425a0add 100644 --- a/include/imu/sensor/sensor_imu2d.h +++ b/include/imu/sensor/sensor_imu2d.h @@ -23,8 +23,9 @@ #define SENSOR_IMU2D_H //wolf includes -#include "core/sensor/sensor_base.h" -#include "core/utils/params_server.h" +#include <core/sensor/sensor_base.h> +#include <core/utils/params_server.h> + #include <iostream> namespace wolf { diff --git a/internal/config.h.in b/internal/config.h.in index 7014ca320e5c5fea1f59a6fe5d9d1ea0987bf95e..35f3468331656ba09a63ad7f26e5c0fb78c8d5bc 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_ */ diff --git a/src/processor/processor_imu.cpp b/src/processor/processor_imu.cpp index ec1db9e4391f0015ad2f6e084110063ba17f5203..5e429fd80355bddf587eaccafec7bf4db8476b02 100644 --- a/src/processor/processor_imu.cpp +++ b/src/processor/processor_imu.cpp @@ -244,7 +244,7 @@ Eigen::VectorXd ProcessorImu::correctDelta (const Eigen::VectorXd& delta_preint, } // namespace wolf -// Register in the FactorySensor +// Register in the FactoryProcessor #include "core/processor/factory_processor.h" namespace wolf diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bc10d2bf34366c9dbd624d62a8fffa92b1fb2598..3318eba7174a462947ffbf26f33497389dc75400 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,66 +2,45 @@ add_subdirectory(gtest) -# Include gtest directory. -include_directories(${GTEST_INCLUDE_DIRS}) - ############# USE THIS TEST AS AN EXAMPLE ################# # # # Create a specific test executable for gtest_example # wolf_add_gtest(gtest_example gtest_example.cpp) # -target_link_libraries(gtest_example ${PLUGIN_NAME}) # # # ########################################################### wolf_add_gtest(gtest_processor_imu gtest_processor_imu.cpp) -target_link_libraries(gtest_processor_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_imu2d gtest_processor_imu2d.cpp) -target_link_libraries(gtest_processor_imu2d ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_imu2d_with_gravity gtest_processor_imu2d_with_gravity.cpp) -target_link_libraries(gtest_processor_imu2d_with_gravity ${PLUGIN_NAME} ${wolf_LIBRARY}) wolf_add_gtest(gtest_imu gtest_imu.cpp) -target_link_libraries(gtest_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_imu_tools gtest_imu_tools.cpp) -target_link_libraries(gtest_imu_tools ${PLUGIN_NAME}) wolf_add_gtest(gtest_imu2d_tools gtest_imu2d_tools.cpp) -target_link_libraries(gtest_imu2d_tools ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_imu_jacobians gtest_processor_imu_jacobians.cpp) -target_link_libraries(gtest_processor_imu_jacobians ${PLUGIN_NAME}) wolf_add_gtest(gtest_feature_imu gtest_feature_imu.cpp) -target_link_libraries(gtest_feature_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_factor_imu2d gtest_factor_imu2d.cpp) -target_link_libraries(gtest_factor_imu2d ${PLUGIN_NAME}) wolf_add_gtest(gtest_imu_static_init gtest_imu_static_init.cpp) -target_link_libraries(gtest_imu_static_init ${PLUGIN_NAME}) wolf_add_gtest(gtest_imu2d_static_init gtest_imu2d_static_init.cpp) -target_link_libraries(gtest_imu2d_static_init ${PLUGIN_NAME}) wolf_add_gtest(gtest_factor_imu2d_with_gravity gtest_factor_imu2d_with_gravity.cpp) -target_link_libraries(gtest_factor_imu2d_with_gravity ${PLUGIN_NAME} ${wolf_LIBRARY}) wolf_add_gtest(gtest_imu_mocap_fusion gtest_imu_mocap_fusion.cpp) -target_link_libraries(gtest_imu_mocap_fusion ${PLUGIN_NAME}) wolf_add_gtest(gtest_factor_compass_3d gtest_factor_compass_3d.cpp) -target_link_libraries(gtest_factor_compass_3d ${PLUGIN_NAME}) # Has been excluded from tests for god knows how long, so thing is broken. # Maybe call an archeologist to fix this thing? # wolf_add_gtest(gtest_factor_imu gtest_factor_imu.cpp) -# target_link_libraries(gtest_factor_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_motion_intrinsics_update gtest_processor_motion_intrinsics_update.cpp) -target_link_libraries(gtest_processor_motion_intrinsics_update ${PLUGIN_NAME}) wolf_add_gtest(gtest_sensor_compass gtest_sensor_compass.cpp) -target_link_libraries(gtest_sensor_compass ${PLUGIN_NAME}) diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 559756b02472653c655c44152c452ba8767ef6f2..6209d341bcd32308bd522ab1990eb0cc82692012 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -1,65 +1,73 @@ -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 ON) # without this in ubuntu 18.04 we get linking errors -set(GTEST_FORCE_SHARED_CRT ON) -set(GTEST_DISABLE_PTHREADS OFF) + # 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 + ) -# 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() + # Get GTest source and binary directories from CMake project -# 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 -) + # Specify include dir + ExternalProject_Get_Property(googletest source_dir) + set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include PARENT_SCOPE) -# Get GTest source and binary directories from CMake project + # Specify MainTest's link libraries + ExternalProject_Get_Property(googletest binary_dir) + set(GTEST_LIBS_DIR ${binary_dir}/googlemock/gtest PARENT_SCOPE) -# Specify include dir -ExternalProject_Get_Property(googletest source_dir) -set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include 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) -# Specify MainTest's link libraries -ExternalProject_Get_Property(googletest binary_dir) -set(GTEST_LIBS_DIR ${binary_dir}/googlemock/gtest PARENT_SCOPE) + # Set libgtest properties + set_target_properties(libgtest PROPERTIES + "IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a" + "IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}" + ) -# Create a libgtest target to be used as a dependency by test programs -add_library(libgtest IMPORTED STATIC GLOBAL) -add_dependencies(libgtest googletest) +else() -# Set libgtest properties -set_target_properties(libgtest PROPERTIES - "IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a" - "IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}" -) + 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) + + SET(INSTALL_GTEST OFF) # Disable installation of googletest + 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} gtest_main ${PLUGIN_NAME}) + endif() add_test(NAME ${target} COMMAND ${target}) endfunction()