[CMake] Clarification around "target_link_libraries"

SF Markus Elfring elfring at users.sourceforge.net
Thu Sep 12 09:00:25 EDT 2013


Hello,

CMake supports also building of static and shared libraries together.
http://cmake.org/cmake/help/v2.8.11/cmake.html#command:add_library

I get the impression from the tutorial that a needed library can be passed as a
target name for the macro "target_link_libraries".
http://cmake.org/cmake/help/cmake_tutorial.html#s2

But I get a different experience.
http://cmake.org/cmake/help/v2.8.11/cmake.html#command:target_link_libraries

Now I try to give a build configurator the choice with which library type some
executable files should be linked. It seems that I need to construct
corresponding file names instead of target names.

I adjust also a property like "OUTPUT_NAME" already.
http://cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F

Is it possible to determine the final path and complete file name for the
generated library in my build environment?
Can I avoid to query properties like "PREFIX" and "SUFFIX" by the macro
"get_target_property" separately?

How should I deal with special cases that might be better supported by a tool
like "Libtool"?
http://www.gnu.org/software/libtool/manual/html_node/Issues.html

Regards,
Markus


More information about the CMake mailing list