View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015748CMakeCMakepublic2015-09-16 18:202016-02-01 09:10
ReporterJames Johnston 
Assigned ToStephen Kelly 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformVisual Studio 2008OSWindows 7OS Version
Product VersionCMake 3.4 
Target VersionCMake 3.4Fixed in VersionCMake 3.4 
Summary0015748: Regression: get_target_property dies if a source file does not exist
DescriptionPreviously, in CMake 3.3, one could call get_target_property to retrieve the deprecated LOCATION target property even if not all source files exist yet. Now, in CMake master branch (commit febeabbf0b221a19bd4bf16ba7620af22d8dba17) this does not work under some conditions. The bug is a little tricky to isolate into a test case - e.g. not all calls to get_target_property will die. (e.g. if you call get_target_property from the same dir that creates the target, it seems to work). I am also not sure if the LOCATION property is the only target property affected by this.

Even though LOCATION is deprecated, this matters because very recent OpenCV versions still use it (e.g. in OpenCV/cmake/OpenCVGenPkgconfig.cmake).
Steps To Reproduce1. Create file CMakeLists.txt with this contents:

cmake_minimum_required(VERSION 2.6.3)
project(SourceTest)
add_subdirectory(subdir)
# Critical: this needs to happen in root CMakeLists.txt and not inside
# the subdir.
get_target_property(mypath Hello LOCATION_${CMAKE_BUILD_TYPE})
# Now we create the file later, so you can see, ultimately no error should
# happen e.g. during generate phase:
configure_file(subdir/Hello.c.in ${CMAKE_CURRENT_BINARY_DIR}/subdir/Hello.c)

2. Create subdir/CMakeLists.txt with this contents:

add_executable(Hello ${CMAKE_CURRENT_BINARY_DIR}/Hello.c)

3. The contents of subdir/Hello.c.in can be a simple Hello World program. (actually the contents do not matter to repro this bug since you don't get to compile phase...).

4. Configure the project:

cmake -GNinja ../SourceTest

5. I get this error:

CMake Error at subdir/CMakeLists.txt:1 (add_executable):
  Cannot find source file:

    C:/Users/JamesJ/Documents/Repositories/OI3D-2/SourceTest-build/subdir/Hello.
c

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


-- Configuring incomplete, errors occurred!
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0039435)
Brad King (manager)
2015-09-17 09:29

This bisects to somewhere around:

 cmTarget: Create cmGeneratorTargets before reading deprecated LOCATION.
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba266858 [^]

That commit fails but a few preceding commits segfault on the example.
(0039441)
Stephen Kelly (developer)
2015-09-18 14:11

Thanks for the reproducing example!

Fixed with

 CMP0026: Use compatibility codepath until configure is finished (0015748)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d02c5b6e [^]
(0039445)
Stephen Kelly (developer)
2015-09-18 14:33
edited on: 2015-09-18 14:51

That commit caused some test failures.

I reverted it until the cause of the test failures is known.

(0039461)
Brad King (manager)
2015-09-21 09:22

Here is the revised fix:

 CMP0026: Use compatibility codepath until configure is finished
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2514e426 [^]

Thanks, Steve.
(0040414)
Robert Maynard (manager)
2016-02-01 09:10

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

 Issue History
Date Modified Username Field Change
2015-09-16 18:20 James Johnston New Issue
2015-09-16 18:22 James Johnston Steps to Reproduce Updated
2015-09-17 09:27 Brad King Target Version => CMake 3.4
2015-09-17 09:28 Brad King Assigned To => Stephen Kelly
2015-09-17 09:28 Brad King Status new => assigned
2015-09-17 09:29 Brad King Note Added: 0039435
2015-09-18 14:11 Stephen Kelly Note Added: 0039441
2015-09-18 14:33 Stephen Kelly Note Added: 0039445
2015-09-18 14:51 Stephen Kelly Note Edited: 0039445
2015-09-21 09:22 Brad King Note Added: 0039461
2015-09-21 09:22 Brad King Status assigned => resolved
2015-09-21 09:22 Brad King Resolution open => fixed
2015-09-21 09:22 Brad King Fixed in Version => CMake 3.4
2016-02-01 09:10 Robert Maynard Note Added: 0040414
2016-02-01 09:10 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team