CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

CMAKE_POLICY(SET CMP0048 NEW)
CMAKE_POLICY(SET CMP0040 NEW)
 
SET ( RBDL_ADDON_MUSCLE_VERSION_MAJOR 1 )
SET ( RBDL_ADDON_MUSCLE_VERSION_MINOR 0 )
SET ( RBDL_ADDON_MUSCLE_VERSION_PATCH 0 )

SET ( RBDL_ADDON_MUSCLE_VERSION 
	${RBDL_ADDON_MUSCLE_VERSION_MAJOR}.${RBDL_ADDON_MUSCLE_VERSION_MINOR}.${RBDL_ADDON_MUSCLE_VERSION_PATCH}
)


PROJECT (RBDL_ADDON_MUSCLE VERSION ${RBDL_ADDON_MUSCLE_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(MUSCLE_SOURCES 
	muscle.h
	Millard2016TorqueMuscle.h
	Millard2016TorqueMuscle.cc
	MuscleFunctionFactory.h 
	MuscleFunctionFactory.cc
	TorqueMuscleFunctionFactory.h
	TorqueMuscleFunctionFactory.cc
	csvtools.h
	csvtools.cc
)

SET(MUSCLE_HEADERS	
	muscle.h
	Millard2016TorqueMuscle.h
	MuscleFunctionFactory.h 
	TorqueMuscleFunctionFactory.h
	csvtools.h	
)

IF (RBDL_BUILD_STATIC)
	ADD_LIBRARY ( rbdl_muscle-static STATIC ${MUSCLE_SOURCES} )
	SET_TARGET_PROPERTIES ( rbdl_muscle-static PROPERTIES PREFIX "lib")
	SET_TARGET_PROPERTIES ( rbdl_muscle-static PROPERTIES OUTPUT_NAME "rbdl_muscle")
	TARGET_LINK_LIBRARIES (rbdl_muscle-static
		rbdl_geometry-static
		rbdl-static
	)


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

	TARGET_LINK_LIBRARIES (rbdl_muscle
		rbdl_geometry
		rbdl
		)


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

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

INSTALL ( FILES ${MUSCLE_HEADERS} 
	DESTINATION 
	${CMAKE_INSTALL_INCLUDEDIR}/rbdl/addons/muscle
	)
