-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCMakeLists.txt
158 lines (133 loc) · 5.69 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
cmake_minimum_required(VERSION 3.10)
project(raisimOgre VERSION 0.7.0)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
option(RAISIM_OGRE_EXAMPLES "Build example applications." TRUE)
####################################
########### dependencies ###########
####################################
find_package(raisim 0.6.0 CONFIG REQUIRED)
find_package(OGRE 1.12.1 CONFIG REQUIRED COMPONENTS Bites RTShaderSystem)
find_package(Eigen3 REQUIRED HINTS ${Eigen3_HINT})
####################################
############# building #############
####################################
add_library(${PROJECT_NAME} SHARED
${CMAKE_CURRENT_SOURCE_DIR}/src/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/imgui_plot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/imgui_widgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ImguiManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ImguiRenderable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/AssimpLoader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/OgreVis.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CameraMan.cpp
)
add_library(raisim::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
add_subdirectory(third-party/assimp)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)
target_compile_options(${PROJECT_NAME} PUBLIC -fPIC)
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELEASE>:-O3>")
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:DEBUG>:-O0>")
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:DEBUG>:-g>")
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELEASE>:-g>")
target_link_libraries(${PROJECT_NAME} PUBLIC OgreMain OgreBites OgreRTShaderSystem OgreMeshLodGenerator raisim::assimp raisim::raisim pthread zzip SDL2)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_compile_options(${PROJECT_NAME} PUBLIC -Wl,--no-as-needed) # workaround for gcc pthread link bug
####################################
########### installation ###########
####################################
# Install package configuration
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config-version.cmake
VERSION ${raisimOgre_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config-version.cmake
DESTINATION
${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
###################################################################################
# This section is a hack to make resource found for both example build, installation and inclusion from upper-level project
# Install resources for installed version
set(RAISIM_OGRE_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/rsc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/resources.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre/resources.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ogre.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre/ogre.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/plugins.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre/plugins.cfg @ONLY)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/ogre/resources.cfg
${CMAKE_CURRENT_BINARY_DIR}/ogre/ogre.cfg
${CMAKE_CURRENT_BINARY_DIR}/ogre/plugins.cfg
DESTINATION
${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/ogre
)
# Install resources for this cmake build.
set(RAISIM_OGRE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rsc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/resources.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/resources.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ogre.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/plugins.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/plugins.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/resources.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre/resources.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ogre.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre/ogre.cfg @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/plugins.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ogre/plugins.cfg @ONLY)
######################################################################################
add_definitions(-DOGRE_CONFIG_DIR=${CMAKE_CURRENT_BINARY_DIR}/)
install(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/rsc
DESTINATION
${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
)
file(
COPY
${CMAKE_CURRENT_SOURCE_DIR}/rsc
DESTINATION
${CMAKE_CURRENT_BINARY_DIR}
)
# Install targets
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${LIBLEGACY_INCLUDE_DIRS}
)
export(
TARGETS ${PROJECT_NAME}
NAMESPACE raisim::
FILE cmake/${PROJECT_NAME}-targets.cmake
)
install(
EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE raisim::
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
# Install headers
install(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/include/raisim
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
)
####################################
############# examples #############
####################################
if(RAISIM_OGRE_EXAMPLES)
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_PREFIX_PATH})
add_subdirectory(examples)
endif()