-
Notifications
You must be signed in to change notification settings - Fork 579
/
CMakeLists.txt
188 lines (163 loc) · 6.65 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
########################################################
#
# This is a CMake configuration file.
# To use it you need CMake which can be
# downloaded from here:
# http://www.cmake.org/cmake/resources/software.html
#
#########################################################
# Hard minimum version of cmake for all sub projects and Sigil
cmake_minimum_required( VERSION 3.18 )
project( Sigil )
# Change this URL if the location of the CI Windows Qt6 download ever changes
set (WINQTURL "https://github.com/dougmassay/win-qtwebkit-5.212/releases/download/v5.212-1")
set( RECENT_CMAKE_VER "3.18" )
if ( NOT DEFINED TRY_NEWER_FINDPYTHON3 )
set ( TRY_NEWER_FINDPYTHON3 0 )
endif()
if ( NOT DEFINED USE_VIRT_PY )
set ( USE_VERT_PY 0 )
endif()
if ( NOT DEFINED DOWNLOAD_QT )
set ( DOWNLOAD_QT 0 )
endif()
# Set Inno minimum Windows version
if ( NOT DEFINED BUILD_FOR_WIN7 )
# Windows 10 (1809)
set( BUILD_FOR_WIN7 0 )
set ( WIN_MIN_VERSION 10.0.17763 )
else()
# Windows 7sp1
set ( WIN_MIN_VERSION 6.1.7601 )
endif()
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL ${RECENT_CMAKE_VER} AND ${TRY_NEWER_FINDPYTHON3})
set ( USE_NEWER_FINDPYTHON3 1 )
else()
set ( USE_NEWER_FINDPYTHON3 0 )
endif()
set( CMAKE_DEBUG_POSTFIX "d" )
# Avoid the whole Release/Debug folder creation with Visual Studio
if (MSVC_IDE)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/bin")
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/bin")
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${PROJECT_BINARY_DIR}/bin")
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/lib")
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/lib")
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${PROJECT_BINARY_DIR}/lib")
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/lib")
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/lib")
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${PROJECT_BINARY_DIR}/lib")
endif()
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
set( PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package )
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_extras" )
set( SIGIL_MAJOR_VERSION 2 )
set( SIGIL_MINOR_VERSION 4 )
set( SIGIL_REVISION_VERSION 0 )
set( SIGIL_FULL_VERSION ${SIGIL_MAJOR_VERSION}.${SIGIL_MINOR_VERSION}.${SIGIL_REVISION_VERSION} )
if( UNIX AND NOT APPLE )
include(GNUInstallDirs)
# Make sure the correct rpath is set for the sigil executable
# on Linux -- for both the build and the installed versions.
# Needed to make sure the installed shared hunspell and gumbo
# libraries are found/used at runtime.
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}/sigil")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH.
# This will ensure the Qt5 lib directory is always included after install.
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Because GCC's link time optimization is willfully choosing to suck.
add_compile_options(-fno-lto)
endif()
# Check if platform is 64 bit
if( NOT APPLE )
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set( 64_BIT_PLATFORM 0 )
else()
set( 64_BIT_PLATFORM 1 )
endif()
endif()
# Profiler configuration for GCC
if( CMAKE_COMPILER_IS_GNUCXX )
set( CMAKE_BUILD_TYPE profiling )
set( CMAKE_CXX_FLAGS_PROFILING "-O2 -DNDEBUG -pg -g -fno-omit-frame-pointer -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls" )
# After creating the new build type,
# we clear the default back to empty
set( CMAKE_BUILD_TYPE )
endif()
if (USE_SYSTEM_LIBS)
MESSAGE(STATUS "Trying to use System Libraries...")
find_package( ZLIB )
find_package( PkgConfig )
find_package( MiniZip )
pkg_check_modules( HUNSPELL hunspell )
if ( NOT APPLE )
pkg_check_modules( PCRE2 libpcre2-16 )
endif()
endif()
message(STATUS "CMake version in use: ${CMAKE_VERSION}")
if (${USE_NEWER_FINDPYTHON3})
message(STATUS "Using newer findpython3 cmake module")
if ( APPLE )
find_package(Python3 3.9 COMPONENTS Interpreter Development)
endif()
if ( WIN32 )
if ( DOWNLOAD_QT )
include(windownloadqt.cmake)
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/Qt${QTVER}/lib/cmake")
set(Qt6_Dir "${CMAKE_CURRENT_BINARY_DIR}/Qt${QTVER}/lib/cmake/Qt6")
if(NOT EXISTS "${Qt6_Dir}")
message(FATAL_ERROR "Qt6 download/configure unsuccessful!")
endif()
endif()
if ( USE_VIRT_PY )
include(winvirtpy.cmake)
# Set hints so virtual Python environement is found first
set(Python3_FIND_VIRTUAL ONLY)
set(Python3_FIND_REGISTRY NEVER)
set(Python3_FIND_STRATEGY LOCATION)
# Trick cmake's findPython3 module into thinking the virtual python is activated
set(VIRT_PATH "${CMAKE_CURRENT_BINARY_DIR}/sigilpy")
set(ENV{VIRTUAL_ENV} "${VIRT_PATH}")
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/sigilpy/Scripts/python.exe")
message(FATAL_ERROR "Virtual Python setup unsuccessful!")
endif()
endif()
find_package(Python3 3.9 REQUIRED COMPONENTS Interpreter Development)
endif()
if( UNIX AND NOT APPLE )
if ( USE_VIRT_PY )
# Must be run in an environment with the venv activated
set ( Python3_FIND_VIRTUAL ONLY )
add_definitions( -DLINUX_VIRT_PY )
endif()
find_package(Python3 3.9 COMPONENTS Interpreter Development)
endif()
else()
message(STATUS "Using older findpython cmake module")
if ( APPLE )
find_package(PythonInterp 3.9)
find_package (PythonLibs 3.9)
endif()
if ( WIN32 )
find_package(PythonInterp 3.9)
find_package (PythonLibs 3.9)
endif()
if( UNIX AND NOT APPLE )
find_package(PythonInterp 3.9)
find_package (PythonLibs 3.9)
endif()
endif()
# gumbo-parser it is our main xhtml/html5 parser.
# We have an internal version because it diverges from Google's and GitHub's
# versions and neither want's our epub specific changes.
add_subdirectory( internal/gumbo )
add_subdirectory( 3rdparty/ )
add_subdirectory( src/ )