Here’s my directory structure for my project (abbreviated):
Drawbox/
Library/
Drawbox.cpp
APClass/
smallAPstring.h
Here’s the top level CMakeLists.txt file:
cmake_minimum_required(VERSION 3.28)
project(my-project)
find_package(SDL2 REQUIRED)
link_directories(${SDL2_LIBRARY_DIRS})
include_directories(${SDL2_INCLUDE_DIRS} . Library APClass Library/jpeg)
add_library(Drawbox STATIC)
add_subdirectory(Library)
add_subdirectory(Tools)
add_subdirectory(APClass)
target_compile_features(Drawbox PUBLIC cxx_std_11)
And here’s the one for the Library directory:
target_sources(Drawbox
PRIVATE
Color.cpp DrErrMessages.cpp DrEventQ.cpp
DrawboxWindow.cpp FinePoint.cpp Image.cpp
JpegReader.cpp
PVector.cpp Point.cpp Rect.cpp SpaceCalc.cpp Timer.cpp
SDL/Drawbox.SDL.cpp SDL/Keyboard.SDL.cpp
)
But I’m finding that a Drawbox.cpp located in the Library sub-directory doesn’t find smallAPstring.h when doing
#include “smallAPstring.h"
What I really want to say is, “All source files in all subdirectories should find include files in these directories.” Can that be said? Or should I be putting something in my sub-directory CMakeLists.txt files?