[cmake-developers] [CMake 0014697]: CMake does not add files to depend.make which are referenced by #include but not present on disk
Mantis Bug Tracker
mantis at public.kitware.com
Tue Jan 14 08:07:23 EST 2014
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=14697
======================================================================
Reported By: Christian Meyer
Assigned To:
======================================================================
Project: CMake
Issue ID: 14697
Category: CMake
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 2014-01-14 08:07 EST
Last Modified: 2014-01-14 08:07 EST
======================================================================
Summary: CMake does not add files to depend.make which are
referenced by #include but not present on disk
Description:
I added a bash script which should reproduce the problem on any system with a
working cmake installation when generating Makefiles.
It boils down to CMake omitting to add a #included file to the depend.make if
that include is not present on the hard drive at build time. Unfortunately it
does not fix this when that file is added afterwards.
Use Case:
1. User commits new source to a repository but omits a header file (fairly
common)
2. Build server initiates an incremental build which fails because the header
file is missing
3. User commits the missing header
4. Build server starts incremental build, build succeeds
5. User modifies the header
6. Expected: Build server rebuilds the source file which included the header;
Actual: Build server does nothing
Steps to Reproduce:
#!/bin/bash
# Test script to check for correct dependency updating in cmake when users
forget to commit header files to repositories
# Returns a non-zero exit code on test failure.
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 (should fail because main.h is
missing)"
cmake .
make
echo "### At this point the build fails because the header is missing"
echo "# Create the header and make (now the build should pass)"
touch main.h
make
echo "### Now the build passes normally"
echo "# Touch the header and make (now main.cpp should be rebuilt)"
touch main.h
make
echo "### The build does not recompile main.cpp even though I touched main.h"
echo "# Display depend.make and observe that main.h is missing"
cat CMakeFiles/TestApp.dir/depend.make
grep -q main.h CMakeFiles/TestApp.dir/depend.make
TEST_PASSED=$?
# Clean up for retest
make clean
rm main.h
exit ${TEST_PASSED}
Additional Information:
Script output on my local machine:
cmake version 2.8.7
### Create a minimal test project
### Run CMake and build the project (should fail because main.h is missing)
-- Configuring done
-- Generating done
-- Build files have been written to: /scratch/gridbox/cmake-test
[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
### At this point the build fails because the header is missing
# Create the header and make (now the build should pass)
[100%] Building CXX object CMakeFiles/TestApp.dir/main.cpp.o
Linking CXX executable TestApp
[100%] Built target TestApp
### Now the build passes normally
# Touch the header and make (now main.cpp should be rebuilt)
[100%] Built target TestApp
### The build does not recompile main.cpp even tough I touched main.h
# Display depend.make and observe that main.h is missing
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
CMakeFiles/TestApp.dir/main.cpp.o: main.cpp
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-01-14 08:07 Christian MeyerNew Issue
======================================================================
More information about the cmake-developers
mailing list