forked from ros/urdfdom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
138 lines (110 loc) · 4.96 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
project (urdfdom CXX C)
set (URDF_MAJOR_VERSION 0)
set (URDF_MINOR_VERSION 3)
set (URDF_PATCH_VERSION 0)
set (URDF_VERSION ${URDF_MAJOR_VERSION}.${URDF_MINOR_VERSION}.${URDF_PATCH_VERSION})
message (STATUS "${PROJECT_NAME} version ${URDF_VERSION}")
include(GNUInstallDirs)
# hack: by default this would be 'lib/x86_64-linux-gnu'
set(CMAKE_INSTALL_LIBDIR lib)
# set the default build type
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# If compiler support symbol visibility, enable it.
include(CheckCCompilerFlag)
check_c_compiler_flag(-fvisibility=hidden HAS_VISIBILITY)
if (HAS_VISIBILITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
# This shouldn't be necessary, but there has been trouble
# with MSVC being set off, but MSVCXX ON.
if(MSVC OR MSVC90 OR MSVC10)
set(MSVC ON)
endif (MSVC OR MSVC90 OR MSVC10)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddInstallRPATHSupport)
option(URDFDOM_ENABLE_RPATH "Enable RPATH for the library" TRUE)
mark_as_advanced(URDFDOM_ENABLE_RPATH)
include(AddInstallRPATHSupport)
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}"
LIB_DIRS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
DEPENDS YARPWBI_ENABLE_RPATH
USE_LINK_PATH)
# CMake options
option(URDFDOM_DO_NOT_USE_CONSOLEBRIDGE "If true do not use console_bridge for output messages, and rely on standard C functions." FALSE)
option(URDFDOM_DO_NOT_INSTALL_URDFPARSERPY "If true do not install the urdf_parser_py python package through CMake." FALSE)
if(URDFDOM_DO_NOT_USE_CONSOLEBRIDGE)
add_definitions(-DURDFDOM_DO_NOT_USE_CONSOLEBRIDGE)
endif()
# Try to find a TinyXMLConfig.cmake file
find_package(TinyXML CONFIG QUIET)
# if a TinyXML cmake config file is not found, fallback
# to use the FindTinyXML.cmake file
if(NOT TinyXML_FOUND)
find_package(TinyXML REQUIRED)
endif()
include_directories(SYSTEM ${TinyXML_INCLUDE_DIRS})
find_package(urdfdom_headers REQUIRED)
include_directories(SYSTEM ${urdfdom_headers_INCLUDE_DIRS})
if (NOT URDFDOM_DO_NOT_USE_CONSOLEBRIDGE)
find_package(console_bridge REQUIRED)
include_directories(SYSTEM ${console_bridge_INCLUDE_DIRS})
link_directories(${console_bridge_LIBRARY_DIRS})
endif()
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
#In Visual Studio a special postfix for
#libraries compiled in debug is used
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
endif(MSVC)
add_subdirectory(urdf_parser)
set(PKG_NAME ${PROJECT_NAME})
set(PKG_LIBRARIES urdfdom_model urdfdom_world)
if(NOT URDFDOM_DO_NOT_USE_CONSOLEBRIDGE)
set(PKG_DEPENDS urdfdom_headers console_bridge)
else()
set(PKG_DEPENDS urdfdom_headers)
endif()
set(cmake_conf_file "cmake/urdfdom-config.cmake")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${cmake_conf_file}.in" "${CMAKE_BINARY_DIR}/${cmake_conf_file}" @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/${cmake_conf_file}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake/ COMPONENT cmake)
if(NOT CMAKE_VERSION VERSION_LESS 2.8.6)
# If CMake is version 2.8.6 or later, properly produce a version configuration files
set(cmake_conf_version_file "cmake/urdfdom-config-version.cmake")
# Use write_basic_package_version_file to generate a ConfigVersion file that
# allow users of urdfdom to specify the API or version to depend on
# TODO: keep this instruction until deprecate Ubuntu/Precise and update with
# https://github.com/Kitware/CMake/blob/v2.8.8/Modules/CMakePackageConfigHelpers.cmake
include(WriteBasicConfigVersionFile)
write_basic_config_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_version_file}
VERSION "${URDF_VERSION}"
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_version_file}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake/
COMPONENT cmake)
endif()
# Make the package config file
if (NOT MSVC)
set(PKG_DESC "Unified Robot Description Format")
set(PKG_DEPENDS "urdfdom_headers console_bridge") # make the list separated by spaces instead of ;
set(PKG_URDF_LIBS "-lurdfdom_model -lurdfdom_world")
set(pkg_conf_file "cmake/pkgconfig/urdfdom.pc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${pkg_conf_file}.in" "${CMAKE_BINARY_DIR}/${pkg_conf_file}" @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/${pkg_conf_file}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ COMPONENT pkgconfig)
endif()
# If the proper option is selected by the user
# avoid trying to install urdf_parser_py via CMake
if (NOT URDFDOM_DO_NOT_INSTALL_URDFPARSERPY)
add_subdirectory(urdf_parser_py)
endif()
message(STATUS "Configuration successful. Type make to compile urdfdom")
SET_DIRECTORY_PROPERTIES(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/cmake/urdfdom-config.cmake
ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/cmake/pkgconfig/urdfdom.pc)