From 0b1b20ea8172504cb29d7e82f1bdab873fb9fc23 Mon Sep 17 00:00:00 2001 From: sksat Date: Tue, 12 Nov 2024 13:54:27 +0900 Subject: [PATCH 1/4] make s2e-core internal library from static lib to object lib --- src/components/CMakeLists.txt | 2 +- src/disturbances/CMakeLists.txt | 2 +- src/dynamics/CMakeLists.txt | 2 +- src/environment/global/CMakeLists.txt | 2 +- src/environment/local/CMakeLists.txt | 2 +- src/logger/CMakeLists.txt | 2 +- src/math_physics/CMakeLists.txt | 2 +- src/setting_file_reader/CMakeLists.txt | 2 +- src/simulation/CMakeLists.txt | 2 +- src/utilities/CMakeLists.txt | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/CMakeLists.txt b/src/components/CMakeLists.txt index 019dfc82b..03fbfc269 100644 --- a/src/components/CMakeLists.txt +++ b/src/components/CMakeLists.txt @@ -69,7 +69,7 @@ if(USE_C2A_COMMAND_SENDER) ) endif() -add_library(${PROJECT_NAME} STATIC +add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES} ) diff --git a/src/disturbances/CMakeLists.txt b/src/disturbances/CMakeLists.txt index 1ec497d73..cbd75b0c5 100644 --- a/src/disturbances/CMakeLists.txt +++ b/src/disturbances/CMakeLists.txt @@ -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 diff --git a/src/dynamics/CMakeLists.txt b/src/dynamics/CMakeLists.txt index 72f038590..d878e37f9 100644 --- a/src/dynamics/CMakeLists.txt +++ b/src/dynamics/CMakeLists.txt @@ -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 diff --git a/src/environment/global/CMakeLists.txt b/src/environment/global/CMakeLists.txt index 8ce63a332..238590564 100644 --- a/src/environment/global/CMakeLists.txt +++ b/src/environment/global/CMakeLists.txt @@ -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 diff --git a/src/environment/local/CMakeLists.txt b/src/environment/local/CMakeLists.txt index b9943f9d0..d7d52406a 100644 --- a/src/environment/local/CMakeLists.txt +++ b/src/environment/local/CMakeLists.txt @@ -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 diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 336e85042..75af4bc57 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -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 ) diff --git a/src/math_physics/CMakeLists.txt b/src/math_physics/CMakeLists.txt index 7eb305f84..21e5dee87 100644 --- a/src/math_physics/CMakeLists.txt +++ b/src/math_physics/CMakeLists.txt @@ -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 diff --git a/src/setting_file_reader/CMakeLists.txt b/src/setting_file_reader/CMakeLists.txt index 898d3e0fa..18d1b69e8 100644 --- a/src/setting_file_reader/CMakeLists.txt +++ b/src/setting_file_reader/CMakeLists.txt @@ -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 diff --git a/src/simulation/CMakeLists.txt b/src/simulation/CMakeLists.txt index 360406dca..229a03711 100644 --- a/src/simulation/CMakeLists.txt +++ b/src/simulation/CMakeLists.txt @@ -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 diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index ce9bef781..f808742ad 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -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 From a704e9f2d4d585aaae796ddb4e77e28a00ad8018 Mon Sep 17 00:00:00 2001 From: sksat Date: Tue, 12 Nov 2024 13:54:49 +0900 Subject: [PATCH 2/4] make internal lib link logic simple --- CMakeLists.txt | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19144b325..626955c88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,23 +179,25 @@ 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) + +target_link_libraries(${PROJECT_NAME} + LOGGER + SETTING_FILE_READER + INIH + UTILITIES + + COMPONENT + DISTURBANCE + DYNAMICS + GLOBAL_ENVIRONMENT + LOCAL_ENVIRONMENT + MATH_PHYSICS + SIMULATION + + # ExtLibraries + ${NRLMSISE00_LIB} + ${CSPICE_LIB} +) ## C2A integration if(USE_C2A) From cca911f189b6c759ce853d3d37cae4cc18af6409 Mon Sep 17 00:00:00 2001 From: sksat Date: Tue, 12 Nov 2024 14:43:25 +0900 Subject: [PATCH 3/4] fix unit test link --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 626955c88..936ee77f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,11 +239,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() From 52c0199e773960adb0057b1b286e04c5a23c7236 Mon Sep 17 00:00:00 2001 From: sksat Date: Thu, 14 Nov 2024 20:24:21 +0900 Subject: [PATCH 4/4] link hack for MSVC link.exe with CMake object libraries --- CMakeLists.txt | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 936ee77f0..46fda6c45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -180,19 +177,25 @@ if(NOT NRLMSISE00_LIB) message(FATAL_ERROR "nrlmsise00 not found in ${EXT_LIB_DIR}") endif() +# link hack for MSVC link.exe +add_library(lib${PROJECT_NAME} + $ + $ + $ + $ + + $ + $ + $ + $ + $ + $ + $ +) +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) + target_link_libraries(${PROJECT_NAME} - LOGGER - SETTING_FILE_READER - INIH - UTILITIES - - COMPONENT - DISTURBANCE - DYNAMICS - GLOBAL_ENVIRONMENT - LOCAL_ENVIRONMENT - MATH_PHYSICS - SIMULATION + lib${PROJECT_NAME} # ExtLibraries ${NRLMSISE00_LIB}