Config.cmake.in: Conditionally serve static or shared library

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Config.cmake.in: Conditionally serve static or shared library

Kim Walisch
Hi,

My primesieve project builds as both a static and a shared library, hence
there are 2 targets in my main CMakeLists.txt:

1) libprimesieve (shared library)
2) libprimesieve-static

I am now trying to add support for find_package(Primesieve). Ideally I
would like that users can link against libprimesieve as follows:

find_package(Primesieve REQUIRED)
target_link_libraries(user_library Primesieve::Primesieve)

And I want Primesieve::Primesieve to be an alias for
Primesieve::libprimesieve if BUILD_SHARED_LIBS=ON (in the user's
CMakeLists.txt) and and alias for Primesieve::libprimesieve-static if
BUILD_SHARED_LIBS=OFF (or if it is not set).

Is this possible?
Do you know any library that has already implemented this?

Thanks,
Kim

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

ThePhD
I think you can use what's called an "Alias Library": https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries

if (BUILD_SHARED_LIBS)
     add_library(my_libprimesieve ALIAS libprimesieve)
else
     add_library(my_libprimesieve ALIAS libprimesieve-static)
endif(BUILD_SHARED_LIBS)

Then, set it properly to Primesieve::Primesieve and it should work.


On Wed, Feb 14, 2018 at 10:21 AM, Kim Walisch <[hidden email]> wrote:
Hi,

My primesieve project builds as both a static and a shared library, hence
there are 2 targets in my main CMakeLists.txt:

1) libprimesieve (shared library)
2) libprimesieve-static

I am now trying to add support for find_package(Primesieve). Ideally I
would like that users can link against libprimesieve as follows:

find_package(Primesieve REQUIRED)
target_link_libraries(user_library Primesieve::Primesieve)

And I want Primesieve::Primesieve to be an alias for
Primesieve::libprimesieve if BUILD_SHARED_LIBS=ON (in the user's
CMakeLists.txt) and and alias for Primesieve::libprimesieve-static if
BUILD_SHARED_LIBS=OFF (or if it is not set).

Is this possible?
Do you know any library that has already implemented this?

Thanks,
Kim

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

Robert Maynard
If you want to support consumers that are building shared and static
libraries themselves you can do this by using an import library with a
generator expression.
A simplified version of how do this, besides the import library can be found at:

https://github.com/robertmaynard/Sandbox/blob/master/CMakeInterfaceChangesLibrary/CMakeLists.txt

On Wed, Feb 14, 2018 at 11:34 AM, ThePhD <[hidden email]> wrote:

> I think you can use what's called an "Alias Library":
> https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries
>
> if (BUILD_SHARED_LIBS)
>      add_library(my_libprimesieve ALIAS libprimesieve)
> else
>      add_library(my_libprimesieve ALIAS libprimesieve-static)
> endif(BUILD_SHARED_LIBS)
>
> Then, set it properly to Primesieve::Primesieve and it should work.
>
>
> On Wed, Feb 14, 2018 at 10:21 AM, Kim Walisch <[hidden email]> wrote:
>>
>> Hi,
>>
>> My primesieve project builds as both a static and a shared library, hence
>> there are 2 targets in my main CMakeLists.txt:
>>
>> 1) libprimesieve (shared library)
>> 2) libprimesieve-static
>>
>> I am now trying to add support for find_package(Primesieve). Ideally I
>> would like that users can link against libprimesieve as follows:
>>
>> find_package(Primesieve REQUIRED)
>> target_link_libraries(user_library Primesieve::Primesieve)
>>
>> And I want Primesieve::Primesieve to be an alias for
>> Primesieve::libprimesieve if BUILD_SHARED_LIBS=ON (in the user's
>> CMakeLists.txt) and and alias for Primesieve::libprimesieve-static if
>> BUILD_SHARED_LIBS=OFF (or if it is not set).
>>
>> Is this possible?
>> Do you know any library that has already implemented this?
>>
>> Thanks,
>> Kim
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> https://cmake.org/mailman/listinfo/cmake
>>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

Kim Walisch
In reply to this post by ThePhD
CMake currently does not allow alias libraries for import targets:

$ cmake ..
CMake Error at /usr/local/lib/cmake/primesieve/PrimesieveConfig.cmake:7 (add_library):
  add_library cannot create ALIAS target "my_libprimesieve" because target
  "Primesieve::libprimesieve-static" is IMPORTED.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)

-- Configuring incomplete, errors occurred!

Kim


On Wed, Feb 14, 2018 at 5:34 PM, ThePhD <[hidden email]> wrote:
I think you can use what's called an "Alias Library": https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries

if (BUILD_SHARED_LIBS)
     add_library(my_libprimesieve ALIAS libprimesieve)
else
     add_library(my_libprimesieve ALIAS libprimesieve-static)
endif(BUILD_SHARED_LIBS)

Then, set it properly to Primesieve::Primesieve and it should work.


On Wed, Feb 14, 2018 at 10:21 AM, Kim Walisch <[hidden email]> wrote:
Hi,

My primesieve project builds as both a static and a shared library, hence
there are 2 targets in my main CMakeLists.txt:

1) libprimesieve (shared library)
2) libprimesieve-static

I am now trying to add support for find_package(Primesieve). Ideally I
would like that users can link against libprimesieve as follows:

find_package(Primesieve REQUIRED)
target_link_libraries(user_library Primesieve::Primesieve)

And I want Primesieve::Primesieve to be an alias for
Primesieve::libprimesieve if BUILD_SHARED_LIBS=ON (in the user's
CMakeLists.txt) and and alias for Primesieve::libprimesieve-static if
BUILD_SHARED_LIBS=OFF (or if it is not set).

Is this possible?
Do you know any library that has already implemented this?

Thanks,
Kim

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

Kim Walisch
Thanks, I got it working!

Unfortunately I could not make the generator expression work inside
PrimesieveConfig.cmake.in, here is the error message:

CMake Error:
  Error evaluating generator expression:
    $<BUILD_SHARED_LIBS:libprimesieve>
  Expression did not evaluate to a known generator expression

Note that in my main CMakeLists.txt the generator expression worked
fine. But I figured out I don't actually need the generator expression,
the following code inside my PrimesieveConfig.cmake.in does the trick:

if(BUILD_SHARED_LIBS)
        add_library(Primesieve::Primesieve INTERFACE IMPORTED)
        set_target_properties(Primesieve::Primesieve PROPERTIES
                INTERFACE_LINK_LIBRARIES "Primesieve::libprimesieve")
else()
        add_library(Primesieve::Primesieve INTERFACE IMPORTED)
        set_target_properties(Primesieve::Primesieve PROPERTIES 
                INTERFACE_LINK_LIBRARIES "Primesieve::libprimesieve-static")
endif()

This trick is also used by the c-ares library:

The trick was already discussed on the cmake mailing list before:

It would be really nice though if CMake would support library aliases for
import targets, then I could achieve the same using much nicer code.

Kim

On Wed, Feb 14, 2018 at 7:08 PM, Kim Walisch <[hidden email]> wrote:
CMake currently does not allow alias libraries for import targets:

$ cmake ..
CMake Error at /usr/local/lib/cmake/primesieve/PrimesieveConfig.cmake:7 (add_library):
  add_library cannot create ALIAS target "my_libprimesieve" because target
  "Primesieve::libprimesieve-static" is IMPORTED.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)

-- Configuring incomplete, errors occurred!

Kim


On Wed, Feb 14, 2018 at 5:34 PM, ThePhD <[hidden email]> wrote:
I think you can use what's called an "Alias Library": https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries

if (BUILD_SHARED_LIBS)
     add_library(my_libprimesieve ALIAS libprimesieve)
else
     add_library(my_libprimesieve ALIAS libprimesieve-static)
endif(BUILD_SHARED_LIBS)

Then, set it properly to Primesieve::Primesieve and it should work.


On Wed, Feb 14, 2018 at 10:21 AM, Kim Walisch <[hidden email]> wrote:
Hi,

My primesieve project builds as both a static and a shared library, hence
there are 2 targets in my main CMakeLists.txt:

1) libprimesieve (shared library)
2) libprimesieve-static

I am now trying to add support for find_package(Primesieve). Ideally I
would like that users can link against libprimesieve as follows:

find_package(Primesieve REQUIRED)
target_link_libraries(user_library Primesieve::Primesieve)

And I want Primesieve::Primesieve to be an alias for
Primesieve::libprimesieve if BUILD_SHARED_LIBS=ON (in the user's
CMakeLists.txt) and and alias for Primesieve::libprimesieve-static if
BUILD_SHARED_LIBS=OFF (or if it is not set).

Is this possible?
Do you know any library that has already implemented this?

Thanks,
Kim

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

Hendrik Sattler


Am 14. Februar 2018 21:47:24 MEZ schrieb Kim Walisch <[hidden email]>:

>Thanks, I got it working!
>
>Unfortunately I could not make the generator expression work inside
>PrimesieveConfig.cmake.in, here is the error message:
>
>CMake Error:
>  Error evaluating generator expression:
>    $<BUILD_SHARED_LIBS:libprimesieve>
>  Expression did not evaluate to a known generator expression
>
>Note that in my main CMakeLists.txt the generator expression worked
>fine. But I figured out I don't actually need the generator expression,
>the following code inside my PrimesieveConfig.cmake.in does the trick:
>
>if(BUILD_SHARED_LIBS)

This is IMHO using the wrong variable! This variable tells that I want to build MY libs as static, not that I want to link 3rdParty libs statically!
At least this is surprising behavior.

OTOH and luckily, there are still the real targets to choose from.

>This trick is also used by the c-ares library:

Others also doing this wrong does not make it any better.

HS

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

Kim Walisch
Thanks for your comment, I seem to have misunderstood the usage of BUILD_SHARED_LIBS. I will remove the hack to serve either a static or shared libprimesieve from my cmake config file.

Kim

On Feb 14, 2018 11:42 PM, "Hendrik Sattler" <[hidden email]> wrote:


Am 14. Februar 2018 21:47:24 MEZ schrieb Kim Walisch <[hidden email]>:
>Thanks, I got it working!
>
>Unfortunately I could not make the generator expression work inside
>PrimesieveConfig.cmake.in, here is the error message:
>
>CMake Error:
>  Error evaluating generator expression:
>    $<BUILD_SHARED_LIBS:libprimesieve>
>  Expression did not evaluate to a known generator expression
>
>Note that in my main CMakeLists.txt the generator expression worked
>fine. But I figured out I don't actually need the generator expression,
>the following code inside my PrimesieveConfig.cmake.in does the trick:
>
>if(BUILD_SHARED_LIBS)

This is IMHO using the wrong variable! This variable tells that I want to build MY libs as static, not that I want to link 3rdParty libs statically!
At least this is surprising behavior.

OTOH and luckily, there are still the real targets to choose from.

>This trick is also used by the c-ares library:

Others also doing this wrong does not make it any better.

HS

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Config.cmake.in: Conditionally serve static or shared library

Robert Maynard
In reply to this post by Kim Walisch
It would be really nice though if CMake would support library aliases for
import targets, then I could achieve the same using much nicer code.

3.11 will include support for aliasing import targets, as long as the
import target was marked with GLOBAL visibility.

On Wed, Feb 14, 2018 at 3:47 PM, Kim Walisch <[hidden email]> wrote:

> Thanks, I got it working!
>
> Unfortunately I could not make the generator expression work inside
> PrimesieveConfig.cmake.in, here is the error message:
>
> CMake Error:
>   Error evaluating generator expression:
>     $<BUILD_SHARED_LIBS:libprimesieve>
>   Expression did not evaluate to a known generator expression
>
> Note that in my main CMakeLists.txt the generator expression worked
> fine. But I figured out I don't actually need the generator expression,
> the following code inside my PrimesieveConfig.cmake.in does the trick:
>
> if(BUILD_SHARED_LIBS)
>         add_library(Primesieve::Primesieve INTERFACE IMPORTED)
>         set_target_properties(Primesieve::Primesieve PROPERTIES
>                 INTERFACE_LINK_LIBRARIES "Primesieve::libprimesieve")
> else()
>         add_library(Primesieve::Primesieve INTERFACE IMPORTED)
>         set_target_properties(Primesieve::Primesieve PROPERTIES
>                 INTERFACE_LINK_LIBRARIES "Primesieve::libprimesieve-static")
> endif()
>
> This trick is also used by the c-ares library:
> https://github.com/gjasny/c-ares/blob/fec405a420597180244e6c66912f09ae84b31123/c-ares-config.cmake.in
>
> The trick was already discussed on the cmake mailing list before:
> https://cmake.org/pipermail/cmake-developers/2017-June/030115.html
>
> It would be really nice though if CMake would support library aliases for
> import targets, then I could achieve the same using much nicer code.
>
> Kim
>
> On Wed, Feb 14, 2018 at 7:08 PM, Kim Walisch <[hidden email]> wrote:
>>
>> CMake currently does not allow alias libraries for import targets:
>>
>> $ cmake ..
>> CMake Error at /usr/local/lib/cmake/primesieve/PrimesieveConfig.cmake:7
>> (add_library):
>>   add_library cannot create ALIAS target "my_libprimesieve" because target
>>   "Primesieve::libprimesieve-static" is IMPORTED.
>> Call Stack (most recent call first):
>>   CMakeLists.txt:6 (find_package)
>>
>> -- Configuring incomplete, errors occurred!
>>
>> Kim
>>
>>
>> On Wed, Feb 14, 2018 at 5:34 PM, ThePhD <[hidden email]> wrote:
>>>
>>> I think you can use what's called an "Alias Library":
>>> https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries
>>>
>>> if (BUILD_SHARED_LIBS)
>>>      add_library(my_libprimesieve ALIAS libprimesieve)
>>> else
>>>      add_library(my_libprimesieve ALIAS libprimesieve-static)
>>> endif(BUILD_SHARED_LIBS)
>>>
>>> Then, set it properly to Primesieve::Primesieve and it should work.
>>>
>>>
>>> On Wed, Feb 14, 2018 at 10:21 AM, Kim Walisch <[hidden email]>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> My primesieve project builds as both a static and a shared library,
>>>> hence
>>>> there are 2 targets in my main CMakeLists.txt:
>>>>
>>>> 1) libprimesieve (shared library)
>>>> 2) libprimesieve-static
>>>>
>>>> I am now trying to add support for find_package(Primesieve). Ideally I
>>>> would like that users can link against libprimesieve as follows:
>>>>
>>>> find_package(Primesieve REQUIRED)
>>>> target_link_libraries(user_library Primesieve::Primesieve)
>>>>
>>>> And I want Primesieve::Primesieve to be an alias for
>>>> Primesieve::libprimesieve if BUILD_SHARED_LIBS=ON (in the user's
>>>> CMakeLists.txt) and and alias for Primesieve::libprimesieve-static if
>>>> BUILD_SHARED_LIBS=OFF (or if it is not set).
>>>>
>>>> Is this possible?
>>>> Do you know any library that has already implemented this?
>>>>
>>>> Thanks,
>>>> Kim
>>>>
>>>> --
>>>>
>>>> Powered by www.kitware.com
>>>>
>>>> Please keep messages on-topic and check the CMake FAQ at:
>>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>>
>>>> Kitware offers various services to support the CMake community. For more
>>>> information on each offering, please visit:
>>>>
>>>> CMake Support: http://cmake.org/cmake/help/support.html
>>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> https://cmake.org/mailman/listinfo/cmake
>>>>
>>>
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Kitware offers various services to support the CMake community. For more
>>> information on each offering, please visit:
>>>
>>> CMake Support: http://cmake.org/cmake/help/support.html
>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> https://cmake.org/mailman/listinfo/cmake
>>>
>>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake