Refactor filter list checking code
[WebKit-https.git] / CMakeLists.txt
1 # -----------------------------------------------------------------------------
2 # Determine CMake version and build type.
3 # -----------------------------------------------------------------------------
4 #
5 # NOTE: cmake_minimum_required() and project() *MUST* be the two fist commands
6 # used, see https://cmake.org/cmake/help/v3.3/command/project.html -- the
7 # latter in particular handles loading a bunch of shared CMake definitions
8 # and loading the cross-compilation settings from CMAKE_TOOLCHAIN_FILE.
9 #
10
11 cmake_minimum_required(VERSION 3.3)
12
13 project(WebKit)
14
15 if (NOT CMAKE_BUILD_TYPE)
16     message(WARNING "No CMAKE_BUILD_TYPE value specified, defaulting to RelWithDebInfo.")
17     set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
18 else ()
19     message(STATUS "The CMake build type is: ${CMAKE_BUILD_TYPE}")
20 endif ()
21
22 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
23
24 set(ENABLE_WEBCORE ON)
25
26 if (NOT DEFINED ENABLE_WEBKIT)
27     set(ENABLE_WEBKIT ON)
28 endif ()
29
30 if (NOT DEFINED ENABLE_TOOLS AND EXISTS "${CMAKE_SOURCE_DIR}/Tools")
31     set(ENABLE_TOOLS ON)
32 endif ()
33
34 # -----------------------------------------------------------------------------
35 # Determine which port will be built
36 # -----------------------------------------------------------------------------
37 set(ALL_PORTS
38     AppleWin
39     Efl
40     GTK
41     JSCOnly
42     Mac
43     WPE
44     WinCairo
45 )
46 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
47
48 list(FIND ALL_PORTS ${PORT} RET)
49 if (${RET} EQUAL -1)
50     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
51 endif ()
52
53 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
54
55 # -----------------------------------------------------------------------------
56 # Determine the compiler
57 # -----------------------------------------------------------------------------
58 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
59     set(COMPILER_IS_CLANG ON)
60 endif ()
61
62 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
63     if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "5.0.0")
64         message(FATAL_ERROR "GCC 5.0.0 is required to build WebKitGTK+, use a newer GCC version or clang")
65     endif ()
66 endif ()
67
68 if (CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
69     set(COMPILER_IS_GCC_OR_CLANG ON)
70 endif ()
71
72 if (MSVC AND COMPILER_IS_CLANG)
73     set(COMPILER_IS_CLANG_CL ON)
74 endif ()
75
76 # -----------------------------------------------------------------------------
77 # Determine the target processor
78 # -----------------------------------------------------------------------------
79 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
80 # since the later one just resolves to the host processor on Windows.
81 if (MSVC_CXX_ARCHITECTURE_ID)
82     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
83 else ()
84     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
85 endif ()
86 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
87     set(WTF_CPU_ARM 1)
88 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
89     set(WTF_CPU_ARM64 1)
90 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
91     set(WTF_CPU_MIPS 1)
92 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
93     set(WTF_CPU_X86_64 1)
94 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
95     set(WTF_CPU_X86 1)
96 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
97     set(WTF_CPU_PPC 1)
98 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
99     set(WTF_CPU_PPC64 1)
100 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
101     set(WTF_CPU_PPC64LE 1)
102 else ()
103     set(WTF_CPU_UNKNOWN 1)
104 endif ()
105
106 # -----------------------------------------------------------------------------
107 # Determine the operating system
108 # -----------------------------------------------------------------------------
109 if (UNIX)
110     if (APPLE)
111         set(WTF_OS_MAC_OS_X 1)
112     else ()
113         set(WTF_OS_UNIX 1)
114     endif ()
115 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
116     set(WTF_OS_WINDOWS 1)
117 else ()
118     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
119 endif ()
120
121 # -----------------------------------------------------------------------------
122 # Default library types
123 # -----------------------------------------------------------------------------
124 # By default, only the highest-level libraries, WebKitLegacy and WebKit, are
125 # shared, because properly building shared libraries that depend on each other
126 # can be tricky. Override these in Options*.cmake for your port as needed.
127 set(WTF_LIBRARY_TYPE STATIC)
128 set(JavaScriptCore_LIBRARY_TYPE STATIC)
129 set(PAL_LIBRARY_TYPE STATIC)
130 set(WebCore_LIBRARY_TYPE STATIC)
131 set(WebKitLegacy_LIBRARY_TYPE SHARED)
132 set(WebKit_LIBRARY_TYPE SHARED)
133 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
134
135 set(CMAKE_POSITION_INDEPENDENT_CODE True)
136
137 # -----------------------------------------------------------------------------
138 # Install JavaScript shell
139 # -----------------------------------------------------------------------------
140 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
141
142 # -----------------------------------------------------------------------------
143 # Default output directories, which can be overwritten by ports
144 #------------------------------------------------------------------------------
145 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
146 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
147 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
148
149 # -----------------------------------------------------------------------------
150 # Common configuration
151 #------------------------------------------------------------------------------
152 include(WebKitCommon)
153
154 # -----------------------------------------------------------------------------
155 # Enable API unit tests and create a target for the test runner
156 # -----------------------------------------------------------------------------
157 if (ENABLE_API_TESTS)
158     enable_testing()
159 endif ()
160
161 # -----------------------------------------------------------------------------
162 # Add module directories
163 # -----------------------------------------------------------------------------
164 add_subdirectory(Source)
165
166 # -----------------------------------------------------------------------------
167 # Add tools
168 # -----------------------------------------------------------------------------
169 if (ENABLE_TOOLS)
170     add_subdirectory(Tools)
171 endif ()
172
173 if ("${PORT}" STREQUAL "GTK" OR "${PORT}" STREQUAL "WPE")
174     if (DEVELOPER_MODE)
175         add_subdirectory(PerformanceTests)
176     endif ()
177 else ()
178     add_subdirectory(PerformanceTests)
179 endif ()
180
181 # -----------------------------------------------------------------------------
182 # Print the features list last, for maximum visibility.
183 # -----------------------------------------------------------------------------
184 PRINT_WEBKIT_OPTIONS()