cmake_minimum_required (VERSION 3.15)

cmake_policy(SET CMP0077 NEW)

project (rbdlsim
	VERSION 0.0.1
	LANGUAGES CXX)

set(ENABLE_DOUBLE_PRECISION On)
set(RBDL_USE_SIMPLE_MATH On)

add_subdirectory (3rdparty/rbdl)
add_subdirectory (3rdparty/libccd)

# Library
add_library(${PROJECT_NAME})
target_include_directories(
		${PROJECT_NAME}
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/rbdl/include>
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/rbdl/include>)
target_link_libraries(${PROJECT_NAME} rbdl ccd)
target_sources(${PROJECT_NAME} PRIVATE src/rbdlsim.cc)

# Simulator Executable
add_executable(runsim)
target_include_directories(
		runsim
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/rbdl/include>
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/rbdl/include>)

target_link_libraries(runsim ${PROJECT_NAME})

target_sources(runsim PRIVATE src/main.cc)

# Tests
add_executable(runtests)

target_sources(runtests PRIVATE tests/runtests.cc tests/CollisionTests.cc)
target_include_directories(
		runtests
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/rbdl/include>
		PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/rbdl/include>)

target_link_libraries(runtests ${PROJECT_NAME})
