[CMake] CMake custom link executable command, how to extract linker options?

Roman random.romik at gmail.com
Sat May 21 20:19:28 EDT 2016


Hello,

I want to use custom executable linking command in my CMake script, namely
Synopsys VCS. VCS is a wrapper over GCC, but it uses special syntax for
passing LD options:

vcs -LDFLAGS "<LINK_FLAGS>" <LINK_LIBRARIES> <OBJECTS>

I've tried to play with CMAKE_CXX_LINK_EXECUTABLE:

set(CMAKE_CXX_LINK_EXECUTABLE "echo CXXFLAGS: <CMAKE_CXX_LINK_FLAGS>
LINK_FLAGS: <LINKER_FLAGS> LINK_LIBRARIES: <LINK_LIBRARIES> OBJECTS:
<OBJECTS> ")

When I build project i got:

CXXFLAGS:
LINK_FLAGS:
LINK_LIBRARIES: -rdynamic ../slib/libslib.a ../dlib/libdlib.so
-Wl,-rpath,/home/ripopov/proj_cmake/build/dlib
OBJECTS: CMakeFiles/sim.dir/sc_main.cpp.o

So all linker flags together with libraries are in <LINK_LIBRARIES>.  And
<LINK_FLAGS> is empty.

Why it works this way? And how can I extract linker flags from
LINK_LIBRARIES?

I've posted same question on stackoverflow:
http://stackoverflow.com/questions/37368434/cmake-custom-link-executable-command-how-to-extract-linker-options


-- 
Best regards,
Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160521/3dc4b811/attachment.html>


More information about the CMake mailing list