mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 11:29:56 +03:00
[SITL] sitl specific cmake cleanup (Windows only linker option) (#8995)
* [SITL] sitl specific cmake cleanup (Windows only linker option) * [SITL] sitl specific cmake cleanup (C17 for recent cmake)
This commit is contained in:
parent
3f35503a74
commit
f3088aeb9b
1 changed files with 16 additions and 10 deletions
|
@ -29,9 +29,12 @@ set(SITL_LINK_OPTIONS
|
||||||
-lrt
|
-lrt
|
||||||
-Wl,-L${STM32_LINKER_DIR}
|
-Wl,-L${STM32_LINKER_DIR}
|
||||||
-Wl,--cref
|
-Wl,--cref
|
||||||
-static-libgcc # Required for windows build under cygwin
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(${WIN32} OR ${CYGWIN})
|
||||||
|
set(SITL_LINK_OPTIONS ${SITL_LINK_OPTIONS} "-static-libgcc")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(SITL_LINK_LIBRARIS
|
set(SITL_LINK_LIBRARIS
|
||||||
-lpthread
|
-lpthread
|
||||||
-lm
|
-lm
|
||||||
|
@ -60,11 +63,14 @@ function(generate_map_file target)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function (target_sitl name)
|
function (target_sitl name)
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.22)
|
||||||
|
set(CMAKE_C_STANDARD 17)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT host STREQUAL TOOLCHAIN)
|
if(NOT host STREQUAL TOOLCHAIN)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
exclude(COMMON_SRC "${SITL_COMMON_SRC_EXCLUDES}")
|
exclude(COMMON_SRC "${SITL_COMMON_SRC_EXCLUDES}")
|
||||||
|
|
||||||
set(target_sources)
|
set(target_sources)
|
||||||
|
@ -72,9 +78,9 @@ function (target_sitl name)
|
||||||
file(GLOB target_c_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
|
file(GLOB target_c_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
|
||||||
file(GLOB target_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
|
file(GLOB target_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
|
||||||
list(APPEND target_sources ${target_c_sources} ${target_h_sources})
|
list(APPEND target_sources ${target_c_sources} ${target_h_sources})
|
||||||
|
|
||||||
set(target_definitions ${COMMON_COMPILE_DEFINITIONS})
|
set(target_definitions ${COMMON_COMPILE_DEFINITIONS})
|
||||||
|
|
||||||
set(hse_mhz ${STM32_DEFAULT_HSE_MHZ})
|
set(hse_mhz ${STM32_DEFAULT_HSE_MHZ})
|
||||||
math(EXPR hse_value "${hse_mhz} * 1000000")
|
math(EXPR hse_value "${hse_mhz} * 1000000")
|
||||||
list(APPEND target_definitions "HSE_VALUE=${hse_value}")
|
list(APPEND target_definitions "HSE_VALUE=${hse_value}")
|
||||||
|
@ -92,18 +98,18 @@ function (target_sitl name)
|
||||||
target_include_directories(${exe_target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(${exe_target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
target_compile_definitions(${exe_target} PRIVATE ${target_definitions})
|
target_compile_definitions(${exe_target} PRIVATE ${target_definitions})
|
||||||
|
|
||||||
|
|
||||||
if(WARNINGS_AS_ERRORS)
|
if(WARNINGS_AS_ERRORS)
|
||||||
target_compile_options(${exe_target} PRIVATE -Werror)
|
target_compile_options(${exe_target} PRIVATE -Werror)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_options(${exe_target} PRIVATE ${SITL_COMPILE_OPTIONS})
|
target_compile_options(${exe_target} PRIVATE ${SITL_COMPILE_OPTIONS})
|
||||||
|
|
||||||
target_link_libraries(${exe_target} PRIVATE ${SITL_LINK_LIBRARIS})
|
target_link_libraries(${exe_target} PRIVATE ${SITL_LINK_LIBRARIS})
|
||||||
target_link_options(${exe_target} PRIVATE ${SITL_LINK_OPTIONS})
|
target_link_options(${exe_target} PRIVATE ${SITL_LINK_OPTIONS})
|
||||||
|
|
||||||
generate_map_file(${exe_target})
|
generate_map_file(${exe_target})
|
||||||
|
|
||||||
set(script_path ${MAIN_SRC_DIR}/target/link/sitl.ld)
|
set(script_path ${MAIN_SRC_DIR}/target/link/sitl.ld)
|
||||||
if(NOT EXISTS ${script_path})
|
if(NOT EXISTS ${script_path})
|
||||||
message(FATAL_ERROR "linker script ${script_path} doesn't exist")
|
message(FATAL_ERROR "linker script ${script_path} doesn't exist")
|
||||||
|
@ -116,7 +122,7 @@ function (target_sitl name)
|
||||||
else()
|
else()
|
||||||
set(exe_filename ${CMAKE_BINARY_DIR}/${binary_name})
|
set(exe_filename ${CMAKE_BINARY_DIR}/${binary_name})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_target(${name} ALL
|
add_custom_target(${name} ALL
|
||||||
cmake -E env PATH="$ENV{PATH}"
|
cmake -E env PATH="$ENV{PATH}"
|
||||||
${CMAKE_OBJCOPY} $<TARGET_FILE:${exe_target}> ${exe_filename}
|
${CMAKE_OBJCOPY} $<TARGET_FILE:${exe_target}> ${exe_filename}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue