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

hendrik at darkon.info hendrik at darkon.info
Mon Sep 4 02:39:09 EDT 2006


>I just tried
>
>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?


>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.

Maybe I just don't see the error. This is the CMakeLists.txt of my main directory

PROJECT(edi)
# Include some useful CMake modules 
INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCXXCompiler.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineSystem.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeSystemSpecificInformation.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeTestCXXCompiler.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)

# Always give as much information as possible when compiling
SET(CMAKE_VERBOSE_MAKEFILE ON)

# Some basic options for the user
OPTION(BUILD_DOC "Build documentation with Doxygen (takes very long!)"	OFF )

# --- Checking for mandatory libs ---

#BEGIN Checking for components of the boost libarries

# Regular expressions
FIND_PATH(BOOST_REGEX boost/regex.hpp
  /usr/include /usr/local/include C:/Boost/include/boost-1_33_1
  DOC "Directory containing boost/regex.hpp")
IF( NOT BOOST_REGEX )
  MESSAGE( SEND_ERROR "boost/regex.hpp is mandatory for installation" )
ENDIF( NOT BOOST_REGEX )
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} )
INCLUDE_DIRECTORIES( ${BOOST_REGEX} )

#END Checking for components of the boost libarries

INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src )

IF(BUILD_DOC)
INCLUDE( ${CMAKE_ROOT}/Modules/FindDoxygen.cmake)
ADD_CUSTOM_TARGET(api-docs ALL ${DOXYGEN} ${edi_SOURCE_DIR}/Doxyfile )
ENDIF(BUILD_DOC)

SUBDIRS( src )

and this is the corresponding file in the src subdirectory:

FILE(GLOB SRC_FILES *.cpp )
ADD_EXECUTABLE( edi ${SRC_FILES} )
INSTALL_TARGETS(/bin edi )


More information about the CMake mailing list