Hello,
I am creating a library, and the associated test.
Here is the files structure :
── MyLibrary
├── CMakeLists.txt
├── include
│ └── x.h
├── src
│ ├── CMakeLists.txt
│ ├── x.cpp
│ ├── y.h
│ └── y.cpp
└── test
├── CMakeLists.txt
├── test.h
└── test.cpp
and where is what I do in the CMakeLists.txt inside the tesy directory :
target_sources(${LIB_PROJECT_NAME}
PUBLIC
test.h
test.cpp
PUBLIC
../include/x.h)
source_group(TREE . PREFIX Sources)
target_include_directories(${TEST_PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${LIB_PROJECT_NAME}/include/)
The problem is that in the test, if I want to include a.h, I just have to do :
#include <a.h>
I’d like to be able to do :
#include <MyLibrary/a.h>
I read several posts on StackOverflow telling to do :
── MyLibrary
├── CMakeLists.txt
├── include
│ └── MyLibrary
│ └── x.h
It’s not very clean, and when I am including a.h in the library, I have also to add MyLibrary in the path, where I am already in the library.
Would it be possible to alias the include directory so that
${LIB_PROJECT_NAME}/include/
becomes
MyLibrary/
?
PS : I am not sure of the PUBLIC access in the commands. Let me know if I should change anything about this point.