[CMake] Cannot determine link language for target

Brad King brad.king at kitware.com
Fri Jul 28 11:44:56 EDT 2006


Marc-André Laverdière wrote:
> Hello CMakers,
> 
> I'm really a n00b...
> 
> So, I am building each subdirectory into a static library and I want to
> put all those libraries into a nice big dynamic library. The big dynamic
> library is the objective here.
> 
> I'm doing it as such:
> ADD_LIBRARY(XYZ SHARED
> ${CMAKE_CURRENT_SOURCE_DIR}/stdio/libstdio.a
> ${CMAKE_CURRENT_SOURCE_DIR}/stdlib/libstdlib.a
> ${CMAKE_CURRENT_SOURCE_DIR}/string/libstring.a
> ${CMAKE_CURRENT_SOURCE_DIR}/time/libtime.a
> ${CMAKE_CURRENT_SOURCE_DIR}/wchar/libwchar.a)
> 
> Yet, I obtain the following, when I run rebuild_cache:
> CMake Error: Cannot determine link language for target XYZ
> 
> What am I doing wrong? How should I proceed to build that dynamic library?

CMake needs to know what programming language is used within the target.
 This determines whether the C or C++ compiler (or Fortran, etc.) is
used to link the shared library.  Normally the language is computed from
the language of the source files listed in the target.  Since you don't
list any source files CMake cannot deduce the language.  You can set it
explicitly by setting the LINKER_LANGUAGE target property:

SET_TARGET_PROPERTIES(XYZ PROPERTIES LINKER_LANGUAGE C)

Linking static libraries into a shared library is generally a dangerous
thing to do anyway.  What are you trying to accomplish?  Why can't you
just list all the source files from those subdirectories in the XYZ target?

-Brad


More information about the CMake mailing list