[CMake] Linking to a library with a "-"

David Doria daviddoria at gmail.com
Wed Apr 15 11:09:43 EDT 2009


I'm using Fedora 10. The KDevelop3 and normal makefile generator produce the
same result.  CMake version: ccmake version 2.6-patch 3

My CMakeLists.txt file is:
--------------------------------------------------------
cmake_minimum_required(VERSION 2.6)

Project(BoostProgramOptions)

INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} /home/doriad/src/boost)

LINK_DIRECTORIES(${LINK_DIRECTORIES} /home/doriad/bin/boost/lib)

ADD_EXECUTABLE(BoostProgramOptions BoostProgramOptions.cpp)
TARGET_LINK_LIBRARIES(BoostProgramOptions boost_program_options)

ADD_EXECUTABLE(MultipleLists MultipleLists.cpp)
TARGET_LINK_LIBRARIES(MultipleLists boost_program_options-mt)
--------------------------------------------------------

and the link.txt that is produced is:

--------------------------------------------------------
/usr/lib/ccache/c++     -fPIC
CMakeFiles/BoostProgramOptions.dir/BoostProgramOpt
ions.cpp.o  -o BoostProgramOptions -rdynamic -L/home/doriad/bin/boost/lib
-lboos
t_program_options -Wl,-rpath,/home/doriad/bin/boost/lib
--------------------------------------------------------

Thanks,

David


On Wed, Apr 15, 2009 at 9:12 AM, Brad King <brad.king at kitware.com> wrote:

> David Doria wrote:
>
>> When I add a line like this:
>>
>> TARGET_LINK_LIBRARIES(MyProject boost_program_options-mt)
>>
>> in my link.txt file, -lboost_program_options gets produced instead
>> (without the "-mt"), and therefore the library cannot be found. I've been
>> creating a symlink with the name without the -mt and that works, but it
>> seems silly to have to do that. Is there a way to link to a library name
>> which contains a "-"?
>>
>
> I cannot reproduce this.  I get "-lboost_program_options-mt".
>
> What version of CMake?
> What platform?
> What generator?
>
> -Brad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090415/e6d26340/attachment-0001.htm>


More information about the CMake mailing list