CMAKE: Move flags to general location, disable sections for linker on Mac OS

This commit is contained in:
Lorenz Meier 2015-09-12 11:25:48 +02:00
parent ceb7204590
commit 4bc44841f6
3 changed files with 32 additions and 12 deletions

View File

@ -498,6 +498,7 @@ function(px4_add_common_flags)
-Werror=reorder
-Werror=uninitialized
-Werror=init-self
-Wno-unused-const-variable
#-Wcast-qual - generates spurious noreturn attribute warnings,
# try again later
#-Wconversion - would be nice, but too many "risky-but-safe"
@ -508,7 +509,6 @@ function(px4_add_common_flags)
if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
list(APPEND warnings
-Wno-unused-const-variable
-Werror=unused-but-set-variable
-Wformat=1
#-Wlogical-op # very verbose due to eigen
@ -618,10 +618,16 @@ function(px4_add_common_flags)
-DCONFIG_ARCH_BOARD_${board_config}
)
set(added_exe_link_flags
-Wl,--warn-common
-Wl,--gc-sections
)
if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(added_exe_link_flags
-Wl,--warn-common
-Wl,--gc-sections
)
else()
set(added_exe_link_flags
-Wl,--warn-common
)
endif()
# output
foreach(var ${inout_vars})

View File

@ -1,5 +1,5 @@
# compiler tools
foreach(tool objcopy nm ld)
foreach(tool nm ld)
string(TOUPPER ${tool} TOOL)
find_program(${TOOL} ${tool})
if(NOT ${TOOL})

View File

@ -13,11 +13,25 @@ add_executable(mainapp
apps.h
)
target_link_libraries(mainapp
-Wl,--start-group
${module_libraries}
pthread m rt
-Wl,--end-group
)
if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
target_link_libraries(mainapp
-Wl,--start-group
${module_libraries}
pthread m rt
-Wl,--end-group
)
else()
if (APPLE)
target_link_libraries(mainapp
${module_libraries}
pthread m
)
else()
target_link_libraries(mainapp
${module_libraries}
pthread m rt
)
endif()
endif()
# vim: set noet ft=cmake fenc=utf-8 ff=unix :