-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
144 lines (113 loc) · 4.37 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
139
140
141
142
143
144
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
MESSAGE(STATUS "Using CMake ${CMAKE_VERSION}")
SET(RLENVSCPP_VERSION_MAJOR 1)
SET(RLENVSCPP_VERSION_MINOR 8)
SET(RLENVSCPP_VERSION_PATCH 0)
SET(RLENVSCPP_VERSION "${RLENVSCPP_VERSION_MAJOR}.${RLENVSCPP_VERSION_MINOR}.${RLENVSCPP_VERSION_PATCH}")
MESSAGE(STATUS "rlenvscpplib Version ${RLENVSCPP_VERSION}")
# create a CMake project
PROJECT(rlenvscpp VERSION ${RLENVSCPP_VERSION} LANGUAGES CXX)
# -----------------------------------------------------------------------------
# Prevent in-source builds.
# -----------------------------------------------------------------------------
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
MESSAGE( FATAL_ERROR "In-source build is not possible. Choose an empty directory for build output.")
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# Be sure to avoid troubles with library paths when using old policy
IF(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0048 NEW)
ENDIF(COMMAND cmake_policy)
OPTION(ENABLE_TESTS_FLAG OFF)
OPTION(ENABLE_EXAMPLES_FLAG OFF)
OPTION(ENABLE_DOC_FLAG OFF)
SET(CMAKE_BUILD_TYPE "Debug")
#SET(CMAKE_CXX_COMPILER /usr/bin/g++-11)
#SET(CMAKE_C_COMPILER /usr/bin/gcc-11)
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED True)
SET(CMAKE_LINKER_FLAGS "-pthread")
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install/dbg)
SET(CMAKE_CXX_FLAGS "-g ") # -Wall -Wextra")
SET(RLENVSCPP_DEBUG ON)
ELSE(CMAKE_BUILD_TYPE STREQUAL "Release")
SET(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install/opt)
SET(CMAKE_CXX_FLAGS "-O2")
SET(RLENVSCPP_DEBUG OFF)
ENDIF()
# where to install the library
IF(ENABLE_TESTS_FLAG)
# find gtest
FIND_PACKAGE(GTest REQUIRED)
IF(GTest_FOUND)
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
LINK_DIRECTORIES("/usr/local/lib")
MESSAGE( STATUS "Found Gtest at ${GTEST_INCLUDE_DIRS}.")
ELSE()
MESSAGE( FATAL_ERROR "ENABLE_TESTS_FLAG is ON but could not find GTest library.")
ENDIF()
ENDIF()
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
configure_file(config.h.in ${PROJECT_SOURCE_DIR}/src/rlenvs/rlenvscpp_config.h @ONLY)
configure_file(version.h.in ${PROJECT_SOURCE_DIR}/src/rlenvs/rlenvscpp_version.h @ONLY)
# Find boost
FIND_PACKAGE(Boost 1.74.0 REQUIRED)
FIND_PACKAGE(BLAS REQUIRED)
FIND_PACKAGE(Eigen3 REQUIRED)
IF(Boost_FOUND)
MESSAGE( STATUS "Found needed Boost C++ library.")
SET(Boost_USE_SHARED_LIBS ON)
ELSE()
MESSAGE( FATAL_ERROR "Boost C++ library is required but not found.")
ENDIF()
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
MESSAGE(STATUS "C++ Compiler: ${CMAKE_CXX_COMPILER}")
MESSAGE(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
MESSAGE(STATUS "Boost lib: ${Boost_LIBRARY_DIR}")
MESSAGE(STATUS "Boost include: ${Boost_INCLUDE_DIRS}")
MESSAGE(STATUS "Install dst: ${CMAKE_INSTALL_PREFIX}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(src/)
FILE(GLOB SRCS src/rlenvs/*.cpp
src/rlenvs/envs/*.cpp
src/rlenvs/envs/api_server/*.cpp
src/rlenvs/envs/gymnasium/*.cpp
src/rlenvs/envs/gymnasium/toy_text/*.cpp
src/rlenvs/envs/gymnasium/classic_control/*.cpp
src/rlenvs/envs/gymnasium/classic_control/vector/*.cpp
src/rlenvs/envs/gdrl/*.cpp
#src/rlenvs/envs/gym_pybullet_drones/*.cpp
src/rlenvs/envs/grid_world/*.cpp
src/rlenvs/envs/connect2/*.cpp
src/rlenvs/dynamics/*.cpp
src/rlenvs/utils/*.cpp
src/rlenvs/utils/io/*.cpp
src/rlenvs/utils/io/tensor_board_server/*.cpp
src/rlenvs/utils/geometry/*.cpp
src/rlenvs/utils/geometry/shapes/*.cpp
src/rlenvs/utils/geometry/mesh/*.cpp
src/rlenvs/utils/trajectory/*.cpp
)
ADD_LIBRARY(rlenvscpplib SHARED ${SRCS})
SET_TARGET_PROPERTIES(rlenvscpplib PROPERTIES LINKER_LANGUAGE CXX)
INSTALL(TARGETS rlenvscpplib DESTINATION ${CMAKE_INSTALL_PREFIX})
MESSAGE(STATUS "Installation destination at: ${CMAKE_INSTALL_PREFIX}")
IF(ENABLE_EXAMPLES_FLAG)
# Add the examples
ADD_SUBDIRECTORY(examples)
ELSE()
MESSAGE(WARNING "Examples have not been enabled")
ENDIF()
IF(ENABLE_TESTS_FLAG)
# Add the tests
ADD_SUBDIRECTORY(tests)
ELSE()
MESSAGE(WARNING "Tests have not been enabled")
ENDIF()
#IF(ENABLE_DOC_FLAG)
# Add the tests
# ADD_SUBDIRECTORY(doc)
#ELSE()
# MESSAGE(WARNING "Documentation will not be generated")
#ENDIF()