Cannot resolve header file dependency with ./ path style include
With the following example, the header file dependency is not resolved as expected.
CMakeLists.txt
b.h
src/a.h
src/main.c
- CMakeList.txt
cmake_minimum_required(VERSION 3.12)
project(tmp)
add_executable(main src/main.c)
- b.h
// empty
- src/main.c
#include "./a.h"
void main() {}
- src/a.h
#include "../b.h"
The output of depend.make is as follows. b.h
is not marked as a dependent file of src/main.c
.
$ cat CMakeFiles/main.dir/depend.make
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.12
CMakeFiles/main.dir/src/main.c.o: src/./a.h
CMakeFiles/main.dir/src/main.c.o: src/main.c
If I changed #include "./a.h"
to #include "a.h"
in src/main.c, the problem was resolved.
CMake doesn't support “./path.h” style include? Or, is there any option I should add to CMakeFiles.txt?
Edited by Brad King