Hey,
I’m quite new to CMake and try make a project with CMake. I need some hints / suggestions on how to make this as easy and as idiomatic as possible (so not to burden possible future users with bad CMake code). My project has the following folder structure:
./include/myproject/subproj1/
./include/myproject/subproj1/internal/
./include/myproject/subproj2/
./include/myproject/subproj2/internal/
./src/myproject/subproj2/
… and some others (tests etc.). Header files are in the include directory, subproj1 is a header only lib.
Can I make the “internal” folders not accessible to the ide / users of my lib with this folder structure? Do I need to alter the folder structure? I currently use the following code:
add_library(subproj1 INTERFACE)
target_include_directories(subproj1
INTERFACE "${myproject_SOURCE_DIR}/include/"
)
add_library(subproj2 subproj2.cpp)
target_include_directories(subproj2
PUBLIC "${myproject_SOURCE_DIR}/include/"
# tried this, didnt have any effects
# PRIVATE "${myproject_SOURCE_DIR}/include/myproject/subproj2/internal/"
)
target_link_libraries(subproj2 PUBLIC subproj1)
Are there suggestions on how to structure your directories/code? Where can I find (non-trivial) libraries that use idiomatic, modern CMake (code) to draw some inspiration? I would like to use the includes (C++) in my code like this (kinda similar to boost):
#include "myproject/subproj1/subproj1.h"
#include "myproject/subproj2/subproj2.h"
Thanks for any help and suggestions
mike
Edit: Made the layout a bit nicer