Missing header dependencies
If the name of the header file is contained in an compiler define, cmake doesn't pick it up.
Example main.cc
:
#define STRINGIFY(s) #s
#define EXPAND_STRINGIFY(s) STRINGIFY(s)
#include EXPAND_STRINGIFY(DRIVER)
int main() {
return 0;
}
with CMakelists.txt
:
cmake_minimum_required(VERSION 2.6)
add_executable(main main.cc)
target_compile_definitions(main PRIVATE DRIVER=driver.h)
and driver.h
:
#warning included
Using cmake 3.5.2 CMakeFiles/main.dir/depend.make
has:
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.5
CMakeFiles/main.dir/main.cc.o: ../main.cc
which is wrong. gcc -MM -DDRIVER=driver.h main.cc
gets it right:
main.o: main.cc driver.h