diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e02155fd..02a974cc1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -116,6 +116,21 @@ set(VOXEL_COMPILE_OPTIONS -Wduplicated-cond >) +# Everything the engine sources and their public headers include: the backends +# compile against the same surface, and a missing include directory shows up as +# a build failure only on the platforms that keep the library outside the +# default include path. +add_library(VoxelCoreInterface INTERFACE) + +target_include_directories(VoxelCoreInterface INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}) + +target_link_libraries(VoxelCoreInterface INTERFACE + glfw + GLEW::GLEW + OpenGL::GL + glm::glm) + option(VOXELCORE_WAYLAND "Build the native Wayland window backend" ON) add_subdirectory(window/detail) diff --git a/src/window/detail/CMakeLists.txt b/src/window/detail/CMakeLists.txt index 7939d486a..9537eefe8 100644 --- a/src/window/detail/CMakeLists.txt +++ b/src/window/detail/CMakeLists.txt @@ -3,20 +3,12 @@ project(VoxelWindowBackends) # Input state shared by the window backends. add_library(VoxelWindowBase STATIC BaseInput.cpp) -target_include_directories(VoxelWindowBase PRIVATE ${CMAKE_SOURCE_DIR}/src) - target_compile_options(VoxelWindowBase PRIVATE ${VOXEL_COMPILE_OPTIONS}) +target_link_libraries(VoxelWindowBase PRIVATE VoxelCoreInterface) + add_library(VoxelGLFW STATIC GLFWWindow.cpp) -target_include_directories(VoxelGLFW PRIVATE ${CMAKE_SOURCE_DIR}/src) - target_compile_options(VoxelGLFW PRIVATE ${VOXEL_COMPILE_OPTIONS}) -target_link_libraries( - VoxelGLFW - PRIVATE VoxelWindowBase - glfw - OpenGL::GL - GLEW::GLEW - glm::glm) +target_link_libraries(VoxelGLFW PRIVATE VoxelWindowBase VoxelCoreInterface) diff --git a/src/window/wayland/CMakeLists.txt b/src/window/wayland/CMakeLists.txt index 667fd1174..fe8a7b810 100644 --- a/src/window/wayland/CMakeLists.txt +++ b/src/window/wayland/CMakeLists.txt @@ -60,8 +60,7 @@ function(voxel_add_wayland_backend) add_library(VoxelWayland STATIC ${wayland_sources} ${WAYLAND_SOURCES}) - target_include_directories(VoxelWayland - PRIVATE ${CMAKE_SOURCE_DIR}/src ${WAYLAND_GENERATED}) + target_include_directories(VoxelWayland PRIVATE ${WAYLAND_GENERATED}) target_compile_options(VoxelWayland PRIVATE ${VOXEL_COMPILE_OPTIONS}) @@ -71,14 +70,11 @@ function(voxel_add_wayland_backend) target_link_libraries( VoxelWayland PRIVATE VoxelWindowBase + VoxelCoreInterface PkgConfig::wayland-client PkgConfig::xkbcommon PkgConfig::egl - ${WAYLAND_EGL_LIBRARY} - glfw - OpenGL::GL - GLEW::GLEW - glm::glm) + ${WAYLAND_EGL_LIBRARY}) if(libsystemd_FOUND) target_compile_definitions(VoxelWayland PRIVATE VOXELCORE_SDBUS=1)