I have a project with the following file structure (transitioning to CMake), with source and header files in the same directories:
root +- module1 +- a.hpp +- a.cpp +- b.hpp +- b.cpp + module1a +- a.hpp +- b.cpp +- module2 +- a.hpp +- a.cpp Header files are included in each other as #include<projectname/module1/a.hpp>. How can I instruct CMake to install all headers into the build directory as this structure, prior to building the .cpp files? I was briefly looking at install(DIRECTORY "${CMAKE_SOURCE_DIR}/module1" DESTINATION "projectname/module1" FILES_MATCHING PATTERN "*.hpp") (from CMake install header files and maintain directory heirarchy) but it does install those headers into the build directory (nothing happens).
The headers are needed only at compile-time, not at runtime.
Can I get some hint how to achieve this?
EDIT: The directory layout is different in the source three than how #include directives include it. For example, consider #include<projectname/module1a/a.hpp>. include_directories will not work for this header. The same for #include<projectname/module1/a.hpp as root!=projectname. Headers must be copied/symlinked from the old layout to the new layout first.
include_directories(/path/to/the/headers)to provide the headers for build.root/..as include path (rootvs.projectname).#include<projectname/module/header.hpp>. So I need to create theprojectnamedirectory somewhere and then copy/symlink all headers into it (or symlink module subdirectories). There is no directory I can put toinclude_directorieswhich will work.include_directories()for including headers into your project? Why doesinclude_directories()not work?