[CMake] IMPORTED_LOCATION

Bill Hoffman bill.hoffman at kitware.com
Mon Dec 1 08:09:33 EST 2008


Micha Renner wrote:
> Hello, 
> 
> I have two questions for the listening below.
> 
> 1. Out-commenting the line #4
> results in a linker error LINK : fatal error LNK1104: File
> "_sLib-NOTFOUND.obj" can't be opened"
> 
> What is the purpose of this command (line #4)?
> 
The imported targets are new.  Looks like a small glitch...

Here are the docs:
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:IMPORTED_LOCATION
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:IMPORTED_IMPLIB

Looks like IMPORTED_LOCATION should be ignored if IMPORTED_IMPLIB is found.

> 2. If line #4 is active. An inspection of the project properties (link
> -> command line) shows in the implib-section the following result:
> /IMPLIB:"C:\WORK-C\ArchiveCMake\CMakeListsNeu\BuildDLL-2\TestDLL\CMake
> \Debug\TestDll2.lib" /ERRORREPORT:PROMPT kernel32.lib user32.lib
> gdi32.lib winspool.lib shell32.lib ole32.lib 
> oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  
> \WORK-C\ArchiveCMake\CMakeListsNeu\BuildDLL-2\DLL\CMake\Debug\SLib.lib
> 
> For what reason is there a TestDll2.lib?

You can export symbols from an executable on windows.  So, CMake will 
create the import library file.


> 
> Michael
> 
> Start of listening ----------------------------------------------------
> 
> 1:PROJECT(TestDLL)
> 
> 2:CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
>  
> 3:ADD_LIBRARY(_sLib SHARED IMPORTED)
> 4:SET_PROPERTY(TARGET _sLib PROPERTY IMPORTED_LOCATION /Path/SLib.dll) 
> 5:SET_PROPERTY(TARGET _sLib PROPERTY IMPORTED_IMPLIB /Path/SLib.lib)
> 
> 6:INCLUDE_DIRECTORIES(/myIncludeDir)
> 
> 7:SET(_src MRTestC.c)  
> 8:ADD_EXECUTABLE(TestDll2 ${_src})
> 9:TARGET_LINK_LIBRARIES(TestDll2 _sLib)
> 


More information about the CMake mailing list