From 4eac8ae24da0db13597b15ee56970b5347e96f4f Mon Sep 17 00:00:00 2001 From: slipher Date: Fri, 19 Aug 2022 01:23:38 -0500 Subject: [PATCH] Make it build on M1 Mac The CMake changes are to work around the issue that the pkgconfig module is populating the xxx_LIBRARIES variable with the library name only (e.g. 'glib-2.0') rather than the full path, which the linker is unable to find. I guess the correct way to do it is to use the xxx_LDFLAGS variable from pkgconfig which should tell the linker where to find the libraries, but it's kind of annoying because we also have a non-pkgconfig route. The xxx_LINK_LIBRARIES variable has the full library paths but it is available only from CMake 3.12 so it can't be used unconditionally. --- README.md | 2 +- cmake/FindGLIB.cmake | 3 +++ cmake/FindGTK2.cmake | 3 +++ cmake/FindGtkGLExt.cmake | 3 +++ cmake/FindMinizip.cmake | 3 +++ cmake/FindPango.cmake | 6 ++++++ libs/gtkutil/CMakeLists.txt | 1 + radiant/CMakeLists.txt | 1 + 8 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b5fd112..33954233 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ If you plan to build a bundle, you also need to install `patchelf` Note: some dependencies of gtk+ seems to only be pulled with gtk+3, gtkglext seems to require libffi. ```sh -brew install cmake glib libffi gtk+ gtk+3 pkgconfig minizip webp coreutils gnu-sed wget sassc +brew install cmake glib gobject-introspection libffi gtk+ gtk+3 gtk-doc pkgconfig minizip webp coreutils gnu-sed wget sassc brew link --force gettext ``` diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index cf12399e..e1e09e35 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -9,6 +9,9 @@ if (PKG_CONFIG_FOUND) set(_pkgconfig_REQUIRED REQUIRED) endif () pkg_check_modules(GLIB ${_pkgconfig_REQUIRED} glib-2.0) + if (GLIB_LINK_LIBRARIES) + set(GLIB_LIBRARIES ${GLIB_LINK_LIBRARIES}) # HACK + endif () else () find_path(GLIB_INCLUDE_DIRS glib.h) find_library(GLIB_LIBRARIES glib-2.0) diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK2.cmake index ff205261..6f21791d 100644 --- a/cmake/FindGTK2.cmake +++ b/cmake/FindGTK2.cmake @@ -4,6 +4,9 @@ if (PKG_CONFIG_FOUND) set(_pkgconfig_REQUIRED REQUIRED) endif () pkg_check_modules(GTK2 ${_pkgconfig_REQUIRED} gtk+-2.0) + if (GTK2_LINK_LIBRARIES) + set(GTK2_LIBRARIES ${GTK2_LINK_LIBRARIES}) # HACK + endif () else () find_path(GTK2_INCLUDE_DIRS gtk.h) # find_library(GTK2_LIBRARIES) diff --git a/cmake/FindGtkGLExt.cmake b/cmake/FindGtkGLExt.cmake index fa8ddda9..7090890b 100644 --- a/cmake/FindGtkGLExt.cmake +++ b/cmake/FindGtkGLExt.cmake @@ -11,6 +11,9 @@ if (PKG_CONFIG_FOUND) elseif (WIN32) pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-win32-1.0) endif () + if (GtkGLExt_LINK_LIBRARIES) + set(GtkGLExt_LIBRARIES ${GtkGLExt_LINK_LIBRARIES}) # HACK + endif () else () find_path(GtkGLExt_INCLUDE_DIRS gtkglwidget.h) # find_library(GtkGLExt_LIBRARIES) diff --git a/cmake/FindMinizip.cmake b/cmake/FindMinizip.cmake index 0de098f4..8aeea296 100644 --- a/cmake/FindMinizip.cmake +++ b/cmake/FindMinizip.cmake @@ -4,6 +4,9 @@ if (PKG_CONFIG_FOUND) set(_pkgconfig_REQUIRED REQUIRED) endif () pkg_check_modules(Minizip ${_pkgconfig_REQUIRED} minizip) + if (Minizip_LINK_LIBRARIES) + set(Minizip_LIBRARIES ${Minizip_LINK_LIBRARIES}) # HACK + endif () else () find_path(Minizip_INCLUDE_DIRS unzip.h) # find_library(Minizip_LIBRARIES) diff --git a/cmake/FindPango.cmake b/cmake/FindPango.cmake index 67359ef0..aaf64a16 100644 --- a/cmake/FindPango.cmake +++ b/cmake/FindPango.cmake @@ -5,6 +5,12 @@ if (PKG_CONFIG_FOUND) endif () pkg_search_module(Pango ${_pkgconfig_REQUIRED} pango pangocairo) pkg_search_module(PangoFT2 ${_pkgconfig_REQUIRED} pangoft2) + if (Pango_LINK_LIBRARIES) + set(Pango_LIBRARIES ${Pango_LINK_LIBRARIES}) # HACK + endif() + if (PangoFT2_LINK_LIBRARIES) + set(PangoFT2_LIBRARIES ${PangoFT2_LINK_LIBRARIES}) # HACK + endif() else () # find_path(Pango_INCLUDE_DIRS) # find_library(Pango_LIBRARIES) diff --git a/libs/gtkutil/CMakeLists.txt b/libs/gtkutil/CMakeLists.txt index 80eca88c..1d6df92b 100644 --- a/libs/gtkutil/CMakeLists.txt +++ b/libs/gtkutil/CMakeLists.txt @@ -27,6 +27,7 @@ add_library(gtkutil STATIC target_include_directories(gtkutil PRIVATE uilib) target_link_libraries(gtkutil PRIVATE uilib) +find_package(GTK${GTK_TARGET} REQUIRED) target_include_directories(gtkutil PRIVATE ${GTK${GTK_TARGET}_INCLUDE_DIRS}) target_link_libraries(gtkutil PRIVATE ${GTK${GTK_TARGET}_LIBRARIES}) diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index f93b00cf..bbf72ed4 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -1,6 +1,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") find_package(OpenGL REQUIRED) +find_package(GTK${GTK_TARGET} REQUIRED) string(SUBSTRING ${CMAKE_SHARED_MODULE_SUFFIX} 1 -1 _clibext) add_definitions(-DCMAKE_SHARED_MODULE_SUFFIX="${_clibext}") -- 2.39.2