I'm trying to cross-build a piece of SW over Android and iOS using CMake. Android project uses GNU ld, while iOS uses lld. I need to add linker options for stripping dead code from linked libraries to both toolchains. I identified the way to achieve it adding on GNU ld, the --gc-sections linker options, while on lld adding the -dead_strip linker options. So, my question is:
Is there an alternative way to check cross-compiling platform, like below?
if(CMAKE_SYSTEM_NAME STREQUAL Android)
target_link_options(GarminAis PRIVATE LINKER:--gc-sections)
elseif(CMAKE_SYSTEM_NAME STREQUAL APPLE)
target_link_options(GarminAis PRIVATE LINKER:-dead_strip)
endif()
I would strongly prefer an unified approach.
Thanks in advance for any help