-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
103 lines (78 loc) · 4.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Copyright: (C) 2013 CoDyCo Consortium
# Authors: Francesco Romano, Silvio Traversaro
# CopyPolicy: Released under the terms of the GNU GPL v2.0 (or any later version).
cmake_minimum_required(VERSION 2.8.11)
project(codycoCommons CXX)
set(LIBRARY_NAME codycocommons)
set(VARS_PREFIX ${PROJECT_NAME})
set(INCLUDE_DIRS codyco)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(${VARS_PREFIX}_MAJOR_VERSION 0)
set(${VARS_PREFIX}_MINOR_VERSION 3)
set(${VARS_PREFIX}_PATCH_VERSION 0)
set(${VARS_PREFIX}_VERSION ${${VARS_PREFIX}_MAJOR_VERSION}.${${VARS_PREFIX}_MINOR_VERSION}.${${VARS_PREFIX}_PATCH_VERSION})
option(COMPILE_AS_SHARED_LIBRARY "Compile ${PROJECT_NAME} as a shared library" TRUE)
option(CODYCOCOMMONS_ENABLE_RPATH "Enable RPATH for the library" TRUE)
mark_as_advanced(CODYCOCOMMONS_ENABLE_RPATH)
find_package(YCM REQUIRED)
include(YCMDefaultDirs)
ycm_default_dirs(${VARS_PREFIX})
find_package(YARP REQUIRED)
find_package(ICUB REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(iDynTree REQUIRED)
set(folder_source src/MathUtils.cpp
src/ControllerThread.cpp
src/ModelParsing.cpp
src/PIDList.cpp)
set(folder_header include/codyco/Commons.h
include/codyco/Utils.h
include/codyco/MathUtils.h
include/codyco/ControllerThread.h
include/codyco/ModelParsing.h
include/codyco/PIDList.h)
SOURCE_GROUP("Source Files" FILES ${folder_source})
SOURCE_GROUP("Header Files" FILES ${folder_header})
if(MSVC)
message(STATUS "Building ${PROJECT_NAME} as a shared library is not currently supported on Windows")
set(COMPILE_AS_SHARED_LIBRARY FALSE)
endif()
if(COMPILE_AS_SHARED_LIBRARY)
set(LIB_TYPE SHARED)
else()
set(LIB_TYPE STATIC)
endif()
include(AddInstallRPATHSupport)
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_PREFIX}/bin"
LIB_DIRS "${CMAKE_INSTALL_PREFIX}/lib"
DEPENDS CODYCOCOMMONS_ENABLE_RPATH
USE_LINK_PATH)
add_library(${LIBRARY_NAME} ${LIB_TYPE} ${folder_source} ${folder_header})
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION ${${VARS_PREFIX}_VERSION}
SOVERSION ${${VARS_PREFIX}_VERSION}
PUBLIC_HEADER "${folder_header}")
target_include_directories(${LIBRARY_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/codyco>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/${${VARS_PREFIX}_INSTALL_INCLUDEDIR}>"
${YARP_INCLUDE_DIRS}
${iDynTree_INCLUDE_DIRS}
${skinDynLib_INCLUDE_DIRS}
${ctrlLib_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR})
target_link_libraries(${LIBRARY_NAME} ${YARP_LIBRARIES}
${iDynTree_LIBRARIES}
${ctrlLib_LIBRARIES}
${skinDynLib_LIBRARIES})
install(TARGETS ${LIBRARY_NAME}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION "${${VARS_PREFIX}_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${${VARS_PREFIX}_INSTALL_LIBDIR}" COMPONENT shlib
ARCHIVE DESTINATION "${${VARS_PREFIX}_INSTALL_LIBDIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${${VARS_PREFIX}_INSTALL_INCLUDEDIR}/${INCLUDE_DIRS}" COMPONENT dev)
set_property(GLOBAL APPEND PROPERTY ${VARS_PREFIX}_TARGETS ${LIBRARY_NAME})
include(InstallBasicPackageFiles)
install_basic_package_files(${PROJECT_NAME} VARS_PREFIX ${VARS_PREFIX}
VERSION ${${VARS_PREFIX}_VERSION}
COMPATIBILITY SameMajorVersion
TARGETS_PROPERTY ${VARS_PREFIX}_TARGETS
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
include(AddUninstallTarget)