[CMake] Cannot determine link language for target
Marc-André Laverdière
ma_laver at ciise.concordia.ca
Fri Jul 28 13:48:32 EDT 2006
Dear Brad, William,
Thanks for the quick reply.
SET_TARGET_PROPERTIES did the trick.
I don't know enough of industrial UNIX programming to know why what I
did was a bad thing. I'll need a lecture :)
Orginally, we were compiling each subdir in a .a file so that we could
compile unit tests and link them only with the .a file(s) needed. At
that stage, we didn't go much farther than some test programs that used
a module or two, so we didn't need to put all things together in a big .so.
I figured that keeping this in CMake would keep things lighter. That
being said, we can also have the tests dynamically linking to the .so
I'm making those modifications. However, I'd like to avoid having to put
the whole subdirectory hierarchy before each file... that'd make things
heavy (especially since one thing I'm adding soon is gonna have things 3
levels down...). Is there a way to do that outside of the
non-reccomended AUX_SOURCE_DIRECTORY?
Regards,
--
Marc-André LAVERDIÈRE, B. Eng., M. A. Sc. (in progress)
Research Assitant - Computer Security Laboratory
CIISE, Université Concordia University, Montréal, Québec, Canada
www.ciise.concordia.ca
/"\
\ / ASCII Ribbon Campaign
X against HTML e-mail
/ \
"Perseverance must finish its work so that you may be mature and
complete, not lacking anything." -James 1:4
Brad King wrote:
> 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