View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014699CMakeCMakepublic2014-01-15 02:542014-06-02 08:38
ReporterChristian Meyer 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformOSlinuxOS Version
Product VersionCMake 2.8.7 
Target VersionFixed in VersionCMake 2.8.10 
Summary0014699: Implicity dependency scanner does not not update depend.make in succeeding incremental make builds if a #include was missing
DescriptionIf a #included header is not found on disk by the dependency scanner, that file will be absent from depend.make, which is fine, because the build will fail anyway. If during a succeeding build that header is added to the project and that build succeeds, CMake will fail to update depend.make with the now available header and will also not update depend.make with any other #included files that may have been added to the source file in question.

This means that the generated build system is corrupted and the only remedy I was able to find is deleting all CMake generated files and starting over.

This is curious, because CMake will happily update depend.make with newly added #included files in incremental builds if it was able to find all #included files before.

I added a script that demonstrates this behavior.
Steps To Reproduce#!/bin/bash

# Test script to demonstrate lack of dependency updating in cmake after users forgot to commit header files to repositories

cmake --version
echo "### Create a minimal test project"
echo "#include \"main.h\"" > main.cpp
echo "int main() {return 0;}" >> main.cpp
echo "add_executable(TestApp main.cpp)" > CMakeLists.txt
echo "### Run CMake and build the project (fails because main.h is
missing)"
mkdir build
cd build
cmake ..
make
echo "### Need to wait for a sec or there might be no timestamp difference on main.cpp"
sleep 1
echo "### Add previously missing main.h and a new header aux.h"
touch ../main.h
touch ../aux.h
echo "### Update main.cpp with the new header"
echo "#include \"aux.h\"" > ../main.cpp
echo "#include \"main.h\"" >> ../main.cpp
echo "int main() {return 0;}" >> ../main.cpp
echo "### Run make (main.cpp is rebuilt)"
make
echo "### Display depend.make and observe that both main.h and aux.h are missing"
cat CMakeFiles/TestApp.dir/depend.make
# Clean up for retest
cd ..
rm -rf build
rm main.cpp
rm CMakeLists.txt
rm aux.h
rm main.h
Additional InformationI have mentioned this in another bug report - (http://www.cmake.org/Bug/view.php?id=14697#c34937 [^]) - but I seem to have emphasized the wrong part of the problem.
TagsNo tags attached.
Attached Files

 Relationships
duplicate of 0014697closed CMake does not add files to depend.make which are referenced by #include but not present on disk 
related to 0013474closedAlex Neundorf CMake Makefile generator does not re-scan dependencies if object fails to build 

  Notes
(0034943)
Brad King (manager)
2014-01-15 09:42

With:

$ cmake --version
cmake version 2.8.12.1

I run your script and get

--------------------------------------------------------------
...
### Add previously missing main.h and a new header aux.h
### Update main.cpp with the new header
### Run make (main.cpp is rebuilt)
Scanning dependencies of target TestApp
[100%] Building CXX object CMakeFiles/TestApp.dir/main.cpp.o
Linking CXX executable TestApp
[100%] Built target TestApp
### Display depend.make and observe that both main.h and aux.h are missing
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

CMakeFiles/TestApp.dir/main.cpp.o: ../aux.h
CMakeFiles/TestApp.dir/main.cpp.o: ../main.cpp
CMakeFiles/TestApp.dir/main.cpp.o: ../main.h
--------------------------------------------------------------

The headers are not missing from the dependencies. Once you touch main.cpp between builds the CMake knows that its dependencies need to be re-scanned.

I understood the problem described in 0014697 to be when the missing header is added but main.cpp not updated. I updated your script to take out aux.h and the update to main.cpp leaving only the "touch main.h" step between builds and that indeed leaves depend.make without mention of main.h. That it is still not fixable.
(0034945)
Christian Meyer (reporter)
2014-01-15 10:20

I just fetched the source for CMake 2.8.12.1 and built it for my distro (Linux Mint). Below are the outputs for both versions, it looks like this issue has been fixed somewhere between 2.8.7 and 2.8.12.1. Thanks for your time and sorry for wasting some of it. I'll keep the limitations in mind when doing incremental CI with CMake.

cmake version 2.8.7
### Create a minimal test project
### Run CMake and build the project (fails because main.h is
missing)
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /scratch/gridbox/cmake-test/build
Scanning dependencies of target TestApp
[100%] Building CXX object CMakeFiles/TestApp.dir/main.cpp.o
/scratch/gridbox/cmake-test/main.cpp:1:18: fatal error: main.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/TestApp.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/TestApp.dir/all] Error 2
make: *** [all] Error 2
### Need to wait for a sec or there might be no timestamp difference on main.cpp
### Add previously missing main.h and a new header aux.h
### Update main.cpp with the new header
### Run make (main.cpp is rebuilt)
[100%] Building CXX object CMakeFiles/TestApp.dir/main.cpp.o
Linking CXX executable TestApp
[100%] Built target TestApp
### Display depend.make and observe that both main.h and aux.h are missing
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

CMakeFiles/TestApp.dir/main.cpp.o: ../main.cpp

---

cmake version 2.8.12.1
### Create a minimal test project
### Run CMake and build the project (fails because main.h is
missing)
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /scratch/gridbox/cmake-test/build
Scanning dependencies of target TestApp
[100%] Building CXX object CMakeFiles/TestApp.dir/main.cpp.o
/scratch/gridbox/cmake-test/main.cpp:1:18: fatal error: main.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/TestApp.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/TestApp.dir/all] Error 2
make: *** [all] Error 2
### Need to wait for a sec or there might be no timestamp difference on main.cpp
### Add previously missing main.h and a new header aux.h
### Update main.cpp with the new header
### Run make (main.cpp is rebuilt)
Scanning dependencies of target TestApp
[100%] Building CXX object CMakeFiles/TestApp.dir/main.cpp.o
Linking CXX executable TestApp
[100%] Built target TestApp
### Display depend.make and observe that both main.h and aux.h are missing
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

CMakeFiles/TestApp.dir/main.cpp.o: ../aux.h
CMakeFiles/TestApp.dir/main.cpp.o: ../main.cpp
CMakeFiles/TestApp.dir/main.cpp.o: ../main.h
(0034946)
Brad King (manager)
2014-01-15 10:32

The change between 2.8.7 and 2.8.12 was likely the fix for issue 0013474:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87fe4286 [^]
(0036082)
Robert Maynard (manager)
2014-06-02 08:38

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

 Issue History
Date Modified Username Field Change
2014-01-15 02:54 Christian Meyer New Issue
2014-01-15 09:31 Brad King Relationship added duplicate of 0014697
2014-01-15 09:42 Brad King Note Added: 0034943
2014-01-15 10:20 Christian Meyer Note Added: 0034945
2014-01-15 10:31 Brad King Relationship added related to 0013474
2014-01-15 10:32 Brad King Note Added: 0034946
2014-01-15 10:32 Brad King Status new => resolved
2014-01-15 10:32 Brad King Resolution open => duplicate
2014-01-15 10:32 Brad King Fixed in Version => CMake 2.8.10
2014-06-02 08:38 Robert Maynard Note Added: 0036082
2014-06-02 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team