[CMake] [CMake BUG] CMake (2.8.12.2) adding extraneous libraries at the end of the link command
Brad King
brad.king at kitware.com
Tue Apr 15 08:42:18 EDT 2014
On 04/14/2014 05:30 PM, Zaak Beekman wrote:
> The problem is that the link step adds spurious (intel) libraries
> when linking the executable.
This is related to the mixed-language support, usually used for linking
C++/Fortran together. When computing a link line CMake looks at all
the languages that it knows have been compiled into object files
involved in the link. It wants to ensure that the libraries normally
added by the compiler for each language will appear. Whatever lang's
compiler is used to drive the link has a known set of libraries. All
other libraries implicitly used by the other languages will be added
to the link line explicitly.
Look at the CMakeFiles/<cmake-version>/CMake(C|Fortran)Compiler.cmake
files in the build tree. There should be lines that set variables
like CMAKE_C_IMPLICIT_LINK_LIBRARIES. Also look at the log file
CMakeFiles/CMakeOutput.log for content following lines like
Parsed C implicit link information from above output
and
Parsed Fortran implicit link information from above output
That has verbose information about how CMake detects these libraries.
Likely the detection is being done using executables that are not
linked statically. Since CMake has no first-class support for
specifying that an executable should be linked statically this use
case was not considered previously for mixed-language support.
If after enabling languages you do
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "")
the extra libraries should no longer appear.
-Brad
More information about the CMake
mailing list