AW: Re: [CMake] Linking Problems w. CMake 2.4 and MinGW32

Brad King brad.king at kitware.com
Thu Sep 7 10:32:34 EDT 2006


hendrik at darkon.info wrote:
>> ADD_EXECUTABLE(foo foo.cxx)
>> TARGET_LINK_LIBRARIES(foo bar.lib)
>>
>> and I got a "-lbar" on the link line from CMake 2.4.3 with the "MSYS
>> Makefiles" and "MinGW Makefiles" generators.
> 
> This example works for me, too. Maybe there's some issue on setting the LIbrary via FIND_LIBRARY?

Use the MESSAGE command to see the value of BOOST_REGEX_LIB.  Perhaps it
gets set to "bar.lib.lib" or something.

>> MESSAGE("CMAKE_EXTRA_LINK_EXTENSIONS=[${CMAKE_EXTRA_LINK_EXTENSIONS}]")
>>
>> to your code to see if the variable is set to ".lib" as it is supposed
>> to be on MinGW and MSYS generators.
> 
> This is true for my CMake file, too.
[snip]
> FIND_LIBRARY(BOOST_REGEX_LIB
>   NAMES boost_regex-gcc boost_regex-gcc-1_33_1 boost_regex-vc80-mt.lib
>   PATHS /usr/lib /usr/local/lib C:/Boost/lib
>   DOC "Path to the boost regular expression library")
> LINK_LIBRARIES( ${BOOST_REGEX_LIB} )
[snip]
> ADD_EXECUTABLE( edi ${SRC_FILES} )

The LINK_LIBRARIES command is obsolete.  Use TARGET_LINK_LIBRARIES to
specifically link the library to each target that needs it:

ADD_EXECUTABLE( edi ${SRC_FILES} )
TARGET_LINK_LIBRARIES(edi ${BOOST_REGEX_LIB})

-Brad



More information about the CMake mailing list