summaryrefslogtreecommitdiff
path: root/Depends.cmake
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-03 16:16:44 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-03 16:16:44 +0300
commite5622837160de59a9807309240ac1bc5380e4b73 (patch)
tree0325bf3a22e1b347ab75a642c717c85bf83b0b15 /Depends.cmake
parentbd1504bbefc8954557044691bddd463c0d0e1911 (diff)
Added build options for HarfBuzz and FriBidi
Allow using both `pkg-config` provided libraries for local builds, and configuring more minimal versions for distribution. HarfBuzz has a bunch of dependencies by default. TODO: ENABLE_FRIBIDI_BUILD should cause a static library to be built.
Diffstat (limited to 'Depends.cmake')
-rw-r--r--Depends.cmake88
1 files changed, 57 insertions, 31 deletions
diff --git a/Depends.cmake b/Depends.cmake
index b30dc373..cc5c89b7 100644
--- a/Depends.cmake
+++ b/Depends.cmake
@@ -3,40 +3,65 @@ if (IOS)
3 return () 3 return ()
4endif () 4endif ()
5 5
6find_package (PkgConfig)
7
6if (ENABLE_HARFBUZZ AND EXISTS ${CMAKE_SOURCE_DIR}/lib/harfbuzz/CMakeLists.txt) 8if (ENABLE_HARFBUZZ AND EXISTS ${CMAKE_SOURCE_DIR}/lib/harfbuzz/CMakeLists.txt)
7 # Build HarfBuzz with minimal dependencies. 9 # Find HarfBuzz with pkg-config.
8 set (HB_BUILD_SUBSET OFF CACHE BOOL "" FORCE) 10 if (NOT ENABLE_HARFBUZZ_MINIMAL AND PKG_CONFIG_FOUND)
9 set (HB_HAVE_CORETEXT OFF CACHE BOOL "" FORCE) 11 pkg_check_modules (HARFBUZZ IMPORTED_TARGET harfbuzz)
10 set (HB_HAVE_FREETYPE OFF CACHE BOOL "" FORCE) 12 endif ()
11 set (HB_HAVE_GLIB OFF CACHE BOOL "" FORCE) 13 if (ENABLE_HARFBUZZ_MINIMAL OR NOT HARFBUZZ_FOUND)
12 set (HB_HAVE_GOBJECT OFF CACHE BOOL "" FORCE) 14 # Build HarfBuzz with minimal dependencies.
13 set (HB_HAVE_ICU OFF CACHE BOOL "" FORCE) 15 set (HB_BUILD_SUBSET OFF CACHE BOOL "" FORCE)
14 cmake_policy (SET CMP0075 NEW) 16 set (HB_HAVE_CORETEXT OFF CACHE BOOL "" FORCE)
15 add_subdirectory (${CMAKE_SOURCE_DIR}/lib/harfbuzz) 17 set (HB_HAVE_FREETYPE OFF CACHE BOOL "" FORCE)
16 set (HARFBUZZ_FOUND YES) 18 set (HB_HAVE_GLIB OFF CACHE BOOL "" FORCE)
19 set (HB_HAVE_GOBJECT OFF CACHE BOOL "" FORCE)
20 set (HB_HAVE_ICU OFF CACHE BOOL "" FORCE)
21 add_subdirectory (${CMAKE_SOURCE_DIR}/lib/harfbuzz)
22 set (HARFBUZZ_LIBRARIES harfbuzz)
23 # HarfBuzz is C++ so must link with the standard library.
24 if (APPLE)
25 list (APPEND HARFBUZZ_LIBRARIES c++)
26 else ()
27 list (APPEND HARFBUZZ_LIBRARIES stdc++)
28 endif ()
29 set (HARFBUZZ_FOUND YES)
30 endif ()
17endif () 31endif ()
18 32
19if (ENABLE_FRIBIDI AND EXISTS ${CMAKE_SOURCE_DIR}/lib/fribidi) 33if (ENABLE_FRIBIDI AND EXISTS ${CMAKE_SOURCE_DIR}/lib/fribidi)
20 cmake_policy (SET CMP0114 NEW) 34 # Find FriBidi with pkg-config.
21 # Build FriBidi with Meson. 35 if (NOT ENABLE_FRIBIDI_BUILD AND PKG_CONFIG_FOUND)
22 find_program (MESON_EXECUTABLE meson DOC "Meson build system") 36 pkg_check_modules (FRIBIDI IMPORTED_TARGET fribidi)
23 find_program (NINJA_EXECUTABLE NAMES ninja ninja-build DOC "Ninja build tool") 37 add_library (fribidi-lib ALIAS PkgConfig::FRIBIDI)
24 # TODO: Add an option to use autotools instead. 38 endif ()
25 include (ExternalProject) 39 if (ENABLE_FRIBIDI_BUILD OR NOT FRIBIDI_FOUND)
26 set (_dst ${CMAKE_BINARY_DIR}/lib/fribidi) 40 # Build FriBidi with Meson.
27 ExternalProject_Add (fribidi 41 find_program (MESON_EXECUTABLE meson DOC "Meson build system")
28 PREFIX ${CMAKE_BINARY_DIR}/fribidi-ext 42 find_program (NINJA_EXECUTABLE ninja DOC "Ninja build tool")
29 SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/fribidi 43 include (ExternalProject)
30 CONFIGURE_COMMAND NINJA=${NINJA_EXECUTABLE} ${MESON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/lib/fribidi 44 set (_dst ${CMAKE_BINARY_DIR}/lib/fribidi)
31 -Dtests=false -Ddocs=false -Dbin=false 45 if (MESON_EXECUTABLE AND NINJA_EXECUTABLE)
32 --prefix ${_dst} 46 ExternalProject_Add (fribidi
33 BUILD_COMMAND ${NINJA_EXECUTABLE} 47 PREFIX ${CMAKE_BINARY_DIR}/fribidi-ext
34 INSTALL_COMMAND ${NINJA_EXECUTABLE} install 48 SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/fribidi
35 ) 49 CONFIGURE_COMMAND NINJA=${NINJA_EXECUTABLE} ${MESON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/lib/fribidi
36 add_library (fribidi-lib INTERFACE) 50 -Dtests=false -Ddocs=false -Dbin=false
37 target_include_directories (fribidi-lib INTERFACE ${_dst}/include) 51 -Dc_flags=-Wno-macro-redefined
38 target_link_libraries (fribidi-lib INTERFACE -L${_dst}/lib fribidi) 52 --prefix ${_dst}
39 set (FRIBIDI_FOUND YES) 53 BUILD_COMMAND ${NINJA_EXECUTABLE}
54 INSTALL_COMMAND ${NINJA_EXECUTABLE} install
55 )
56 else ()
57 message (FATAL_ERROR
58 "GNU FriBidi must be built with Meson. Please install Meson and Ninja and try again, or provide FriBidi via pkg-config.")
59 endif ()
60 add_library (fribidi-lib INTERFACE)
61 target_include_directories (fribidi-lib INTERFACE ${_dst}/include)
62 target_link_libraries (fribidi-lib INTERFACE -L${_dst}/lib fribidi)
63 set (FRIBIDI_FOUND YES)
64 endif ()
40endif () 65endif ()
41 66
42if (NOT EXISTS ${CMAKE_SOURCE_DIR}/lib/the_Foundation/CMakeLists.txt) 67if (NOT EXISTS ${CMAKE_SOURCE_DIR}/lib/the_Foundation/CMakeLists.txt)
@@ -54,7 +79,7 @@ else ()
54 OUTPUT_STRIP_TRAILING_WHITESPACE 79 OUTPUT_STRIP_TRAILING_WHITESPACE
55 ) 80 )
56 if (subout) 81 if (subout)
57 message (FATAL_ERROR "The 'lib/the_Foundation' submodule has been updated, please re-run CMake.\n") 82 message (FATAL_ERROR "'lib/the_Foundation' Git submodule has been updated, please re-run CMake.\n")
58 endif () 83 endif ()
59 endif () 84 endif ()
60 endif () 85 endif ()
@@ -72,6 +97,7 @@ else ()
72 message (FATAL_ERROR "Lagrange requires zlib for reading compressed archives. Please check if pkg-config can find 'zlib'.") 97 message (FATAL_ERROR "Lagrange requires zlib for reading compressed archives. Please check if pkg-config can find 'zlib'.")
73 endif () 98 endif ()
74endif () 99endif ()
100
75find_package (PkgConfig REQUIRED) 101find_package (PkgConfig REQUIRED)
76pkg_check_modules (SDL2 REQUIRED sdl2) 102pkg_check_modules (SDL2 REQUIRED sdl2)
77pkg_check_modules (MPG123 IMPORTED_TARGET libmpg123) 103pkg_check_modules (MPG123 IMPORTED_TARGET libmpg123)