Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link internal library as CMake object library #710

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ set(SOURCE_FILES
src/simulation_sample/ground_station/sample_ground_station.cpp
)

## Create executable file
add_executable(${PROJECT_NAME} ${SOURCE_FILES})

## cspice library
if(APPLE)
if(APPLE_SILICON)
Expand Down Expand Up @@ -179,23 +176,31 @@ endif()
if(NOT NRLMSISE00_LIB)
message(FATAL_ERROR "nrlmsise00 not found in ${EXT_LIB_DIR}")
endif()
#target_link_libraries(${PROJECT_NAME} ${NRLMSISE00_LIB})

# Initialize link
target_link_libraries(COMPONENT DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT MATH_PHYSICS SETTING_FILE_READER LOGGER UTILITIES)
target_link_libraries(DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT SIMULATION MATH_PHYSICS)
target_link_libraries(DISTURBANCE DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT MATH_PHYSICS)
target_link_libraries(SIMULATION DYNAMICS GLOBAL_ENVIRONMENT LOCAL_ENVIRONMENT DISTURBANCE MATH_PHYSICS)
target_link_libraries(GLOBAL_ENVIRONMENT ${CSPICE_LIB} MATH_PHYSICS)
target_link_libraries(LOCAL_ENVIRONMENT GLOBAL_ENVIRONMENT ${CSPICE_LIB} MATH_PHYSICS)
target_link_libraries(MATH_PHYSICS ${NRLMSISE00_LIB})
target_link_libraries(SETTING_FILE_READER INIH)

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} COMPONENT)

# link hack for MSVC link.exe
add_library(lib${PROJECT_NAME}
$<TARGET_OBJECTS:LOGGER>
$<TARGET_OBJECTS:SETTING_FILE_READER>
$<TARGET_OBJECTS:INIH>
$<TARGET_OBJECTS:UTILITIES>

$<TARGET_OBJECTS:COMPONENT>
$<TARGET_OBJECTS:DISTURBANCE>
$<TARGET_OBJECTS:DYNAMICS>
$<TARGET_OBJECTS:GLOBAL_ENVIRONMENT>
$<TARGET_OBJECTS:LOCAL_ENVIRONMENT>
$<TARGET_OBJECTS:MATH_PHYSICS>
$<TARGET_OBJECTS:SIMULATION>
)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})

target_link_libraries(${PROJECT_NAME}
lib${PROJECT_NAME}

# ExtLibraries
${NRLMSISE00_LIB}
${CSPICE_LIB}
)

## C2A integration
if(USE_C2A)
Expand Down Expand Up @@ -237,11 +242,12 @@ if(GOOGLE_TEST)
file(GLOB_RECURSE TEST_FILES ${CMAKE_CURRENT_LIST_DIR}/src/test_*.cpp)
# Uncomment the following line to exclude any files that match the REGEX from TEST_FILES
# list(FILTER TEST_FILES EXCLUDE REGEX ${CMAKE_CURRENT_LIST_DIR}/src/test_example.cpp)
include_directories(${TEST_PROJECT_NAME})

add_executable(${TEST_PROJECT_NAME} ${TEST_FILES})
target_link_libraries(${TEST_PROJECT_NAME} gtest gtest_main gmock)
target_link_libraries(${TEST_PROJECT_NAME} MATH_PHYSICS)
include_directories(${TEST_PROJECT_NAME})
target_link_libraries(${TEST_PROJECT_NAME} MATH_PHYSICS ${NRLMSISE00_LIB})

add_test(NAME s2e-test COMMAND ${TEST_PROJECT_NAME})
enable_testing()

Expand Down
2 changes: 1 addition & 1 deletion src/components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if(USE_C2A_COMMAND_SENDER)
)
endif()

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
${SOURCE_FILES}
)

Expand Down
2 changes: 1 addition & 1 deletion src/disturbances/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(DISTURBANCE)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
air_drag.cpp
disturbances.cpp
geopotential.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/dynamics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(DYNAMICS)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
orbit/orbit.cpp
orbit/sgp4_orbit_propagation.cpp
orbit/rk4_orbit_propagation.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/environment/global/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(GLOBAL_ENVIRONMENT)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
global_environment.cpp
celestial_information.cpp
hipparcos_catalogue.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/environment/local/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(LOCAL_ENVIRONMENT)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
atmosphere.cpp
local_environment.cpp
geomagnetic_field.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/logger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(LOGGER)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
logger.cpp
initialize_log.cpp
)
Expand Down
2 changes: 1 addition & 1 deletion src/math_physics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(MATH_PHYSICS)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
atmosphere/simple_air_density_model.cpp
atmosphere/harris_priester_model.cpp
atmosphere/wrapper_nrlmsise00.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/setting_file_reader/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(SETTING_FILE_READER)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
initialize_file_access.cpp
c2a_command_database.cpp
wings_operation_file.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(SIMULATION)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
case/simulation_case.cpp

monte_carlo_simulation/monte_carlo_simulation_executor.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(UTILITIES)
cmake_minimum_required(VERSION 3.13)

add_library(${PROJECT_NAME} STATIC
add_library(${PROJECT_NAME} OBJECT
endian.cpp
slip.cpp
quantization.cpp
Expand Down