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

Robert Maynard robert.maynard at kitware.com
Tue Apr 11 14:50:26 EDT 2017


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 at web.de> 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


More information about the CMake mailing list