Say I have the following file structure:
project/
- src/
- main.cpp
moduleA/
- moduleA.cpp
- moduleA.hpp
moduleB/
- moduleB.cpp
- moduleB.hpp
Within moduleB I would like to use moduleA. As such, I would like to include moduleA.hpp but as a relative path to src. Aka, I would like to be able to write #include moduleA/moduleA.hpp to use moduleA. I have control over all files, and can put CMakeLists.txt or FindModule<>.cmake in any directories.
Note: I want to do this because there are files in each module that have the same name (in this case, parameters.hpp). Therefore, I would like to be able to include parameters.hpp relative to src directory for readability purposes, and to ensure that the correct parameters file is being included.
If this is confusing, or any other information is required, please ask. Thanks for all the help everyone!
include_directories(${CMAKE_SOURCE_DIR}), or maybeinclude_directories(${CMAKE_SOURCE_DIR}/src), depends what your root folder is.include_directories(bar/foo.h)is that within a file, I can then just write#include "foo.h". I would like that to error out - and instead require the relative path. As such, you would need to write#include "bar/foo.h".