Best way to append "--no-undefined" to shared link flags?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Best way to append "--no-undefined" to shared link flags?

Robert Dailey-2
For only compilers that support it (I guess any clang/gcc compiler?),
I want my shared libs to link with "--no-undefined". What is the best
(most modern) way using CMake 3.9.0 and forward to do this? Is it
still to explicitly set CMAKE_SHARED_LINKER_FLAGS? How does this
impact using toolchain files and cross compiling? I don't want to wipe
out any existing flags, and I'm not sure of the exact syntax the
command line options need to follow.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Best way to append "--no-undefined" to shared link flags?

Robert Dailey-2
+CMake dev list

After googling I came up with this:


    set( CMAKE_SHARED_LINKER_FLAGS "${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). Does
--no-defined get specified by default for other platforms? Or is it
just Android that isn't getting it?

On Tue, Jul 18, 2017 at 3:38 PM, Robert Dailey <[hidden email]> wrote:
> For only compilers that support it (I guess any clang/gcc compiler?),
> I want my shared libs to link with "--no-undefined". What is the best
> (most modern) way using CMake 3.9.0 and forward to do this? Is it
> still to explicitly set CMAKE_SHARED_LINKER_FLAGS? How does this
> impact using toolchain files and cross compiling? I don't want to wipe
> out any existing flags, and I'm not sure of the exact syntax the
> command line options need to follow.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Brad King
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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...