[CMake] TARGET_SUPPORTS_SHARED_LIBS not set

Rolf Eike Beer eike at sf-mail.de
Tue Sep 11 13:44:44 EDT 2012


Nico Schlömer wrote:
> Indeed, that gets set up by the PROJECT() call.
> 
> Now, this creates a little bit of a problem here.
> The main CMakeLists.txt looks something like
> 
> =============== *snip* ===============
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
> 
> FIND_PACKAGE(Foobar REQUIRED)
> 
> # Set compilers before the PROJECT is declared.
> SET(CMAKE_CXX_COMPILER ${Foobar_CXX_COMPILER})
> 
> PROJECT(MyProject CXX)
> [...]
> =============== *snap* ===============
> 
> Evidently, FIND_PACKAGE() must be called before PROJECT(),
> specifically before TARGET_SUPPORTS_SHARED_LIBS is set.
> However, the Foobar package not only defines some compiler variables,
> but also includes libraries like
> 
> ADD_LIBRARY(barfoo SHARED IMPORTED)
> 
> Those ADD_LIBRARY(... SHARED ...) calls however check for
> TARGET_SUPPORTS_SHARED_LIBS and choke if it is not defined.
> 
> What could be identified as the bug here?

Fiddling with the compilers inside the CMakeLists.txt. Don't do it. Either use 
CC and CXX environment variables to set them up when calling CMake for the 
first time or use a toolchain file if you want to set up a cross compiler that 
needs some special arguments. But don't try changing the compilers from inside 
the CMakeLists.txt. As you already found out this is only a request for 
trouble which was promptly served.

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120911/bd226bc6/attachment.pgp>


More information about the CMake mailing list