View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013588CMake(No Category)public2012-10-15 04:332013-03-04 08:38
Reportervkaramov 
Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionwon't fix 
PlatformPCOSUbuntu Linux 64OS Version12.04
Product VersionCMake 2.8.7 
Target VersionFixed in Version 
Summary0013588: target_link_libraries fails if one of the libraries is NOTFOUND
DescriptionMy target which is dynamic library, uses some static libs:

target_link_libraries(${lib_name}
debug ${do_scoring_debug}
optimized ${do_scoring}
)
Steps To ReproduceWhen I tried to build Release configuration of my library, build fails because do_scoring_debug == NOTFOUND at that time.
It seems strange to me, because linker doesn't need *Debug* version of ${do_scoring} when building *Release* version of target.
TagsNo tags attached.
Attached Filesgz file icon fail.tar.gz [^] (691 bytes) 2012-10-15 09:46

 Relationships

  Notes
(0031234)
Brad King (manager)
2012-10-15 08:25

I cannot reproduce this. Please attach a minimal but complete example source tarball.
(0031240)
vkaramov (reporter)
2012-10-16 04:11

I could reproduce it on 2 computers with Ubuntu 12.04 AMD64.
(0031242)
Brad King (manager)
2012-10-16 06:58

Your description said "one of the libraries is NOTFOUND". It is actually "one of the libraries is FIND_RESULT-NOTFOUND":


$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 2.8.7)
project(Issue13588 C)
add_executable(fail main.c)
target_link_libraries(fail debug m-NOTFOUND optimized m)

$ cmake --version
cmake version 2.8.9

$ cmake .. -DCMAKE_BUILD_TYPE=Release
...
CMake Error: The following variables are used in this project, but they are set
to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
m
    linked by target "fail" in directory ...

The check is here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalGenerator.cxx;hb=v2.8.9#l1125 [^]

and is so old that it pre-dates the optimized/debug keywords.

Furthermore, there is a regression in 2.8.10-rc1 in that it does not check for foo-NOTFOUND results correctly.
(0031246)
Brad King (manager)
2012-10-16 09:23

In multi-config generators like VS and Xcode the check is correct because all configurations are generated at once. If you want to ensure libs that are not found do not get used, do something like

 find_library(mylib_RELEASE ...)
 find_library(mylib_DEBUG ...)

 if(mylib_RELEASE AND mylib_DEBUG)
   set(mylib_LIBRARIES optimized ${mylib_RELEASE} debug ${mylib_DEBUG})
 elseif(mylib_RELEASE)
   set(mylib_LIBRARIES ${mylib_RELEASE})
 elseif(mylib_DEBUG)
   set(mylib_LIBRARIES ${mylib_DEBUG})
 else()
   message(SEND_ERROR "No mylib found!")
 endif()
 # ...
 target_link_libraries(${mytarget} ${mylib_LIBRARIES})

Some find modules do this already.

The regression noted in 0013588:0031242 will be addressed before 2.8.10 final.
(0032473)
Robert Maynard (manager)
2013-03-04 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-10-15 04:33 vkaramov New Issue
2012-10-15 08:25 Brad King Note Added: 0031234
2012-10-15 09:46 vkaramov File Added: fail.tar.gz
2012-10-16 04:11 vkaramov Note Added: 0031240
2012-10-16 06:58 Brad King Note Added: 0031242
2012-10-16 09:23 Brad King Note Added: 0031246
2012-10-16 09:23 Brad King Status new => resolved
2012-10-16 09:23 Brad King Resolution open => won't fix
2013-03-04 08:38 Robert Maynard Note Added: 0032473
2013-03-04 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team