summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-15 10:31:45 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-15 10:31:45 +0300
commit9b664e4be6953a038adb7698efc46fd26c5771bf (patch)
treef3e5ceef4af266c343d37ee3d7816f79cf29af11
parent46b730c6e41e13802e129a5e3970a66b6083311e (diff)
Improving integrated HarfBuzz and FriBidi builds
Build HarfBuzz with Meson, too, since that's what it recommends doing. Both HarfBuzz and FriBidi are always built as release builds. Install DLLs in the MSYS2 build. TODO: The HarfBuzz CMake build should *not* use a subdirectory, but use ExternalProject instead so it can always be a Release build.
-rw-r--r--CMakeLists.txt8
-rw-r--r--Depends.cmake76
2 files changed, 58 insertions, 26 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a668c38..7a4a2f06 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ option (ENABLE_DOWNLOAD_EDIT "Allow changing the Downloads directory" ON)
34option (ENABLE_FRIBIDI "Use the GNU FriBidi library for bidirectional text" ON) 34option (ENABLE_FRIBIDI "Use the GNU FriBidi library for bidirectional text" ON)
35option (ENABLE_FRIBIDI_BUILD "Build the GNU FriBidi library (if OFF, try pkg-config)" OFF) 35option (ENABLE_FRIBIDI_BUILD "Build the GNU FriBidi library (if OFF, try pkg-config)" OFF)
36option (ENABLE_HARFBUZZ "Use the HarfBuzz library to shape text" ON) 36option (ENABLE_HARFBUZZ "Use the HarfBuzz library to shape text" ON)
37option (ENABLE_HARFBUZZ_MINIMAL "Build the HarfBuzz library with minimal dependencies (if OFF, try pkg-config)" ON) 37option (ENABLE_HARFBUZZ_MINIMAL "Build the HarfBuzz library with minimal dependencies (if OFF, try pkg-config)" OFF)
38option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON) 38option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON)
39option (ENABLE_IPC "Use IPC to communicate between running instances" ON) 39option (ENABLE_IPC "Use IPC to communicate between running instances" ON)
40option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON) 40option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON)
@@ -313,11 +313,11 @@ endif ()
313target_link_libraries (app PUBLIC the_Foundation::the_Foundation) 313target_link_libraries (app PUBLIC the_Foundation::the_Foundation)
314target_link_libraries (app PUBLIC ${SDL2_LDFLAGS}) 314target_link_libraries (app PUBLIC ${SDL2_LDFLAGS})
315if (ENABLE_HARFBUZZ AND HARFBUZZ_FOUND) 315if (ENABLE_HARFBUZZ AND HARFBUZZ_FOUND)
316 if (TARGET PkgConfig::HARFBUZZ) 316 if (TARGET harfbuzz-lib)
317 target_link_libraries (app PUBLIC PkgConfig::HARFBUZZ) 317 target_link_libraries (app PUBLIC harfbuzz-lib)
318 else () 318 else ()
319 target_link_libraries (app PUBLIC ${HARFBUZZ_LIBRARIES}) 319 target_link_libraries (app PUBLIC ${HARFBUZZ_LIBRARIES})
320 endif () 320 endif ()
321 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_HARFBUZZ=1) 321 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_HARFBUZZ=1)
322endif () 322endif ()
323if (ENABLE_FRIBIDI AND FRIBIDI_FOUND) 323if (ENABLE_FRIBIDI AND FRIBIDI_FOUND)
diff --git a/Depends.cmake b/Depends.cmake
index ca2eb85b..846519f0 100644
--- a/Depends.cmake
+++ b/Depends.cmake
@@ -4,31 +4,60 @@ if (IOS)
4endif () 4endif ()
5 5
6find_package (PkgConfig) 6find_package (PkgConfig)
7find_program (MESON_EXECUTABLE meson DOC "Meson build system")
8find_program (NINJA_EXECUTABLE ninja DOC "Ninja build tool")
9include (ExternalProject)
7 10
8if (ENABLE_HARFBUZZ AND EXISTS ${CMAKE_SOURCE_DIR}/lib/harfbuzz/CMakeLists.txt) 11if (ENABLE_HARFBUZZ AND EXISTS ${CMAKE_SOURCE_DIR}/lib/harfbuzz/CMakeLists.txt)
9 # Find HarfBuzz with pkg-config. 12 # Find HarfBuzz with pkg-config.
10 if (NOT ENABLE_HARFBUZZ_MINIMAL AND PKG_CONFIG_FOUND) 13 if (NOT ENABLE_HARFBUZZ_MINIMAL AND PKG_CONFIG_FOUND)
11 pkg_check_modules (HARFBUZZ IMPORTED_TARGET harfbuzz) 14 pkg_check_modules (HARFBUZZ IMPORTED_TARGET harfbuzz)
15 if (HARFBUZZ_FOUND)
16 add_library (harfbuzz-lib ALIAS PkgConfig::HARFBUZZ)
17 endif ()
12 endif () 18 endif ()
13 if (ENABLE_HARFBUZZ_MINIMAL OR NOT HARFBUZZ_FOUND) 19 if (ENABLE_HARFBUZZ_MINIMAL OR NOT HARFBUZZ_FOUND)
14 # Build HarfBuzz with minimal dependencies. 20 # Build HarfBuzz with minimal dependencies.
15 set (HB_BUILD_SUBSET OFF CACHE BOOL "" FORCE) 21 if (MESON_EXECUTABLE AND NINJA_EXECUTABLE)
16 set (HB_HAVE_CORETEXT OFF CACHE BOOL "" FORCE) 22 set (_dst ${CMAKE_BINARY_DIR}/lib/harfbuzz)
17 set (HB_HAVE_FREETYPE OFF CACHE BOOL "" FORCE) 23 ExternalProject_Add (harfbuzz
18 set (HB_HAVE_GLIB OFF CACHE BOOL "" FORCE) 24 PREFIX ${CMAKE_BINARY_DIR}/harfbuzz-ext
19 set (HB_HAVE_GOBJECT OFF CACHE BOOL "" FORCE) 25 SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/harfbuzz
20 set (HB_HAVE_ICU OFF CACHE BOOL "" FORCE) 26 CONFIGURE_COMMAND NINJA=${NINJA_EXECUTABLE} ${MESON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/lib/harfbuzz
21 set (SKIP_INSTALL_ALL YES CACHE BOOL "" FORCE) 27 -Dbuildtype=release
22 add_subdirectory (${CMAKE_SOURCE_DIR}/lib/harfbuzz) 28 -Dtests=disabled -Dglib=disabled -Dgobject=disabled
23 set (HARFBUZZ_LIBRARIES harfbuzz) 29 --prefix ${_dst}
24 # HarfBuzz is C++ so must link with the standard library. 30 BUILD_COMMAND ${NINJA_EXECUTABLE}
25 if (APPLE) 31 INSTALL_COMMAND ${NINJA_EXECUTABLE} install
26 list (APPEND HARFBUZZ_LIBRARIES c++) 32 )
33 add_library (harfbuzz-lib INTERFACE)
34 target_include_directories (harfbuzz-lib INTERFACE ${_dst}/include/harfbuzz)
35 if (MSYS)
36 # Link dynamically.
37 target_link_libraries (harfbuzz-lib INTERFACE -L${_dst}/lib harfbuzz)
38 install (PROGRAMS ${_dst}/bin/msys-harfbuzz-0.dll DESTINATION .)
39 endif ()
40 set (HARFBUZZ_FOUND YES)
27 else () 41 else ()
28 list (APPEND HARFBUZZ_LIBRARIES stdc++) 42 # Try the CMake instead.
29 endif () 43 set (HB_BUILD_SUBSET OFF CACHE BOOL "" FORCE)
30 set (HARFBUZZ_FOUND YES) 44 set (HB_HAVE_CORETEXT OFF CACHE BOOL "" FORCE)
31 set (SKIP_INSTALL_ALL NO CACHE BOOL "" FORCE) 45 set (HB_HAVE_FREETYPE OFF CACHE BOOL "" FORCE)
46 set (HB_HAVE_GLIB OFF CACHE BOOL "" FORCE)
47 set (HB_HAVE_GOBJECT OFF CACHE BOOL "" FORCE)
48 set (HB_HAVE_ICU OFF CACHE BOOL "" FORCE)
49 set (SKIP_INSTALL_ALL YES CACHE BOOL "" FORCE)
50 add_subdirectory (${CMAKE_SOURCE_DIR}/lib/harfbuzz)
51 set (HARFBUZZ_LIBRARIES harfbuzz)
52 # HarfBuzz is C++ so must link with the standard library.
53 if (APPLE)
54 list (APPEND HARFBUZZ_LIBRARIES c++)
55 else ()
56 list (APPEND HARFBUZZ_LIBRARIES stdc++)
57 endif ()
58 set (HARFBUZZ_FOUND YES)
59 set (SKIP_INSTALL_ALL NO CACHE BOOL "" FORCE)
60 endif ()
32 endif () 61 endif ()
33endif () 62endif ()
34 63
@@ -36,19 +65,19 @@ if (ENABLE_FRIBIDI AND EXISTS ${CMAKE_SOURCE_DIR}/lib/fribidi)
36 # Find FriBidi with pkg-config. 65 # Find FriBidi with pkg-config.
37 if (NOT ENABLE_FRIBIDI_BUILD AND PKG_CONFIG_FOUND) 66 if (NOT ENABLE_FRIBIDI_BUILD AND PKG_CONFIG_FOUND)
38 pkg_check_modules (FRIBIDI IMPORTED_TARGET fribidi) 67 pkg_check_modules (FRIBIDI IMPORTED_TARGET fribidi)
39 add_library (fribidi-lib ALIAS PkgConfig::FRIBIDI) 68 if (FRIBIDI_FOUND)
69 add_library (fribidi-lib ALIAS PkgConfig::FRIBIDI)
70 endif ()
40 endif () 71 endif ()
41 if (ENABLE_FRIBIDI_BUILD OR NOT FRIBIDI_FOUND) 72 if (ENABLE_FRIBIDI_BUILD OR NOT FRIBIDI_FOUND)
42 # Build FriBidi with Meson. 73 # Build FriBidi with Meson.
43 find_program (MESON_EXECUTABLE meson DOC "Meson build system")
44 find_program (NINJA_EXECUTABLE ninja DOC "Ninja build tool")
45 include (ExternalProject)
46 set (_dst ${CMAKE_BINARY_DIR}/lib/fribidi) 74 set (_dst ${CMAKE_BINARY_DIR}/lib/fribidi)
47 if (MESON_EXECUTABLE AND NINJA_EXECUTABLE) 75 if (MESON_EXECUTABLE AND NINJA_EXECUTABLE)
48 ExternalProject_Add (fribidi 76 ExternalProject_Add (fribidi
49 PREFIX ${CMAKE_BINARY_DIR}/fribidi-ext 77 PREFIX ${CMAKE_BINARY_DIR}/fribidi-ext
50 SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/fribidi 78 SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/fribidi
51 CONFIGURE_COMMAND NINJA=${NINJA_EXECUTABLE} ${MESON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/lib/fribidi 79 CONFIGURE_COMMAND NINJA=${NINJA_EXECUTABLE} ${MESON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/lib/fribidi
80 -Dbuildtype=release
52 -Dtests=false -Ddocs=false -Dbin=false 81 -Dtests=false -Ddocs=false -Dbin=false
53 -Dc_flags=-Wno-macro-redefined 82 -Dc_flags=-Wno-macro-redefined
54 --prefix ${_dst} 83 --prefix ${_dst}
@@ -56,12 +85,15 @@ if (ENABLE_FRIBIDI AND EXISTS ${CMAKE_SOURCE_DIR}/lib/fribidi)
56 INSTALL_COMMAND ${NINJA_EXECUTABLE} install 85 INSTALL_COMMAND ${NINJA_EXECUTABLE} install
57 ) 86 )
58 else () 87 else ()
59 message (FATAL_ERROR 88 message (FATAL_ERROR
60 "GNU FriBidi must be built with Meson. Please install Meson and Ninja and try again, or provide FriBidi via pkg-config.") 89 "GNU FriBidi must be built with Meson. Please install Meson and Ninja and try again, or provide FriBidi via pkg-config.")
61 endif () 90 endif ()
62 add_library (fribidi-lib INTERFACE) 91 add_library (fribidi-lib INTERFACE)
63 target_include_directories (fribidi-lib INTERFACE ${_dst}/include) 92 target_include_directories (fribidi-lib INTERFACE ${_dst}/include)
64 target_link_libraries (fribidi-lib INTERFACE -L${_dst}/lib fribidi) 93 target_link_libraries (fribidi-lib INTERFACE -L${_dst}/lib fribidi)
94 if (MSYS)
95 install (PROGRAMS ${_dst}/bin/msys-fribidi-0.dll DESTINATION .)
96 endif ()
65 set (FRIBIDI_FOUND YES) 97 set (FRIBIDI_FOUND YES)
66 endif () 98 endif ()
67endif () 99endif ()