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

Mike Jackson mike.jackson at bluequartz.net
Wed Apr 15 11:41:12 EDT 2009


Any particular reason you are doing the compiling of the Boost Program
Options library instead of letting boost build boost? There is
experimental support for building Boost with CMake in the head SVN
Boost repository if you are looking to use CMake with boost?

Just wondering.

Mike Jackson

On Wed, Apr 15, 2009 at 11:09 AM, David Doria <daviddoria at gmail.com> wrote:
> 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
>
>
> _______________________________________________
> 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