[CMake] Suppressing -rdynamic in toolchain file

Gerhard Gappmeier gerhard.gappmeier at ascolab.com
Fri Apr 4 06:20:39 EDT 2014


Hi

I'm trying to use -ffunction-sections -fdata-sections as C_FLAGS and -Wl,--gc-
sections when cross-compiling for my ARM Linux target.

The gc-sections option does not work because CMake adds the "-rdynamic" flag 
which exports all symbols, also the unused ones.

I already figured out that I can suppress this be setting 
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

This work is the CMakeLists.txt files, but it does not work from a toolchain 
file.
But I want to configure this in my toolchain file, because this setting is 
specific for this single target. It is not an option add this as generic 
setting for all targets.

I also tried this:
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" CACHE INTERNAL ""  FORCE)

But this does not work either.

I believe this is a problem of the order how CMake files are processed. It 
looks like the toolchain file is processed first and then 
/usr/share/cmake/Modules/Platform/Linux-GNU.cmake
which overwrites the toolchain settings (just a guess)

BTW: I had similar problems with settings CMAKE_C_FLAGS, etc. from the 
toochain file.

# this does not work
SET(CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99 -fdata-sections -ffunction-
sections")

# with CACHE FORCE it does work
SET(CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99 -fdata-sections -ffunction-
sections" CACHE INTERNAL "c compiler flags" FORCE)

I'm not sure if this was intended. And for CMAKE_SHARED_LIBRARY_LINK_C_FLAGS 
this does not work either, as explained above.

I hope somebody can clarify how this options can be configured properly the 
CMake way.

PS: I'm using cmake version 2.8.12.2

-- 
mit freundlichen Grüßen / best regards

Gerhard Gappmeier
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-KeyId: 5AAC50C4
GPG-Fingerprint: 967A 15F1 2788 164D CCA3 6C46 07CD 6F82 5AAC 50C4

--
ascolab GmbH
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 • 91058 Erlangen • Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140404/71ed3b6e/attachment.sig>


More information about the CMake mailing list