Directing cmake to link against shared object with debug postfix (_d)

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

Directing cmake to link against shared object with debug postfix (_d)

Olumide
Dear List,

I've got a cmake project that pretty much looks like this:

###############################################################

cmake_minimum_required(VERSION 3.0)

SET(CMAKE_DEBUG_POSTFIX "_d")

include_directories(../TransfunctionerProject)
include_directories(../TransmogrifierProject)

set(Libraries
     ContinuumTransfunctioner
     Transmogrifier
)

set(SourceFiles
     Wrapper.cpp
     Logger.cpp
)

add_library(Frobnigator SHARED ${SourceFiles})
add_library(FrobnigatorStatic STATIC ${SourceFiles})
set_target_properties(FrobnigatorStatic PROPERTIES OUTPUT_NAME Frobnigator)
target_link_libraries(Frobnigator ${Libraries})

###############################################################

Where ContinuumTransfunctioner and Transmogrifier projects include the
debug postfix directive SET(CMAKE_DEBUG_POSTFIX "_d") so that
libContinuumTransfunctioner_d.so and libTransmogrifier_d.so both exist.

The problem is that the current project appears to be linking against
the static library without the _d suffix and complains:

/usr/bin/ld: cannot find -lContinuumTransfunctioner

How can I direct cmake to link against shared object with debug postfix (_d)

Thanks

- Olumide




--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Robert Maynard
CMAKE_DEBUG_POSTFIX is only used by CMake when it builds libraries to
determine what exact file name the executable/library should have.

In your case you will need to do something like:

set(Libraries
    ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
    Transmogrifier${CMAKE_DEBUG_POSTFIX}
)

Another option would to generate proper import targets for your
libraries, as that would allow you to specify different paths for the
release and debug components.

On Tue, Apr 11, 2017 at 8:45 AM, Olumide <[hidden email]> wrote:

> Dear List,
>
> I've got a cmake project that pretty much looks like this:
>
> ###############################################################
>
> cmake_minimum_required(VERSION 3.0)
>
> SET(CMAKE_DEBUG_POSTFIX "_d")
>
> include_directories(../TransfunctionerProject)
> include_directories(../TransmogrifierProject)
>
> set(Libraries
>     ContinuumTransfunctioner
>     Transmogrifier
> )
>
> set(SourceFiles
>     Wrapper.cpp
>     Logger.cpp
> )
>
> add_library(Frobnigator SHARED ${SourceFiles})
> add_library(FrobnigatorStatic STATIC ${SourceFiles})
> set_target_properties(FrobnigatorStatic PROPERTIES OUTPUT_NAME Frobnigator)
> target_link_libraries(Frobnigator ${Libraries})
>
> ###############################################################
>
> Where ContinuumTransfunctioner and Transmogrifier projects include the debug
> postfix directive SET(CMAKE_DEBUG_POSTFIX "_d") so that
> libContinuumTransfunctioner_d.so and libTransmogrifier_d.so both exist.
>
> The problem is that the current project appears to be linking against the
> static library without the _d suffix and complains:
>
> /usr/bin/ld: cannot find -lContinuumTransfunctioner
>
> How can I direct cmake to link against shared object with debug postfix (_d)
>
> Thanks
>
> - Olumide
>
>
>
>
> --
>
> 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:
> http://public.kitware.com/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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Olumide
Thanks Robert.

However it appears that the release build is linking against
ContinuumTransfunctioner_d and Transmogrifier_d.

How can I omit the _d suffix in the release build.

Regards,

- Olumide

On 11/04/2017 19:50, Robert Maynard wrote:

> CMAKE_DEBUG_POSTFIX is only used by CMake when it builds libraries to
> determine what exact file name the executable/library should have.
>
> In your case you will need to do something like:
>
> set(Libraries
>     ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>     Transmogrifier${CMAKE_DEBUG_POSTFIX}
> )
>
> Another option would to generate proper import targets for your
> libraries, as that would allow you to specify different paths for the
> release and debug components.
>
> On Tue, Apr 11, 2017 at 8:45 AM, Olumide <50295-S0/[hidden email]> wrote:
>> Dear List,
>>
>> I've got a cmake project that pretty much looks like this:
>>
>> ###############################################################
>>
>> cmake_minimum_required(VERSION 3.0)
>>
>> SET(CMAKE_DEBUG_POSTFIX "_d")
>>
>> include_directories(../TransfunctionerProject)
>> include_directories(../TransmogrifierProject)
>>
>> set(Libraries
>>     ContinuumTransfunctioner
>>     Transmogrifier
>> )
>>
>> set(SourceFiles
>>     Wrapper.cpp
>>     Logger.cpp
>> )
>>
>> add_library(Frobnigator SHARED ${SourceFiles})
>> add_library(FrobnigatorStatic STATIC ${SourceFiles})
>> set_target_properties(FrobnigatorStatic PROPERTIES OUTPUT_NAME Frobnigator)
>> target_link_libraries(Frobnigator ${Libraries})
>>
>> ###############################################################
>>
>> Where ContinuumTransfunctioner and Transmogrifier projects include the debug
>> postfix directive SET(CMAKE_DEBUG_POSTFIX "_d") so that
>> libContinuumTransfunctioner_d.so and libTransmogrifier_d.so both exist.
>>
>> The problem is that the current project appears to be linking against the
>> static library without the _d suffix and complains:
>>
>> /usr/bin/ld: cannot find -lContinuumTransfunctioner
>>
>> How can I direct cmake to link against shared object with debug postfix (_d)
>>
>> Thanks
>>
>> - Olumide
>>
>>
>>
>>
>> --
>>
>> 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:
>> http://public.kitware.com/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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Volker Enderlein
Am 12/04/2017 um 13:28 schrieb Olumide:
> set(Libraries
>     ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>     Transmogrifier${CMAKE_DEBUG_POSTFIX}
> )
Hi,

you could add the configuration for a single library dependency.

target_link_libraries(your_target

debug ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}

optimized ContinuumTransfunctioner

debug Transmogrifier${CMAKE_DEBUG_POSTFIX}

optimized Transmogrifier

)

you could also put that into a variable and reference that later

set(Libraries

debug ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}

optimized ContinuumTransfunctioner

debug Transmogrifier${CMAKE_DEBUG_POSTFIX}

optimized Transmogrifier

)

target_link_libraries(your_target ${Libraries})


Hope that helps, Cheers, Volker


--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Olumide
Thanks Volker.

I wonder if its possible to do go with the Robert's original suggestion:

set(Libraries
     ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
     Transmogrifier${CMAKE_DEBUG_POSTFIX}
)

But set on debug build set CMAKE_DEBUG_POSTFIX. For example:

## Does not work
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
        SET(CMAKE_DEBUG_POSTFIX "_d")
endif

if (CMAKE_BUILD_TYPE STREQUAL "Release")
        SET(CMAKE_DEBUG_POSTFIX "")
endif

Regards,

- Olumide


On 12/04/2017 12:56, Volker Enderlein wrote:

> Am 12/04/2017 um 13:28 schrieb Olumide:
>> set(Libraries
>>     ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>>     Transmogrifier${CMAKE_DEBUG_POSTFIX}
>> )
> Hi,
>
> you could add the configuration for a single library dependency.
>
> target_link_libraries(your_target
>
> debug ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>
> optimized ContinuumTransfunctioner
>
> debug Transmogrifier${CMAKE_DEBUG_POSTFIX}
>
> optimized Transmogrifier
>
> )
>
> you could also put that into a variable and reference that later
>
> set(Libraries
>
> debug ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>
> optimized ContinuumTransfunctioner
>
> debug Transmogrifier${CMAKE_DEBUG_POSTFIX}
>
> optimized Transmogrifier
>
> )
>
> target_link_libraries(your_target ${Libraries})
>
>
> Hope that helps, Cheers, Volker
>
>

--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Nils Gladitz-2
On 04/12/2017 04:49 PM, Olumide wrote:

> set(Libraries
>     ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>     Transmogrifier${CMAKE_DEBUG_POSTFIX}
> )

Perhaps try with generator expressions:

set(Libraries
     ContinuumTransfunctioner$<$<CONFIG:Debug>:d>
     Transmogrifier$<$<CONFIG:Debug>:d>
)

Maybe alternatively create a find module and populate imported targets
with the required information:
https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules

Or assuming ContinuumTransfunctioner and Transmogrifier are created by
an independent CMake project under your control look into target exports
and package configuration files:
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages

Nils
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Olumide
Thanks Nils.

BTW, shouldn't that be
        ContinuumTransfunctioner$<$<CONFIG:Debug>:_d>
        Transmogrifier$<$<CONFIG:Debug>:_d>


Thanks,

- Olumide

On 12/04/2017 15:56, Nils Gladitz wrote:

> On 04/12/2017 04:49 PM, Olumide wrote:
>
>> set(Libraries
>>     ContinuumTransfunctioner${CMAKE_DEBUG_POSTFIX}
>>     Transmogrifier${CMAKE_DEBUG_POSTFIX}
>> )
>
> Perhaps try with generator expressions:
>
> set(Libraries
>     ContinuumTransfunctioner$<$<CONFIG:Debug>:d>
>     Transmogrifier$<$<CONFIG:Debug>:d>
> )
>
> Maybe alternatively create a find module and populate imported targets
> with the required information:
> https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules
>
>
> Or assuming ContinuumTransfunctioner and Transmogrifier are created by
> an independent CMake project under your control look into target exports
> and package configuration files:
> https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
>
>
> Nils

--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Directing cmake to link against shared object with debug postfix (_d)

Nils Gladitz-2
On 12.04.2017 17:48, Olumide wrote:
> Thanks Nils.
>
> BTW, shouldn't that be
>     ContinuumTransfunctioner$<$<CONFIG:Debug>:_d>
>     Transmogrifier$<$<CONFIG:Debug>:_d>

Ah right given your specific case, yes.

Nils
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Loading...