[CMake] TARGET_LINK_LIBRARIES not working for MSVC

Eric Noulard eric.noulard at gmail.com
Sat Jan 8 09:34:51 EST 2011


2011/1/8 Avanindra Singh <avanindra.singh at gmail.com>:
> Hi all,
> I have been trying to build a project under MSVC which I generated through
> CMAKE. The same projects compiles correctly  without any error in UBUNTU.
> But
> when I build the same project under msvc, I get so many linking errors. From
> the project configuration of msvc project I figured it out that none of
> libraries are linked.
> The project configuration does not contain linker tab, but rather a
> Librarian tab comes which does not contain any of the linked libraries which
> I put in TARGET_LINK_LIBRARIES.
> I am relatively new to cmake. Please point out where I am making mistake.
> I would put here the root CMakeLists.txt and one subdirectory ./lib/imagelib
>  CMakeLists.txt
> cmake_minimum_required(VERSION 2.4)

This is very old version of CMake.
Are you sure you are not able to at least require 2.6 (if not 2.8)
I understand you are beginning with CMake so this historical
requirement may not be necessary.
(Unless you know that some of your user must use CMake 2.4)

> if(UNIX)
> PROJECT(hybridnccsurfacecoloring C CXX Fortran)
> endif(UNIX)
> if(WIN32)
> PROJECT(hybridnccsurfacecoloring C CXX)
> endif(WIN32)

I would do:
PROJECT(hybridnccsurfacecoloring C CXX)

if(UNIX)
   enable_language(Fortran)
endif(UNIX)

>
> ADD_DEFINITIONS(-DNO_BLAS_WRAP)
>
> SET(OpenCV_DIR "E:/opencv-devel/opencv/release2")
> #SET(BOOST_ROOT "C:/Program Files/boost/boost_1_45_0")
> #set (Boost_DEBUG ON)
> find_package(OpenCV)
> find_package(ImageMagick COMPONENTS Magick++ MagickCore)
> #find_package(Boost 1.45.0 COMPONENTS filesystem)
>
> if(OpenCV_FOUND)
> message(STATUS "Opencv found.")
> include_directories(${OpenCV_INCLUDE_DIRS})
> link_libraries(${OpenCV_LIBS})

link_libraries is "Deprecated." you should use "target_link_libraries" on each
target instead.

[...]

> link_libraries(${ImageMagick_LIBRARIES})

same here
[...]

> link_libraries(
>
>  "C:/downloads/ImageMagick-6.6.2/VisualMagick/lib/IM_MOD_DB_magick_.lib"
>
>  "C:/downloads/ImageMagick-6.6.2/VisualMagick/lib/CORE_DB_magick_.lib"
>      "C:/Program
> Files/boost/boost_1_45_0/stage/lib/libboost_filesystem-vc90-mt-gd-1_45.lib"
>               )

same here

[...]


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list