MantisBT - CMake
View Issue Details
0015366CMakeCMakepublic2015-01-22 19:092016-01-04 11:51
Daniel v. Gerpen 
Brad King 
normalminoralways
closedfixed 
LinuxUbuntu14.04
CMake 3.1 
CMake 3.1.2CMake 3.1.2 
0015366: set_source_files_properties OBJECT_DEPENDS broken after normalization
With cmake 2.8.9 (ubuntu repos) and cmake 3.0.2 (build locally)
the attached project can be build.

[ 50%] Generating ../bla/stuff.h
Scanning dependencies of target app
[100%] Building CXX object blubb/CMakeFiles/app.dir/__/bla/a.cpp.o
Linking CXX executable app
[100%] Built target app

With 3.1 and 3.1.1 it fails because a custom command is not run:

Scanning dependencies of target app
make[2]: *** No rule to make target `blubb/../bla/stuff.h', needed by `blubb/CMakeFiles/app.dir/__/bla/a.cpp.o'. Stop.
make[1]: *** [blubb/CMakeFiles/app.dir/all] Error 2
make: *** [all] Error 2

tar zxf object_depends.tar.gz
cd object_depends
cmake .
make
https://github.com/Kitware/CMake/commit/c4af46 [^] is the first commit
with this behavior, it introduced normalization of OUTPUT and
DEPENDS in add_custom_command.

From what I can see OBJECT_DEPENDS in set_source_file_properties
is not normalized.
No tags attached.
related to 0015467closed  add_custom_target ALL option regression 
related to 0015642closed Brad King Source file properties lost if case of drive letter changes 
gz object_depends.tar.gz (712) 2015-01-22 19:09
https://public.kitware.com/Bug/file/5355/object_depends.tar.gz
Issue History
2015-01-22 19:09Daniel v. GerpenNew Issue
2015-01-22 19:09Daniel v. GerpenFile Added: object_depends.tar.gz
2015-01-23 14:12Brad KingNote Added: 0037791
2015-01-23 14:14Brad KingNote Added: 0037792
2015-01-29 09:24Brad KingNote Added: 0037857
2015-01-29 09:24Brad KingAssigned To => Brad King
2015-01-29 09:24Brad KingStatusnew => resolved
2015-01-29 09:24Brad KingResolutionopen => fixed
2015-01-29 09:24Brad KingFixed in Version => CMake 3.2
2015-01-29 09:24Brad KingTarget Version => CMake 3.2
2015-02-05 09:24Brad KingNote Added: 0037922
2015-02-05 09:24Brad KingFixed in VersionCMake 3.2 => CMake 3.1.2
2015-02-05 09:24Brad KingTarget VersionCMake 3.2 => CMake 3.1.2
2015-03-23 13:01Brad KingRelationship addedrelated to 0015467
2015-07-09 10:30Brad KingRelationship addedrelated to 0015642
2016-01-04 11:51Robert MaynardNote Added: 0040090
2016-01-04 11:51Robert MaynardStatusresolved => closed

Notes
(0037791)
Brad King   
2015-01-23 14:12   
From the tarball I was able to narrow the example down to a case involving no relative paths, no subdirectories in the source tree, and that works for in-source and out-of-source builds:

cmake_minimum_required(VERSION 3.0)
project(Issue15366 C)

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sub/../sub/main.h
  COMMAND ${CMAKE_COMMAND} -E copy
            ${CMAKE_CURRENT_SOURCE_DIR}/main.h.in
            ${CMAKE_CURRENT_BINARY_DIR}/sub/main.h
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/main.h.in
  )

set_property(SOURCE main.c PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sub/../sub/main.h)

include_directories(${CMAKE_CURRENT_BINARY_DIR}/sub)
add_executable(main main.c)


It works in 3.0 and not in 3.1.
(0037792)
Brad King   
2015-01-23 14:14   
Bisects to commit v3.1.0-rc1~471^2:

 add_custom_command: Normalize OUTPUT and DEPENDS paths.
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4af46b4 [^]
(0037857)
Brad King   
2015-01-29 09:24   
This commit should fix it:

 Normalize OBJECT_DEPENDS paths to match custom commands
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9259d778 [^]

It won't work for the original example you gave because that uses a relative path in OBJECT_DEPENDS, but the documentation says that full paths are required.
(0037922)
Brad King   
2015-02-05 09:24   
I merged this fix into the 'release' branch for 3.1.2.
(0040090)
Robert Maynard   
2016-01-04 11:51   
Closing resolved issues that have not been updated in more than 4 months.