cmake_minimum_required(VERSION 3.10)
project(costmap_2d)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (NOT TARGET sensor_msgs)
    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../sensor_msgs ${CMAKE_BINARY_DIR}/sensor_msgs_build)
endif()

if (NOT TARGET geometry_msgs)
    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../geometry_msgs ${CMAKE_BINARY_DIR}/geometry_msgs_build)
endif()

# ---- Dependencies ----
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread)

include_directories(
    include
    ${EIGEN3_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
    /usr/include
)

add_definitions(${EIGEN3_DEFINITIONS})

# ---- Core costmap_2d library ----
add_library(costmap_2d
    src/array_parser.cpp
    src/costmap_2d.cpp
    src/observation_buffer.cpp
    src/layer.cpp
    src/layered_costmap.cpp
    src/costmap_math.cpp
    src/footprint.cpp
    src/costmap_layer.cpp
)

target_link_libraries(costmap_2d
    ${Boost_LIBRARIES}
    sensor_msgs
    geometry_msgs
)

# # ---- Layer plugins ----
add_library(layers
    plugins/inflation_layer.cpp
#     plugins/obstacle_layer.cpp
#     plugins/static_layer.cpp
#     plugins/voxel_layer.cpp
)

target_link_libraries(layers
    costmap_2d
    ${Boost_LIBRARIES}
)

# ---- Example Executable ----
# add_executable(test_costmap main.cpp)
# target_link_libraries(test_costmap costmap_2d layers)
