Question about internal headers and idiomatic CMake use

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

You can use target_include_directories(subproj2 INTERFACE $<BUILD_INTERFACE:path/to/internal_dir>) to make the internal header directories only visible to your build.

However, I will note, that with the example structure you have here, someone can explicitly request internal/ anyways (#include <myproject/subproj2/internal/details.h>). What I’d do is move internal to be like this:

./internal/include/myproject/subproj1
./internal/include/myproject/subproj2

You can then add this internal directory as a PRIVATE and/or $<BUILD_INTERFACE:> entry in target_include_directories as needed.