Skip to content
Snippets Groups Projects
Commit ebb8ba08 authored by Mederic Fourmy's avatar Mederic Fourmy
Browse files

objectslam compiles with the new CMakeList.txt refactoring

parent 2ac400b9
No related branches found
No related tags found
No related merge requests found
# Pre-requisites about cmake itself
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
......@@ -13,10 +13,10 @@ SET(CMAKE_MACOSX_RPATH 1)
PROJECT(objectslam)
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")
......@@ -69,8 +69,6 @@ if(BUILD_TESTS)
endif()
MESSAGE("Starting ${PROJECT_NAME} CMakeLists ...")
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#CMAKE modules
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
......@@ -118,7 +116,6 @@ include_directories("${PROJECT_BINARY_DIR}/conf")
#INCLUDES SECTION
# ============EXAMPLE==================
INCLUDE_DIRECTORIES(${wolfcore_INCLUDE_DIRS})
include_directories(BEFORE "include")
#HEADERS
......@@ -209,7 +206,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${wolfcore_LIBRARIES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} wolfcore)
#Build tests
......@@ -225,44 +222,62 @@ IF(BUILD_DEMOS)
ENDIF(BUILD_DEMOS)
#install library
#=============================================================
INSTALL(TARGETS ${PLUGIN_NAME} EXPORT ${PLUGIN_NAME}Targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/iri-algorithms
ARCHIVE DESTINATION lib/iri-algorithms)
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_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_COMMON}
DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/common)
DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/common)
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)
INSTALL(FILES ${HDRS_SOLVER}
DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/solver)
DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/solver)
INSTALL(FILES ${HDRS_UTILS}
DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/utils)
DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/utils)
INSTALL(FILES ${HDRS_YAML}
DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/yaml)
DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/yaml)
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)
DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/internal)
INSTALL(FILES "${CMAKE_SOURCE_DIR}/cmake_modules/${PLUGIN_NAME}Config.cmake" DESTINATION "lib/cmake/${PLUGIN_NAME}")
......
......@@ -5,4 +5,4 @@ For installation guide and code documentation, please visit the [documentation w
To compile this plugin without failure, you need to delete /demos
If you want to compile the demos, you need to install wolf_ros_objectslam and to source ros and its workspace.
\ No newline at end of file
If you want to compile the demos, you need to install wolf_ros_objectslam and to source ros and its workspace.
\ No newline at end of file
#edit the following line to add the librarie's header files
FIND_PATH(
wolfobjectslam_INCLUDE_DIRS
NAMES objectslam.found
PATHS /usr/local/include/iri-algorithms/wolf/plugin_objectslam)
IF(wolfobjectslam_INCLUDE_DIRS)
MESSAGE("Found wolf objectslam include dirs: ${wolfobjectslam_INCLUDE_DIRS}")
ELSE(wolfobjectslam_INCLUDE_DIRS)
MESSAGE("Couldn't find wolf objectslam include dirs")
ENDIF(wolfobjectslam_INCLUDE_DIRS)
FIND_LIBRARY(
wolfobjectslam_LIBRARIES
NAMES libwolfobjectslam.so libwolfobjectslam.dylib
PATHS /usr/local/lib/iri-algorithms)
IF(wolfobjectslam_LIBRARIES)
MESSAGE("Found wolf objectslam lib: ${wolfobjectslam_LIBRARIES}")
ELSE(wolfobjectslam_LIBRARIES)
MESSAGE("Couldn't find wolf objectslam lib")
ENDIF(wolfobjectslam_LIBRARIES)
IF (wolfobjectslam_INCLUDE_DIRS AND wolfobjectslam_LIBRARIES)
SET(wolfobjectslam_FOUND TRUE)
ELSE(wolfobjectslam_INCLUDE_DIRS AND wolfobjectslam_LIBRARIES)
set(wolfobjectslam_FOUND FALSE)
ENDIF (wolfobjectslam_INCLUDE_DIRS AND wolfobjectslam_LIBRARIES)
IF (wolfobjectslam_FOUND)
IF (NOT wolfobjectslam_FIND_QUIETLY)
MESSAGE(STATUS "Found wolf objectslam: ${wolfobjectslam_LIBRARIES}")
ENDIF (NOT wolfobjectslam_FIND_QUIETLY)
ELSE (wolfobjectslam_FOUND)
IF (wolfobjectslam_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find wolf objectslam")
ENDIF (wolfobjectslam_FIND_REQUIRED)
ENDIF (wolfobjectslam_FOUND)
macro(wolf_report_not_found REASON_MSG)
set(wolfobjectslam_FOUND FALSE)
unset(wolfobjectslam_INCLUDE_DIRS)
unset(wolfobjectslam_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 (wolfobjectslam_FIND_QUIETLY)
message(STATUS "Failed to find wolf objectslam- " ${REASON_MSG} ${ARGN})
else (wolfobjectslam_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find wolf objectslam - " ${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 objectslam - " ${REASON_MSG} ${ARGN})
endif ()
return()
endmacro(wolf_report_not_found)
if(NOT wolfobjectslam_FOUND)
wolf_report_not_found("Something went wrong while setting up wolf objectslam.")
endif(NOT wolfobjectslam_FOUND)
# Set the include directories for wolf (itself).
set(wolfobjectslam_FOUND TRUE)
# Now we gather all the required dependencies for Wolf Laser
#FIND_PACKAGE(wolfvision REQUIRED)
#list(APPEND wolfobjectslam_INCLUDE_DIRS ${wolfvision_INCLUDE_DIR})
#list(APPEND wolfobjectslam_LIBRARIES ${wolfvision_LIBRARY})
if(NOT OpenCV_FOUND)
FIND_PACKAGE(OpenCV REQUIRED)
list(APPEND wolfobjectslam_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS})
list(APPEND wolfobjectslam_LIBRARIES ${OpenCV_LIBS})
endif()
#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 wolfobjectslam_INCLUDE_DIRS)
list(APPEND wolfobjectslam_INCLUDE_DIRS ${wolfcore_INCLUDE_DIRS})
list(REVERSE wolfobjectslam_INCLUDE_DIRS)
list(REVERSE wolfobjectslam_LIBRARIES)
list(APPEND wolfobjectslam_LIBRARIES ${wolfcore_LIBRARIES})
list(REVERSE wolfobjectslam_LIBRARIES)
endif()
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)
include("${CMAKE_CURRENT_LIST_DIR}/@PLUGIN_NAME@Targets.cmake")
check_required_components(@PLUGIN_NAME@)
\ No newline at end of file
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
target_link_libraries(${target} gtest_main)
add_test(NAME ${target} COMMAND ${target})
endfunction()
endfunction()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment