[CMake] TARGET_SUPPORTS_SHARED_LIBS not set

Nico Schlömer nico.schloemer at gmail.com
Tue Sep 11 12:17:51 EDT 2012


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?

--Nico



On Tue, Sep 11, 2012 at 11:39 AM, Petr Kmoch <petr.kmoch at gmail.com> wrote:
> Hi Nico.
>
> I don't know, but I would assume this (just like a plethora of other
> internals) is set up by a project() call. The rule of thumb is to call
> project() a soon as you can.
>
> Petr
>
> On Tue, Sep 11, 2012 at 11:26 AM, Nico Schlömer <nico.schloemer at gmail.com>
> wrote:
>>
>> Hi all,
>>
>> I'm having problems linking shared libraries on Ubuntu 12.10 beta1
>> here (shipping with CMake 2.8.9), and found that this is related to
>> TARGET_SUPPORTS_SHARED_LIBS not being set. This
>>
>> CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
>> GET_PROPERTY(test GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
>> MESSAGE("<" ${test} ">")
>>
>> prints "<>".
>> Do I need to manually set a target, or does a later command, e.g. the
>> instantiation of a project set this?
>>
>> Cheers,
>> Nico
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>
>


More information about the CMake mailing list