From 47c3d4d7cd85b9d05806f110668c89080f0aba07 Mon Sep 17 00:00:00 2001 From: James Benton Date: Fri, 15 Jun 2018 14:56:38 +0100 Subject: [PATCH] cmake: Use target_link_libraries even for --whole-archive libraries. So cmake picks up the dependency naturally, I didn't know this was possible before... --- share/wut.cmake | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/share/wut.cmake b/share/wut.cmake index b4a6dbc..60c2ed3 100644 --- a/share/wut.cmake +++ b/share/wut.cmake @@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.2) macro(wut_enable_newlib target) get_property(ENABLED_NEWLIB TARGET ${target} PROPERTY WUT_ENABLE_NEWLIB) if(NOT DEFINED ENABLED_NEWLIB) - set_property(TARGET ${target} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--whole-archive -lwutnewlib -Wl,--no-whole-archive") + target_link_libraries(${target} + -Wl,--whole-archive wutnewlib -Wl,--no-whole-archive) set_target_properties(${target} PROPERTIES WUT_ENABLE_NEWLIB 1) endif() @@ -18,14 +18,12 @@ macro(wut_enable_stdcpp target) wut_enable_newlib(${target}) target_link_libraries(${target} - stdc++) + stdc++ + -Wl,--whole-archive wutstdc++ -Wl,--no-whole-archive) set_property(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS "-std=c++17") - set_property(TARGET ${target} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--whole-archive -lwutstdc++ -Wl,--no-whole-archive") - set_target_properties(${target} PROPERTIES WUT_ENABLE_STDCPP 1) endif() endmacro() @@ -34,8 +32,8 @@ endmacro() macro(wut_enable_devoptab_sd target) get_property(ENABLED_DEVOPTAB_SD TARGET ${target} PROPERTY WUT_ENABLE_DEVOPTAB_SD) if(NOT DEFINED ENABLED_DEVOPTAB_SD) - set_property(TARGET ${target} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--whole-archive -lwutdevoptab_sd -Wl,--no-whole-archive") + target_link_libraries(${target} + -Wl,--whole-archive wutdevoptab_sd -Wl,--no-whole-archive) set_target_properties(${target} PROPERTIES WUT_ENABLE_DEVOPTAB_SD 1) endif() @@ -45,8 +43,8 @@ endmacro() macro(wut_default_malloc target) get_property(ENABLED_DEFAULT_MALLOC TARGET ${target} PROPERTY WUT_DEFAULT_MALLOC) if(NOT DEFINED ENABLED_DEFAULT_MALLOC) - set_property(TARGET ${target} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--whole-archive -lwutmalloc -Wl,--no-whole-archive") + target_link_libraries(${target} + -Wl,--whole-archive wutmalloc -Wl,--no-whole-archive) set_target_properties(${target} PROPERTIES WUT_DEFAULT_MALLOC 1) endif()