[cmake-developers] Best way to append "--no-undefined" to shared link flags?

Brad King brad.king at kitware.com
Thu Jul 20 09:59:46 EDT 2017


On 07/18/2017 04:52 PM, Robert Dailey wrote:
>     set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}
> -Wl,--no-undefined" )

That's fine, but you can use `string(APPEND)` to shorten the code:

  string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--no-undefined")

> After talking more with the NDK devs on github though, they seem to
> indicate this should happen by default (or at least, it does with the
> CMake that ships with the NDK according to Dan Albert).

I don't think the NDK build system itself did that back when we first
developed CMake's NDK support.  It looks like their NDK-provided
toolchain does do it by default, but with an option to turn it off.

> Does --no-defined get specified by default for other platforms?
> Or is it just Android that isn't getting it?

CMake doesn't add --no-undefined by default on any platform.

-Brad



More information about the cmake-developers mailing list