Tutorial: Possibly misleading statement in Tutorial Step 6
While going through the tutorial, I got confused by the following statement (linked here):
Next we have to let CMake know that
mysqrt.cxx
depends on the generated fileTable.h
. This is done by adding the generatedTable.h
to the list of sources for the library MathFunctions.
# MathFunctions/CMakeLists.txt
add_library(MathFunctions
mysqrt.cxx
${CMAKE_CURRENT_BINARY_DIR}/Table.h
)
My question is: Do I have to explicitly declare the dependency this way by putting Table.h
in there?
I found that even if I remove ${CMAKE_CURRENT_BINARY_DIR}/Table.h
from the command above, the generated make file Step6/build/MathFunctions/CMakeFiles/MathFunctions.dir/depend.make
would retain the following line
MathFunctions/CMakeFiles/MathFunctions.dir/mysqrt.cxx.o: MathFunctions/Table.h
Only after I remove the #include "Table.h"
from the mysqrt.cxx file will the line above disappear.
Does CMake actually scan the source files supplied to the add_library
command for the included header files to automatically determine the dependency of the target?
Thank you!