-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
100 lines (90 loc) · 3.83 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
cmake_minimum_required(VERSION 3.5)
# ===========================================================================
# Project Information
# ===========================================================================
project(
extrafont
LANGUAGES C
VERSION 1.3)
# ===========================================================================
# Locate Tcl/Tk
# ===========================================================================
if(MSVC)
find_package(TCL QUIET)
if(NOT TCL_FOUND)
include(FetchContent)
FetchContent_Declare(
cpython-tcltk-win32
GIT_REPOSITORY https://github.com/python/cpython-bin-deps
GIT_TAG tcltk)
FetchContent_MakeAvailable(cpython-tcltk-win32)
if(cpython-tcltk-win32_POPULATED)
if(MSVC_C_ARCHITECTURE_ID STREQUAL "ARM64")
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH};${cpython-tcltk-win32_SOURCE_DIR}/arm64)
elseif(MSVC_C_ARCHITECTURE_ID STREQUAL "x64")
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH};${cpython-tcltk-win32_SOURCE_DIR}/amd64)
elseif(MSVC_C_ARCHITECTURE_ID STREQUAL "X86")
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH};${cpython-tcltk-win32_SOURCE_DIR}/win32)
else()
message(
WARNING
"No Tcl/Tk prebuilt binaries from CPython could be found for your platform (MSVC ${MSVC_C_ARCHITECTURE_ID})."
"If the build fails, Ensure a MSVC-built Tcl/Tk is available on CMAKE_PREFIX_PATH."
)
endif()
endif()
endif()
endif()
find_package(TCL REQUIRED)
find_package(TclStub REQUIRED)
# ===========================================================================
# Target: tkextrafont shared library
# ===========================================================================
configure_file(third_party/extrafont/src/extrafont.c
${CMAKE_CURRENT_BINARY_DIR}/extrafont.c)
add_library(tkextrafont SHARED ${CMAKE_CURRENT_BINARY_DIR}/extrafont.c)
target_link_libraries(tkextrafont PRIVATE ${TCL_STUB_LIBRARY})
target_link_libraries(tkextrafont PRIVATE ${TK_STUB_LIBRARY})
if(APPLE)
find_library(CoreText_LIBRARY CoreText REQUIRED)
find_library(CoreFoundation_LIBRARY CoreFoundation REQUIRED)
target_link_libraries(tkextrafont PRIVATE ${CoreText_LIBRARY} ${CoreFoundation_LIBRARY})
elseif(WIN32)
target_link_libraries(tkextrafont PRIVATE gdi32)
elseif(UNIX)
find_package(Fontconfig REQUIRED)
target_link_libraries(tkextrafont PRIVATE ${Fontconfig_LIBRARIES})
endif()
target_compile_definitions(tkextrafont PRIVATE -DUSE_TCL_STUBS)
target_compile_definitions(tkextrafont PRIVATE -DUSE_TK_STUBS)
target_compile_definitions(tkextrafont
PRIVATE -DPACKAGE_NAME="${CMAKE_PROJECT_NAME}")
target_compile_definitions(tkextrafont
PRIVATE -DPACKAGE_VERSION="${CMAKE_PROJECT_VERSION}")
target_include_directories(tkextrafont PRIVATE ${TCL_INCLUDE_PATH})
target_include_directories(tkextrafont PRIVATE ${TK_INCLUDE_PATH})
target_include_directories(tkextrafont PRIVATE ${Fontconfig_INCLUDE_DIRS})
block()
set(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
set(PKG_LIB_FILE
${CMAKE_SHARED_LIBRARY_PREFIX}tkextrafont${CMAKE_SHARED_LIBRARY_SUFFIX})
configure_file(src/pkgIndex.tcl.in pkgIndex.tcl @ONLY)
endblock()
configure_file(third_party/extrafont/src/extrafont.tcl extrafont.tcl)
configure_file(third_party/extrafont/src/fontnameinfo.tcl fontnameinfo.tcl)
configure_file(third_party/extrafont/src/futmp.tcl futmp.tcl)
if(WIN32)
install(TARGETS tkextrafont RUNTIME DESTINATION tkextrafont)
else()
install(TARGETS tkextrafont LIBRARY DESTINATION tkextrafont)
endif()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgIndex.tcl
${CMAKE_CURRENT_BINARY_DIR}/extrafont.tcl
${CMAKE_CURRENT_BINARY_DIR}/fontnameinfo.tcl
${CMAKE_CURRENT_BINARY_DIR}/futmp.tcl
DESTINATION tkextrafont)