Does a static library target not expose include directories?

Hey guys,
I need to create static library, which itself links to other pre compiled static libraries
My CMakeLists.txt to build this static lib looks like this

list(APPEND RESSOURCE_FILES “Simulation/Simulation.res”)

#incude dirs
#interface include dirs need to contain the absolute path
set(module_name “myLib”)

add_library(“${module_name}” STATIC ${MODULE_SOURCES})

target_sources(${module_name} PRIVATE ${RESSOURCE_FILES})
target_link_libraries(${module_name} PUBLIC ${MODULE_LINK_LIBS})

target_include_directories(“${module_name}” PUBLIC “${INCLUDE_PUBLIC_DIRS}” )

now when I’m trying to consume this static library

set(EXE_NAME “libTest”)
set(MODULE_SOURCES “main.c” )
add_executable(${EXE_NAME} ${MODULE_SOURCES})
target_link_libraries(${EXE_NAME} PRIVATE myLib)

the include Paths are missing
#include <GUI.h> results in a file not found error.
When i add #include <GUI.h> to my static library this paths is resolved correctly.

So does a static library target not expose the INCLUDE_PUBLIC_DIRS?

I’d prefer to remove the STATIC from add_library(“${module_name}” STATIC ${MODULE_SOURCES}) . However when I’m doing that I’m getting some linker errors from unresolved symbols from GUI.lib and GUISim.lib. Not sure why this is happening though. Maybe you can’t mix dynamic and static libs ?!

Could you help me out here?

thx guys

Static libraries expose their non-PRIVATE include directories. I’m pretty sure this is a quoting issue in your CMake files.

Quoting a variable which is a list will expand it like “a;b;c”. You shouldn’t be quoting ${INCLUDE_PUBLIC_DIRS}.

When you build your software with verbose enabled you should see the -I will have an invalid directory path.