Having trouble adding include directories


I'm trying to set up a simple test project, to unit test a change I'm working on. The change is to a file inside some existing project.

I've tried to set up the includes as the original has it, but I'm still getting compiler errors complaining that an included file can't be found. (This project uses a homebrew build system other than CMake, so I couldn't just look in its CMake files to see how it did it).

My CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 3.16.2)
project(Testing LANGUAGES CXX)



add_executable(test main.cpp ${sources})

But make spits out:

In file included from /Users/me/Projects/Testing/repo/main.cpp:1:
/Users/me/Projects/OtherProject/repo/src/FooBarAPI/Blah.hpp|3 col 10| fatal error: 'BeepBoop.hpp' file not found
#include "BeepBoop.hpp"
1 error generated.

Indeed, if I look in the Makefile which CMake generated, there's no FooBarAPI anywhere in there. Isn't that what include_directories is for? What am I missing?

Why should this post be closed?


1 answer



There's a good reason the compiler says it can't find the file: it's not there.

In my particular case, BeepBoop.hpp actually gets automatically generated from other files by the ordinary build process, and I didn't realise this.

include_directories is perfectly correct.


Sign up to answer this question »