diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-05-12 15:09:50 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-05-12 15:09:50 +0200 |
commit | a88242c66c312e3a19c5ad1db9374fd4e86bbae6 (patch) | |
tree | 2e504e58ff773191c66461b2572298500177237c /functions.cmake | |
parent | e8a424601463d91fc4e4f7dce4bd9ff57b87dcb8 (diff) |
Enable more fine grained control of linker options for shared libraries.
Diffstat (limited to 'functions.cmake')
-rw-r--r-- | functions.cmake | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/functions.cmake b/functions.cmake index 9fa1f326e0a..fe59cc3aaa9 100644 --- a/functions.cmake +++ b/functions.cmake @@ -183,7 +183,7 @@ endmacro() function(vespa_add_library TARGET) cmake_parse_arguments(ARG - "STATIC;OBJECT;INTERFACE;TEST" + "STATIC;OBJECT;INTERFACE;TEST;ALLOW_UNRESOLVED_SYMBOLS" "INSTALL;OUTPUT_NAME" "DEPENDS;EXTERNAL_DEPENDS;AFTER;SOURCES" ${ARGN}) @@ -227,6 +227,10 @@ function(vespa_add_library TARGET) set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${ARG_OUTPUT_NAME}) endif() + if(NOT ARG_OBJECT AND NOT ARG_STATIC AND NOT ARG_INTERFACE AND NOT ARG_ALLOW_UNRESOLVED_SYMBOLS AND DEFINED VESPA_DISALLOW_UNRESOLVED_SYMBOLS_IN_SHARED_LIBRARIES) + __add_private_target_link_option(${TARGET} ${VESPA_DISALLOW_UNRESOLVED_SYMBOLS_IN_SHARED_LIBRARIES}) + endif() + __add_target_to_module(${TARGET}) __export_include_directories(${TARGET}) if(VESPA_ADD_IMPLICIT_OBJECT_LIBRARY) @@ -759,3 +763,17 @@ function(vespa_suppress_warnings_for_protobuf_sources) set_source_files_properties(${ARG_SOURCES} PROPERTIES COMPILE_FLAGS "-Wno-array-bounds -Wno-suggest-override -Wno-inline ${VESPA_DISABLE_UNUSED_WARNING}") endif() endfunction() + +function(__add_private_target_link_option TARGET TARGET_LINK_OPTION) + if(COMMAND target_link_options) + target_link_options(${TARGET} PRIVATE ${TARGET_LINK_OPTION}) + else() + get_target_property(TARGET_LINK_FLAGS ${TARGET} LINK_FLAGS) + if (NOT DEFINED TARGET_LINK_FLAGS OR ${TARGET_LINK_FLAGS} STREQUAL "" OR ${TARGET_LINK_FLAGS} STREQUAL "TARGET_LINK_FLAGS-NOTFOUND") + set(TARGET_LINK_FLAGS ${TARGET_LINK_OPTION}) + else() + set(TARGET_LINK_FLAGS "${TARGET_LINK_FLAGS} ${TARGET_LINK_OPTION}") + endif() + set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "${TARGET_LINK_FLAGS}") + endif() +endfunction() |