-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathCMakeLists.txt
103 lines (85 loc) · 3.29 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
# Copyright (C) 2019 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# GNU Lesser General Public License v2.1 or any later version.
cmake_minimum_required(VERSION 3.12)
project(Gympp VERSION 0.1)
# C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Include useful features
include(GNUInstallDirs)
# Build type
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, recommended options are: Debug or Release" FORCE)
endif()
set(GYMPP_BUILD_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${GYMPP_BUILD_TYPES})
endif()
# Build all libraries as shared. Plugins and singleton do not play well
# together if libraries are static.
set(BUILD_SHARED_LIBS ON)
# Tweak linker flags in Linux
if(UNIX AND NOT APPLE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
get_filename_component(LINKER_BIN ${CMAKE_LINKER} NAME)
if("${LINKER_BIN}" STREQUAL "ld")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--unresolved-symbols=report-all")
endif()
endif()
endif()
# Control where binaries and libraries are placed in the build folder.
# This simplifies tests running in Windows.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
# Get include-what-you-use information when compiling
option(USE_IWYU "Get the output of include-what-you-use" OFF)
if(USE_IWYU)
find_program(IWYU_PATH NAMES include-what-you-use iwyu)
if(IWYU_PATH)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
endif()
endif()
# Settings for RPATH
if(NOT MSVC)
option(ENABLE_RPATH "Enable RPATH installation" TRUE)
mark_as_advanced(ENABLE_RPATH)
endif()
# Add custom functions / macros
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Find YCM
find_package(YCM QUIET)
# Bootstrap YCM if not found
if(NOT ${YCM_FOUND})
include(BootstrapYCM)
endif()
# Configure RPATH
include(AddInstallRPATHSupport)
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_BINDIR}"
LIB_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}"
"${CMAKE_INSTALL_FULL_LIBDIR}/gympp/bindings"
"${CMAKE_INSTALL_FULL_LIBDIR}/gympp/plugins"
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}"
DEPENDS ENABLE_RPATH
USE_LINK_PATH)
# Dependencies
add_subdirectory(deps)
# Add the C++ sources subdirectory
add_subdirectory(gympp)
find_package(ignition-gazebo2 COMPONENTS all)
if(ignition-gazebo2_FOUND)
add_subdirectory(ignition)
add_subdirectory(plugins)
add_subdirectory(models)
add_subdirectory(examples/cpp)
option(ENABLE_BINDINGS "Enable swig bindings" ON)
if(ENABLE_BINDINGS)
add_subdirectory(bindings)
endif()
else()
message(STATUS "Ignition Gazebo not found. Enabled only the gympp interface and classes.")
endif()
# Add unistall target
include(AddUninstallTarget)