-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
123 lines (104 loc) · 3.53 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#
# cmake -DCMAKE_BUILD_TYPE=Debug .
# cmake -DCMAKE_BUILD_TYPE=Release .
#
cmake_minimum_required(VERSION 3.4...3.18)
project(litehtmlpy)
# https://stackoverflow.com/questions/38296756/what-is-the-idiomatic-way-in-cmake-to-add-the-fpic-compiler-option
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(LITEHTMLPY_BUILD_TESTING "enable testing for litehtmlpy" OFF)
option(LITEHTMLPY_INCLUDE_CAIRO_CONTAINERS "include cairo containers" OFF)
#find_package(Git)
#
#if(NOT EXISTS ${CMAKE_SOURCE_DIR}/litehtml)
# execute_process(COMMAND "${GIT_EXECUTABLE}" clone --depth 1 https://github.com/m32/litehtml -b master
# WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
#endif()
#if(NOT EXISTS ${CMAKE_SOURCE_DIR}/pybind11)
# if(CMAKE_CROSSCOMPILING)
# execute_process(COMMAND "${GIT_EXECUTABLE}" clone --depth 1 https://github.com/pybind/pybind11.git -b v2.9
# WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
# else()
# execute_process(COMMAND "${GIT_EXECUTABLE}" clone --depth 1 https://github.com/pybind/pybind11.git -b v2.11
# WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
# endif()
#endif()
add_subdirectory(litehtml)
if(CMAKE_CROSSCOMPILING)
# Tell pybind11 where the target python installation is
set(PYTHON_INCLUDE_DIR ${MY_TARGET_PYTHON_INCLUDE_DIRS} CACHE INTERNAL "Cross python include path")
set(PYTHON_INCLUDE_DIRS ${MY_TARGET_PYTHON_INCLUDE_DIRS} CACHE INTERNAL "Cross python include path")
set(PYTHON_MODULE_EXTENSION ".pyd" CACHE INTERNAL "Cross python lib extension")
# Disable pybind11 python search mechanism
set(PYTHONLIBS_FOUND TRUE CACHE INTERNAL "")
target_compile_definitions(litehtml PRIVATE
-DLITEHTML_NO_THREADS
)
endif()
add_subdirectory(pybind11)
if(LITEHTMLPY_INCLUDE_CAIRO_CONTAINERS)
set(TEST_LITEHTMLPY_CONTAINERS
src/cairo/cairo_borders.cpp
src/cairo/container_cairo.cpp
src/cairo/container_cairo_pango.cpp
)
else()
set(TEST_LITEHTMLPY_CONTAINERS
)
endif()
pybind11_add_module(
litehtmlpy
src/litehtmlpy.cpp
${TEST_LITEHTMLPY_CONTAINERS}
)
if(LITEHTMLPY_BUILD_TESTING)
set_target_properties(litehtmlpy PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/src/litehtmlpy")
endif()
#if(NOT CMAKE_CROSSCOMPILING)
# find_package(PythonLibs 3.6)
# #find_package(PythonLibs 3.8 REQUIRED)
# #find_package(PythonLibs 3.11.2 EXACT REQUIRED)
#endif()
set_target_properties(litehtmlpy PROPERTIES
CXX_STANDARD 17
C_STANDARD 99
)
target_compile_definitions(litehtmlpy PRIVATE
#-DUNICODE
)
target_include_directories(litehtmlpy PRIVATE
# ${PYTHON_INCLUDE_DIRS}
litehtml/include
# ${PYBIND11_INCLUDE_DIR}
)
target_link_libraries(litehtmlpy PRIVATE
litehtml
gumbo
# ${PYTHON_LIBRARIES}
)
if(LITEHTMLPY_INCLUDE_CAIRO_CONTAINERS)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CAIRO REQUIRED IMPORTED_TARGET "cairo")
target_link_libraries(litehtmlpy PRIVATE PkgConfig::CAIRO)
pkg_check_modules(PANGO REQUIRED IMPORTED_TARGET "pango")
target_link_libraries(litehtmlpy PRIVATE PkgConfig::PANGO)
pkg_check_modules(PANGOCAIRO REQUIRED IMPORTED_TARGET "pangocairo")
target_link_libraries(litehtmlpy PRIVATE PkgConfig::PANGOCAIRO)
target_compile_definitions(litehtmlpy PRIVATE
-DUSE_CAIRO_CONTAINERS
)
endif()
if(CMAKE_CROSSCOMPILING)
target_compile_definitions(litehtmlpy PRIVATE
-DMS_WIN64
)
target_compile_options(litehtmlpy PRIVATE
-Wa,-mbig-obj
)
target_link_options(litehtmlpy PRIVATE
-static
-static-libgcc
-static-libstdc++
)
endif()