[cmake-developers] [CMake 0015748]: Regression: get_target_property dies if a source file does not exist

Mantis Bug Tracker mantis at public.kitware.com
Wed Sep 16 18:20:19 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15748 
====================================================================== 
Reported By:                James Johnston
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15748
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-09-16 18:20 EDT
Last Modified:              2015-09-16 18:20 EDT
====================================================================== 
Summary:                    Regression:  get_target_property dies if a source
file does not exist
Description: 
Previously, 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 Reproduce: 
1.  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 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!
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-09-16 18:20 James Johnston New Issue                                    
======================================================================



More information about the cmake-developers mailing list