Skip to content
Snippets Groups Projects
Commit 3d7e32af authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Make CMake config file fetch its own dependencies + CMakeLists.txt cleanup

parent 39528813
No related branches found
No related tags found
No related merge requests found
Pipeline #3641 passed
......@@ -97,16 +97,16 @@ ENDIF()
option(_WOLF_TRACE "Enable wolf tracing macro" ON)
# option(BUILD_EXAMPLES "Build examples" OFF)
# option(BUILD_DEMOS "Build examples" OFF)
set(BUILD_TESTS true)
set(BUILD_EXAMPLES false)
set(BUILD_DEMOS false)
# Does this has any other interest
# but for the examples ?
# yes, for the tests !
IF(BUILD_EXAMPLES OR BUILD_TESTS)
IF(BUILD_DEMOS OR BUILD_TESTS)
set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR})
ENDIF(BUILD_EXAMPLES OR BUILD_TESTS)
ENDIF(BUILD_DEMOS OR BUILD_TESTS)
#find dependencies.
......@@ -115,57 +115,10 @@ FIND_PACKAGE(Eigen3 3.2.92 REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Ceres QUIET) #Ceres is not required
IF(Ceres_FOUND)
MESSAGE("Ceres Library FOUND: Ceres related sources will be built.")
ENDIF(Ceres_FOUND)
FIND_PACKAGE(faramotics QUIET) #faramotics is not required
IF(faramotics_FOUND)
FIND_PACKAGE(GLUT REQUIRED)
FIND_PACKAGE(pose_state_time REQUIRED)
MESSAGE("Faramotics Library FOUND: Faramotics related sources will be built.")
ENDIF(faramotics_FOUND)
# Cereal
FIND_PACKAGE(cereal QUIET)
IF(cereal_FOUND)
MESSAGE("cereal Library FOUND: cereal related sources will be built.")
ENDIF(cereal_FOUND)
FIND_PACKAGE(Ceres REQUIRED) #Ceres is not required
# YAML with yaml-cpp
FIND_PACKAGE(YamlCpp REQUIRED)
IF(YAMLCPP_FOUND)
MESSAGE("yaml-cpp Library FOUND: yaml-cpp related sources will be built.")
ELSEIF(YAMLCPP_FOUND)
MESSAGE("yaml-cpp Library NOT FOUND!")
ENDIF(YAMLCPP_FOUND)
#GLOG
INCLUDE (${PROJECT_SOURCE_DIR}/cmake_modules/FindGlog.cmake)
IF(GLOG_FOUND)
MESSAGE("glog Library FOUND: glog related sources will be built.")
MESSAGE(STATUS ${GLOG_INCLUDE_DIR})
MESSAGE(STATUS ${GLOG_LIBRARY})
ELSEIF(GLOG_FOUND)
MESSAGE("glog Library NOT FOUND!")
ENDIF(GLOG_FOUND)
# SuiteSparse doesn't have find*.cmake:
FIND_PATH(
Suitesparse_INCLUDE_DIRS
NAMES SuiteSparse_config.h
PATHS /usr/include/suitesparse /usr/local/include/suitesparse)
MESSAGE("Found suitesparse_INCLUDE_DIRS:" ${Suitesparse_INCLUDE_DIRS})
IF(Suitesparse_INCLUDE_DIRS)
SET(Suitesparse_FOUND TRUE)
MESSAGE("Suitesparse FOUND: wolf_solver will be built.")
ELSE (Suitesparse_INCLUDE_DIRS)
SET(Suitesparse_FOUND FALSE)
MESSAGE(FATAL_ERROR "Suitesparse NOT FOUND")
ENDIF (Suitesparse_INCLUDE_DIRS)
# Define the directory where will be the configured config.h
SET(WOLF_CONFIG_DIR ${PROJECT_BINARY_DIR}/conf/core/internal)
......@@ -184,10 +137,11 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/internal/config.h.in "${WOLF_CONFIG_D
message("WOLF CONFIG ${WOLF_CONFIG_DIR}/config.h")
message("CONFIG DIRECTORY ${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_BINARY_DIR}/conf")
# include spdlog (logging library)
FIND_PATH(SPDLOG_INCLUDE_DIR spdlog.h /usr/local/include/spdlog /usr/include/spdlog)
IF (SPDLOG_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${SPDLOG_INCLUDE_DIR})
# INCLUDE_DIRECTORIES(${SPDLOG_INCLUDE_DIR})
MESSAGE(STATUS "Found spdlog: ${SPDLOG_INCLUDE_DIR}")
ELSE (SPDLOG_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Could not find spdlog")
......@@ -196,32 +150,10 @@ ENDIF (SPDLOG_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${EIGEN_INCLUDE_DIRS})
INCLUDE_DIRECTORIES("include")
INCLUDE_DIRECTORIES(${YAMLCPP_INCLUDE_DIR})
IF(Ceres_FOUND)
INCLUDE_DIRECTORIES(${CERES_INCLUDE_DIRS})
ENDIF(Ceres_FOUND)
IF(faramotics_FOUND)
INCLUDE_DIRECTORIES(${faramotics_INCLUDE_DIRS})
ENDIF(faramotics_FOUND)
# cereal
IF(cereal_FOUND)
INCLUDE_DIRECTORIES(${cereal_INCLUDE_DIRS})
ENDIF(cereal_FOUND)
IF(Suitesparse_FOUND)
INCLUDE_DIRECTORIES(${Suitesparse_INCLUDE_DIRS})
ENDIF(Suitesparse_FOUND)
IF(GLOG_FOUND)
INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIR})
ENDIF(GLOG_FOUND)
INCLUDE_DIRECTORIES(${CERES_INCLUDE_DIRS})
#HEADERS
SET(HDRS_COMMON
include/core/common/factory.h
include/core/common/node_base.h
......@@ -513,23 +445,21 @@ IF (Ceres_FOUND)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CERES_LIBRARIES})
ENDIF(Ceres_FOUND)
IF (GLOG_FOUND)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${GLOG_LIBRARY})
ENDIF (GLOG_FOUND)
# IF (GLOG_FOUND)
# TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${GLOG_LIBRARY})
# ENDIF (GLOG_FOUND)
#check if this is done correctly
IF (GLOG_FOUND)
IF(BUILD_TESTS)
MESSAGE("Building tests.")
add_subdirectory(test)
ENDIF(BUILD_TESTS)
ENDIF (GLOG_FOUND)
IF(BUILD_TESTS)
MESSAGE("Building tests.")
add_subdirectory(test)
ENDIF(BUILD_TESTS)
IF(BUILD_EXAMPLES)
#Build examples
IF(BUILD_DEMOS)
#Build demos
MESSAGE("Building demos.")
ADD_SUBDIRECTORY(demos)
ENDIF(BUILD_EXAMPLES)
ENDIF(BUILD_DEMOS)
#install library
......
......@@ -60,8 +60,8 @@ find_package(wolfvision REQUIRED)
```
if the plugin has been correctly installed, and thus find_package succeeds, then it will define two variables
- ${wolfvision_INCLUDE_DIR} which is the path to the includes. It should have the value `/usr/local/include/iri-algorithms/wolf/plugin_vision`
- ${wolfvision_LIBRARY} which is the path to the compiled (& linked) library. It should have the value `/usr/local/lib/iri-algorithms/libwolfvision.so`
- ${wolfvision_INCLUDE_DIRS} which is the path to the includes. It should have the value `/usr/local/include/iri-algorithms/wolf/plugin_vision`
- ${wolfvision_LIBRARIES} which is the path to the compiled (& linked) library. It should have the value `/usr/local/lib/iri-algorithms/libwolfvision.so`
**IMPORTANT NOTE** For the time being, each plugin is only responsible for finding their own includes and library. This means that for instance wolfvision, which obviously requires
the _core_ plugin, will not find its own dependencies. It is the responsibility of the programmer to do `find_package(wolf REQUIRED)` to get the includes and library. In the future this will change and each plugin will be responsible for finding all the necessary dependencies.
......
......@@ -62,4 +62,21 @@ if(NOT wolf_FOUND)
wolf_report_not_found("Something went wrong while setting up wolf.")
endif(NOT wolf_FOUND)
# Set the include directories for wolf (itself).
set(wolf_FOUND TRUE)
\ No newline at end of file
set(wolf_FOUND TRUE)
# Now we gather all the required dependencies for Wolf
FIND_PACKAGE(Eigen3 3.2.92 REQUIRED)
list(APPEND wolf_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
FIND_PACKAGE(Threads REQUIRED)
list(APPEND wolf_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
FIND_PACKAGE(Ceres REQUIRED)
list(APPEND wolf_INCLUDE_DIRS ${CERES_INCLUDE_DIRS})
list(APPEND wolf_LIBRARIES ${CERES_LIBRARIES})
# YAML with yaml-cpp
FIND_PACKAGE(YamlCpp REQUIRED)
list(APPEND wolf_INCLUDE_DIRS ${YAMLCPP_INCLUDE_DIRS})
list(APPEND wolf_LIBRARIES ${YAMLCPP_LIBRARY})
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