[CMake] how to add custom linker flags when creating shared libs
Alexander Neundorf
a.neundorf-work at gmx.net
Sun Apr 17 15:43:58 EDT 2005
Hi,
what's the best way to add custom options to the linker command when
creating shared libraries (plugins) ?
I have:
c++ -fPIC -shared -Wl,-soname,libkdevcustomproject.so -o
libkdevcustomproject.so "kdevcustomproject.dir/customprojectpart.o"
"kdevcustomproject.dir/custombuildoptionswidget.o"
"kdevcustomproject.dir/custommakeconfigwidget.o"
"kdevcustomproject.dir/custombuildoptionswidgetbase.o"
"kdevcustomproject.dir/custombuildoptionswidgetbase.moc.o"
"kdevcustomproject.dir/custommakeconfigwidgetbase.o"
"kdevcustomproject.dir/custommakeconfigwidgetbase.moc.o" -L/opt/kde/lib
-Wl,-rpath,/opt/kde/lib
and I'd like to have (taken from original KDE build using libtool):
g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -ansi -D_XOPEN_SOURCE=500
-D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -Wall -W
-Wpointer-arith -Wwrite-strings -O2 -Wformat-security
-Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common
-DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT
-DQT_NO_TRANSLATION -o libkdevcustomproject.la
-rpath /opt/kde/lib/kde3 -L/opt/kde/lib -L/usr/lib/qt/lib
-L/usr/X11R6/lib -avoid-version -module -no-undefined
-Wl,--no-undefined -Wl,--allow-shlib-undefined -R /opt/kde/lib
-R /opt/kde/lib -R /usr/lib/qt/lib -R /usr/X11R6/lib
customprojectpart.lo custombuildoptionswidget.lo
custommakeconfigwidget.lo custombuildoptionswidgetbase.lo
custommakeconfigwidgetbase.lo ../../lib/libkdevelop.la
../../buildtools/lib/widgets/libkdevbuildtoolswidgets.la
../../buildtools/lib/base/libkdevbuildbase.la
So what's the recommended way to add the stuff from "-avoid-version" to
"-R /..." to the cmake generated Makefiles ?
I tried setting:
SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS
${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -no-undefined)
but I didn't see any changes.
I tried to redefine
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER>
<CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS>
<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>
<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET>
-avoid-version -module -no-undefined <OBJECTS> <LINK_LIBRARIES>")
which worked, but feels quite "brute force". Is there a better way ?
Also c++ (g++) complained about the unknown option "-no-undefined"
although it works with the libtool command line which contains the same
option.
And a last question, what's the difference between a MODULE and a SHARED
lib ? Is MODULE intended to be used for plugins ?
Is there a way to get Makefiles which generate plugins without the "lib"
prefix in the filename ?
Bye
Alex
--
+++ GMX - Die erste Adresse für Mail, Message, More +++
1 GB Mailbox bereits in GMX FreeMail http://www.gmx.net/de/go/mail
More information about the CMake
mailing list