-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
218 lines (198 loc) · 8.17 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
## General Settings
cmake_policy(SET CMP0048 NEW)
project(S2E_6U_MOBC
LANGUAGES CXX
DESCRIPTION "s2e 6u mobc: S2E Repository for c2a issl6u sphere"
VERSION 2.0.0
)
cmake_minimum_required(VERSION 3.13)
# build config
option(USE_HILS "Use HILS" OFF)
option(USE_C2A "Use C2A" OFF)
# preprocessor
if(WIN32)
add_definitions(-DWIN32)
endif()
## set directory path
set(S2E_CORE_DIR ../s2e-core)
if(NOT DEFINED EXT_LIB_DIR)
set(EXT_LIB_DIR ../ExtLibraries)
endif()
set(CSPICE_DIR ${EXT_LIB_DIR}/cspice)
set(NRLMSISE00_DIR ${EXT_LIB_DIR}/nrlmsise00)
if(NOT DEFINED FLIGHT_SW_DIR)
set(FLIGHT_SW_DIR ../FlightSW)
endif()
if(NOT DEFINED C2A_NAME)
set(C2A_NAME "c2a_oss")
endif()
## options to use C2A
if(USE_C2A)
set(C2A_DIR ${FLIGHT_SW_DIR}/${C2A_NAME})
message("C2A dir: ${C2A_DIR}")
add_definitions(-DUSE_C2A)
add_definitions(-DSILS_FW)
#include_directories of C2A
include_directories(${C2A_DIR}/SH7254R_C2A)
include_directories(${S2E_CORE_DIR}/src/Interface/SpacecraftInOut)
#add subdirectory
set(BUILD_C2A_AS_CXX ON)
add_subdirectory(${C2A_DIR} C2A)
endif()
## options to use HILS
if(USE_HILS AND WIN32)
add_definitions(-DUSE_HILS)
## winsock2
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
find_library(WS2_32_LIB ws2_32.lib)
message("path for winsock2 is")
message(${WS2_32_LIB})
endif()
## include directories of s2e-core
include_directories(${CSPICE_DIR}/include)
include_directories(${NRLMSISE00_DIR}/src)
include_directories(${S2E_CORE_DIR}/src)
include_directories(${S2E_CORE_DIR}/src/Library/math)
include_directories(${S2E_CORE_DIR}/src/Library/utils)
include_directories(${S2E_CORE_DIR}/src/Dynamics)
include_directories(${S2E_CORE_DIR}/src/Disturbance)
include_directories(${S2E_CORE_DIR}/src/Interface/InitInput)
include_directories(${S2E_CORE_DIR}/src/Interface/LogOutput)
include_directories(${S2E_CORE_DIR}/src/Interface/SpacecraftInOut/Ports)
include_directories(${S2E_CORE_DIR}/src/Simulation)
include_directories(${S2E_CORE_DIR}/src/Simulation/MCSim)
include_directories(${S2E_CORE_DIR}/src/Simulation/Spacecraft)
include_directories(${S2E_CORE_DIR}/src/Simulation/Spacecraft/Structure)
include_directories(${S2E_CORE_DIR}/src/Simulation/GroundStation)
include_directories(${S2E_CORE_DIR}/src/Simulation/Case)
include_directories(${S2E_CORE_DIR}/src/Disturbance)
include_directories(${S2E_CORE_DIR}/src/Environment/Global)
include_directories(${S2E_CORE_DIR}/src/Environment/Local)
include_directories(${S2E_CORE_DIR}/src/Component)
include_directories(${S2E_CORE_DIR}/src/Component/Abstract)
include_directories(${S2E_CORE_DIR}/src/Component/AOCS)
include_directories(${S2E_CORE_DIR}/src/Component/CDH)
include_directories(${S2E_CORE_DIR}/src/Component/CommGS)
include_directories(${S2E_CORE_DIR}/src/Component/Mission/Telescope)
include_directories(${S2E_CORE_DIR}/src/Component/Power)
include_directories(${S2E_CORE_DIR}/src/Component/Propulsion)
include_directories(${S2E_CORE_DIR}/src/Component/Thermal)
## add_subdirectories
add_subdirectory(${S2E_CORE_DIR}/src/Component S2E_CORE/Component)
add_subdirectory(${S2E_CORE_DIR}/src/Disturbance S2E_CORE/Disturbance)
add_subdirectory(${S2E_CORE_DIR}/src/Dynamics S2E_CORE/Dynamics)
add_subdirectory(${S2E_CORE_DIR}/src/Environment/Global S2E_CORE/Environment/Global)
add_subdirectory(${S2E_CORE_DIR}/src/Environment/Local S2E_CORE/Environment/Local)
add_subdirectory(${S2E_CORE_DIR}/src/RelativeInformation S2E_CORE/RelativeInformation)
add_subdirectory(${S2E_CORE_DIR}/src/Interface/InitInput S2E_CORE/InitInput)
add_subdirectory(${S2E_CORE_DIR}/src/Interface/LogOutput S2E_CORE/LogOutput)
add_subdirectory(${S2E_CORE_DIR}/src/Interface/SpacecraftInOut S2E_CORE/SpacecraftInOut)
add_subdirectory(${S2E_CORE_DIR}/src/Interface/HilsInOut S2E_CORE/HilsInOut)
add_subdirectory(${S2E_CORE_DIR}/src/Library/igrf S2E_CORE/igrf)
add_subdirectory(${S2E_CORE_DIR}/src/Library/inih S2E_CORE/inih)
add_subdirectory(${S2E_CORE_DIR}/src/Library/math S2E_CORE/math)
add_subdirectory(${S2E_CORE_DIR}/src/Library/nrlmsise00 S2E_CORE/nrlmsise00)
add_subdirectory(${S2E_CORE_DIR}/src/Library/sgp4 S2E_CORE/sgp4)
add_subdirectory(${S2E_CORE_DIR}/src/Library/utils S2E_CORE/utils)
add_subdirectory(${S2E_CORE_DIR}/src/Library/optics S2E_CORE/optics)
add_subdirectory(${S2E_CORE_DIR}/src/Library/RelativeOrbit S2E_CORE/RelativeOrbit)
add_subdirectory(${S2E_CORE_DIR}/src/Library/Orbit S2E_CORE/Orbit)
add_subdirectory(${S2E_CORE_DIR}/src/Library/Geodesy S2E_CORE/Geodesy)
add_subdirectory(${S2E_CORE_DIR}/src/Simulation S2E_CORE/Simulation)
set(SOURCE_FILES
src/S2eMobcSphere.cpp
src/Simulation/Case/MobcSphereCase.cpp
src/Simulation/Spacecraft/MobcSphereSat.cpp
src/Simulation/Spacecraft/MobcSphereComponents.cpp
src/Component/AOCS/aobc.cpp
src/Component/Power/pcdu.cpp
src/Component/COM/lora.cpp
src/Component/COM/STX.cpp
src/Component/COM/XTX.cpp
src/Component/MISSION/CCC.cpp
src/Component/MISSION/MIF.cpp
src/Component/Prop/prop.cpp
src/Component/Thermal/tobc.cpp
src/Component/LIB/crc.cpp
)
# Create executable file
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
## cspice library
if(CYGWIN)
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
find_library(CSPICE_LIB
NAMES cspice.a csupport.a
PATHS ${CSPICE_DIR}/cspice_cygwin/lib)
elseif(UNIX)
find_library(CSPICE_LIB
NAMES cspice.a csupport.a
PATHS ${CSPICE_DIR}/cspice_unix/lib)
elseif(WIN32)
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
find_library(CSPICE_LIB
NAMES cspice.lib csupport.lib
PATHS ${CSPICE_DIR}/cspice_msvs/lib)
endif()
if(NOT CSPICE_LIB)
message(FATAL_ERROR "cspice not found in ${EXT_LIB_DIR}")
endif()
## nrlmsise00 library
if(CYGWIN)
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_library(NRLMSISE00_LIB
NAMES libnrlmsise00.a
PATHS ${NRLMSISE00_DIR}/lib)
elseif(UNIX)
find_library(NRLMSISE00_LIB
NAMES libnrlmsise00.a
PATHS ${NRLMSISE00_DIR}/lib)
elseif(WIN32)
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
find_library(NRLMSISE00_LIB
NAMES libnrlmsise00.lib
PATHS ${NRLMSISE00_DIR}/lib)
endif()
if(NOT NRLMSISE00_LIB)
message(FATAL_ERROR "nrlmsise00 not found in ${EXT_LIB_DIR}")
endif()
## Linking libraries
set(S2E_LIBRARIES
IGRF WRAPPER_NRLMSISE00 INIH SGP4 UTIL OPTICS RELATIVE_ORBIT_MODELS ORBIT_MODELS GEODESY MATH
)
# Initialize link
target_link_libraries(COMPONENT DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT SC_IO RELATIVE_INFO ${S2E_LIBRARIES})
target_link_libraries(DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT SIMULATION ${S2E_LIBRARIES})
target_link_libraries(DISTURBANCE DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT ${S2E_LIBRARIES})
target_link_libraries(SIMULATION DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT DISTURBANCE ${S2E_LIBRARIES})
target_link_libraries(GLOBAL_ENVIRONMENT ${CSPICE_LIB} ${S2E_LIBRARIES})
target_link_libraries(LOCAL_ENVIRONMENT GLOBAL_ENVIRONMENT ${CSPICE_LIB} ${S2E_LIBRARIES})
target_link_libraries(WRAPPER_NRLMSISE00 ${NRLMSISE00_LIB})
target_link_libraries(${PROJECT_NAME} DYNAMICS)
target_link_libraries(${PROJECT_NAME} DISTURBANCE)
target_link_libraries(${PROJECT_NAME} SIMULATION)
target_link_libraries(${PROJECT_NAME} GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT)
target_link_libraries(${PROJECT_NAME} RELATIVE_INFO)
target_link_libraries(${PROJECT_NAME} INI_ACC LOG_OUT SC_IO)
target_link_libraries(${PROJECT_NAME} COMPONENT)
target_link_libraries(${PROJECT_NAME} HILS_IO)
## C2A integration
if(USE_C2A)
target_link_libraries(${PROJECT_NAME} C2A)
endif()
## HILS
if(USE_HILS)
target_link_libraries(${PROJECT_NAME} ${WS2_32_LIB})
set_target_properties(${PROJECT_NAME} PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(COMPONENT PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(DYNAMICS PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(DISTURBANCE PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(SIMULATION PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(GLOBAL_ENVIRONMENT PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(LOCAL_ENVIRONMENT PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(HILS_IO PROPERTIES COMMON_LANGUAGE_RUNTIME "")
set_target_properties(RELATIVE_INFO PROPERTIES COMMON_LANGUAGE_RUNTIME "")
endif()
## Cmake debug
message("Cspice_LIB: " ${CSPICE_LIB})
message("nrlmsise00_LIB: " ${NRLMSISE00_LIB})
include(common.cmake)