CMAKE_MINIMUM_REQUIRED(VERSION 3.0)

SET ( RBDL_ADDON_GEOMETRY_VERSION_MAJOR 1 )
SET ( RBDL_ADDON_GEOMETRY_VERSION_MINOR 0 )
SET ( RBDL_ADDON_GEOMETRY_VERSION_PATCH 0 )

SET ( RBDL_ADDON_GEOMETRY_VERSION 
	${RBDL_ADDON_GEOMETRY_VERSION_MAJOR}.${RBDL_ADDON_GEOMETRY_VERSION_MINOR}.${RBDL_ADDON_GEOMETRY_VERSION_PATCH}
)

PROJECT (RBDL_ADDON_GEOMETRY VERSION ${RBDL_ADDON_GEOMETRY_VERSION})

LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )

SET_TARGET_PROPERTIES ( ${PROJECT_EXECUTABLES} PROPERTIES
		LINKER_LANGUAGE CXX
	)

INCLUDE_DIRECTORIES ( 
	${CMAKE_CURRENT_BINARY_DIR}/include/rbdl
)

SET(GEOMETRY_SOURCES 
	SegmentedQuinticBezierToolkit.cc
	SmoothSegmentedFunction.cc
  SegmentedQuinticBezierToolkit.h
	SmoothSegmentedFunction.h
	geometry.h
	Function.h	
)

SET(GEOMETRY_HEADERS
	geometry.h
	Function.h
	SegmentedQuinticBezierToolkit.h
  SmoothSegmentedFunction.h
)

IF (RBDL_BUILD_STATIC)
	ADD_LIBRARY ( rbdl_geometry-static STATIC ${GEOMETRY_SOURCES} )
	SET_TARGET_PROPERTIES ( rbdl_geometry-static PROPERTIES PREFIX "lib")
	SET_TARGET_PROPERTIES ( rbdl_geometry-static PROPERTIES OUTPUT_NAME "rbdl_geometry")

	TARGET_LINK_LIBRARIES (
		rbdl_geometry-static
		rbdl-static
	)

	INSTALL (TARGETS rbdl_geometry-static  
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		)
ELSE (RBDL_BUILD_STATIC)
	ADD_LIBRARY ( rbdl_geometry SHARED ${GEOMETRY_SOURCES} )
	SET_TARGET_PROPERTIES ( rbdl_geometry PROPERTIES
		VERSION ${RBDL_VERSION}
		SOVERSION ${RBDL_SO_VERSION}
  )

	TARGET_LINK_LIBRARIES (
		rbdl_geometry
		rbdl
		)

	INSTALL (TARGETS rbdl_geometry  
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		)
ENDIF (RBDL_BUILD_STATIC)

FILE ( GLOB headers 
	"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
	)

INSTALL ( FILES ${GEOMETRY_HEADERS} 
	DESTINATION 
	${CMAKE_INSTALL_INCLUDEDIR}/rbdl/addons/geometry 
	)
