From f39d7c2e330f780f10f69a8962a07edfb0e459c9 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 9 Feb 2020 14:01:58 +0000 Subject: [PATCH] cmake: add 'libdecoration' as external project --- CMakeLists.txt | 4 ++++ external/libdecoration.cmake | 13 +++++++++++++ src/CMakeLists.txt | 5 +++++ 3 files changed, 22 insertions(+) create mode 100644 external/libdecoration.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b4ed0496f..68a7cdfe7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,8 @@ cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF "UNIX;NOT APPLE" OFF) cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON "MSVC" OFF) +cmake_dependent_option(GLFW_USE_LIBDECORATION "use libdecoration" ON + "GLFW_USE_WAYLAND" OFF) if (BUILD_SHARED_LIBS AND UNIX) # On Unix-like systems, shared libraries can use the soname system. @@ -55,6 +57,8 @@ endif() list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules") +include(ExternalProject) + find_package(Threads REQUIRED) if (GLFW_BUILD_DOCS) diff --git a/external/libdecoration.cmake b/external/libdecoration.cmake new file mode 100644 index 000000000..d1d50060d --- /dev/null +++ b/external/libdecoration.cmake @@ -0,0 +1,13 @@ +ExternalProject_Add(libdecoration + GIT_REPOSITORY https://gitlab.gnome.org/jadahl/libdecoration.git + GIT_TAG master + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/extern/libdecoration" + CONFIGURE_COMMAND meson --prefix "${CMAKE_CURRENT_BINARY_DIR}/install" --libdir "lib" ../libdecoration + BUILD_COMMAND ninja + INSTALL_COMMAND ninja install +) + +target_include_directories(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/install/include") +target_link_libraries(glfw PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/install/lib/libdecoration${CMAKE_SHARED_LIBRARY_SUFFIX}) + +add_dependencies(glfw libdecoration) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f2bdd883..920614f3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,6 +70,11 @@ if (_GLFW_WAYLAND) "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" BASENAME idle-inhibit-unstable-v1) target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES}) + + if (GLFW_USE_LIBDECORATION) + include("${CMAKE_SOURCE_DIR}/external/libdecoration.cmake") + add_definitions(-DWITH_DECORATION) + endif() endif() if (WIN32 AND BUILD_SHARED_LIBS)