clopez@igalia.com | e1951b8 | 2017-10-05 20:39:04 +0000 | [diff] [blame] | 1 | # ----------------------------------------------------------------------------- |
| 2 | # Determine CMake version and build type. |
| 3 | # ----------------------------------------------------------------------------- |
aperez@igalia.com | 75986e1 | 2017-11-27 15:34:49 +0000 | [diff] [blame] | 4 | # |
don.olmstead@sony.com | bfa6360 | 2019-05-18 02:38:38 +0000 | [diff] [blame] | 5 | # NOTE: cmake_minimum_required() and project() *MUST* be the two first commands |
aperez@igalia.com | 75986e1 | 2017-11-27 15:34:49 +0000 | [diff] [blame] | 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 | |
Hironori.Fujii@sony.com | 8c03dab | 2019-06-27 08:14:30 +0000 | [diff] [blame] | 11 | cmake_minimum_required(VERSION 3.10) |
clopez@igalia.com | e1951b8 | 2017-10-05 20:39:04 +0000 | [diff] [blame] | 12 | |
aperez@igalia.com | 75986e1 | 2017-11-27 15:34:49 +0000 | [diff] [blame] | 13 | project(WebKit) |
| 14 | |
clopez@igalia.com | e1951b8 | 2017-10-05 20:39:04 +0000 | [diff] [blame] | 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 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 22 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake") |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 23 | |
commit-queue@webkit.org | 3604738 | 2016-03-14 15:42:54 +0000 | [diff] [blame] | 24 | set(ENABLE_WEBCORE ON) |
| 25 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 26 | if (NOT DEFINED ENABLE_WEBKIT) |
| 27 | set(ENABLE_WEBKIT ON) |
| 28 | endif () |
commit-queue@webkit.org | 3d436ba | 2012-12-05 18:59:16 +0000 | [diff] [blame] | 29 | |
achristensen@apple.com | 3d2babb | 2015-08-18 19:09:12 +0000 | [diff] [blame] | 30 | if (NOT DEFINED ENABLE_TOOLS AND EXISTS "${CMAKE_SOURCE_DIR}/Tools") |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 31 | set(ENABLE_TOOLS ON) |
| 32 | endif () |
commit-queue@webkit.org | 3d436ba | 2012-12-05 18:59:16 +0000 | [diff] [blame] | 33 | |
chris.reid@sony.com | c392b07 | 2020-04-28 20:59:00 +0000 | [diff] [blame] | 34 | if (NOT DEFINED ENABLE_WEBINSPECTORUI) |
| 35 | set(ENABLE_WEBINSPECTORUI ON) |
| 36 | endif () |
| 37 | |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 38 | # ----------------------------------------------------------------------------- |
| 39 | # Determine which port will be built |
| 40 | # ----------------------------------------------------------------------------- |
commit-queue@webkit.org | 6a4e2eb | 2016-03-13 22:30:13 +0000 | [diff] [blame] | 41 | set(ALL_PORTS |
| 42 | AppleWin |
| 43 | Efl |
don.olmstead@sony.com | 496d9e3 | 2019-06-27 16:54:10 +0000 | [diff] [blame] | 44 | FTW |
commit-queue@webkit.org | 6a4e2eb | 2016-03-13 22:30:13 +0000 | [diff] [blame] | 45 | GTK |
| 46 | JSCOnly |
| 47 | Mac |
don.olmstead@sony.com | b837f67 | 2018-10-31 04:00:45 +0000 | [diff] [blame] | 48 | PlayStation |
zandobersek@gmail.com | 75ce587 | 2017-05-09 11:07:57 +0000 | [diff] [blame] | 49 | WPE |
commit-queue@webkit.org | 6a4e2eb | 2016-03-13 22:30:13 +0000 | [diff] [blame] | 50 | WinCairo |
| 51 | ) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 52 | set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})") |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 53 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 54 | list(FIND ALL_PORTS ${PORT} RET) |
| 55 | if (${RET} EQUAL -1) |
| 56 | message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})") |
| 57 | endif () |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 58 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 59 | string(TOLOWER ${PORT} WEBKIT_PORT_DIR) |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 60 | |
| 61 | # ----------------------------------------------------------------------------- |
annulen@yandex.ru | a1e2e36 | 2016-09-27 12:31:58 +0000 | [diff] [blame] | 62 | # Determine the compiler |
| 63 | # ----------------------------------------------------------------------------- |
annulen@yandex.ru | 5b3b878 | 2016-09-27 16:02:10 +0000 | [diff] [blame] | 64 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") |
| 65 | set(COMPILER_IS_CLANG ON) |
| 66 | endif () |
| 67 | |
utatane.tea@gmail.com | 735de9a | 2017-07-06 04:51:10 +0000 | [diff] [blame] | 68 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") |
mcatanzaro@igalia.com | 86551e8 | 2019-06-25 14:47:44 +0000 | [diff] [blame] | 69 | if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "7.3.0") |
| 70 | message(FATAL_ERROR "GCC 7.3 or newer is required to build WebKit. Use a newer GCC version or Clang.") |
utatane.tea@gmail.com | 735de9a | 2017-07-06 04:51:10 +0000 | [diff] [blame] | 71 | endif () |
| 72 | endif () |
| 73 | |
annulen@yandex.ru | 5b3b878 | 2016-09-27 16:02:10 +0000 | [diff] [blame] | 74 | if (CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG) |
annulen@yandex.ru | a1e2e36 | 2016-09-27 12:31:58 +0000 | [diff] [blame] | 75 | set(COMPILER_IS_GCC_OR_CLANG ON) |
| 76 | endif () |
| 77 | |
commit-queue@webkit.org | bb23a15 | 2017-06-28 23:04:38 +0000 | [diff] [blame] | 78 | if (MSVC AND COMPILER_IS_CLANG) |
| 79 | set(COMPILER_IS_CLANG_CL ON) |
| 80 | endif () |
| 81 | |
annulen@yandex.ru | a1e2e36 | 2016-09-27 12:31:58 +0000 | [diff] [blame] | 82 | # ----------------------------------------------------------------------------- |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 83 | # Determine the target processor |
| 84 | # ----------------------------------------------------------------------------- |
paroga@webkit.org | e3de3b4 | 2013-09-03 13:25:14 +0000 | [diff] [blame] | 85 | # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined, |
| 86 | # since the later one just resolves to the host processor on Windows. |
| 87 | if (MSVC_CXX_ARCHITECTURE_ID) |
| 88 | string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR) |
| 89 | else () |
| 90 | string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR) |
| 91 | endif () |
commit-queue@webkit.org | 4ff1d69 | 2018-12-19 15:37:50 +0000 | [diff] [blame] | 92 | if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64|^arm64)") |
rgabor@webkit.org | e8064e2 | 2014-03-25 13:08:29 +0000 | [diff] [blame] | 93 | set(WTF_CPU_ARM64 1) |
commit-queue@webkit.org | 4ff1d69 | 2018-12-19 15:37:50 +0000 | [diff] [blame] | 94 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") |
| 95 | set(WTF_CPU_ARM 1) |
berto@igalia.com | ac740fb | 2018-08-22 20:27:22 +0000 | [diff] [blame] | 96 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64") |
| 97 | set(WTF_CPU_MIPS64 1) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 98 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") |
| 99 | set(WTF_CPU_MIPS 1) |
paroga@webkit.org | e3de3b4 | 2013-09-03 13:25:14 +0000 | [diff] [blame] | 100 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)") |
commit-queue@webkit.org | 8306d97 | 2019-03-11 19:11:09 +0000 | [diff] [blame] | 101 | # FORCE_32BIT is set in the build script when --32-bit is passed |
| 102 | # on a Linux/intel 64bit host. This allows us to produce 32bit |
| 103 | # binaries without setting the build up as a crosscompilation, |
| 104 | # which is the only way to modify CMAKE_SYSTEM_PROCESSOR. |
| 105 | if (FORCE_32BIT) |
commit-queue@webkit.org | 6c2f735 | 2019-03-25 17:57:13 +0000 | [diff] [blame] | 106 | set(WTF_CPU_X86 1) |
commit-queue@webkit.org | 8306d97 | 2019-03-11 19:11:09 +0000 | [diff] [blame] | 107 | else () |
| 108 | set(WTF_CPU_X86_64 1) |
| 109 | endif () |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 110 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)") |
| 111 | set(WTF_CPU_X86 1) |
commit-queue@webkit.org | 41cece5 | 2014-08-14 16:21:06 +0000 | [diff] [blame] | 112 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc") |
| 113 | set(WTF_CPU_PPC 1) |
| 114 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") |
| 115 | set(WTF_CPU_PPC64 1) |
| 116 | elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") |
| 117 | set(WTF_CPU_PPC64LE 1) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 118 | else () |
utatane.tea@gmail.com | 861472b | 2017-11-20 01:41:20 +0000 | [diff] [blame] | 119 | set(WTF_CPU_UNKNOWN 1) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 120 | endif () |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 121 | |
| 122 | # ----------------------------------------------------------------------------- |
| 123 | # Determine the operating system |
| 124 | # ----------------------------------------------------------------------------- |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 125 | if (UNIX) |
| 126 | if (APPLE) |
| 127 | set(WTF_OS_MAC_OS_X 1) |
dinfuehr@igalia.com | 060dcd2 | 2018-11-21 11:03:29 +0000 | [diff] [blame] | 128 | elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") |
| 129 | set(WTF_OS_LINUX 1) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 130 | else () |
| 131 | set(WTF_OS_UNIX 1) |
| 132 | endif () |
| 133 | elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") |
| 134 | set(WTF_OS_WINDOWS 1) |
abarth@webkit.org | 5a66fae | 2018-06-28 08:02:29 +0000 | [diff] [blame] | 135 | elseif (CMAKE_SYSTEM_NAME MATCHES "Fuchsia") |
| 136 | set(WTF_OS_FUCHSIA 1) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 137 | else () |
| 138 | message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'") |
| 139 | endif () |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 140 | |
| 141 | # ----------------------------------------------------------------------------- |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 142 | # Default library types |
| 143 | # ----------------------------------------------------------------------------- |
mcatanzaro@igalia.com | 883c256 | 2017-12-22 17:18:43 +0000 | [diff] [blame] | 144 | # By default, only the highest-level libraries, WebKitLegacy and WebKit, are |
| 145 | # shared, because properly building shared libraries that depend on each other |
| 146 | # can be tricky. Override these in Options*.cmake for your port as needed. |
don.olmstead@sony.com | 1789bd5 | 2019-05-31 00:46:38 +0000 | [diff] [blame] | 147 | set(bmalloc_LIBRARY_TYPE STATIC) |
annulen@yandex.ru | 3d6fbd0 | 2017-07-18 05:46:55 +0000 | [diff] [blame] | 148 | set(WTF_LIBRARY_TYPE STATIC) |
mcatanzaro@igalia.com | 883c256 | 2017-12-22 17:18:43 +0000 | [diff] [blame] | 149 | set(JavaScriptCore_LIBRARY_TYPE STATIC) |
mmaxfield@apple.com | 1d43810 | 2017-01-22 17:24:51 +0000 | [diff] [blame] | 150 | set(PAL_LIBRARY_TYPE STATIC) |
mcatanzaro@igalia.com | 883c256 | 2017-12-22 17:18:43 +0000 | [diff] [blame] | 151 | set(WebCore_LIBRARY_TYPE STATIC) |
mcatanzaro@igalia.com | d0d3e86 | 2017-09-19 00:29:31 +0000 | [diff] [blame] | 152 | set(WebKitLegacy_LIBRARY_TYPE SHARED) |
achristensen@apple.com | e052cb2 | 2015-03-14 02:57:54 +0000 | [diff] [blame] | 153 | set(WebKit_LIBRARY_TYPE SHARED) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 154 | set(WebCoreTestSupport_LIBRARY_TYPE STATIC) |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 155 | |
mcatanzaro@igalia.com | 8b224d4 | 2017-08-08 15:03:48 +0000 | [diff] [blame] | 156 | set(CMAKE_POSITION_INDEPENDENT_CODE True) |
| 157 | |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 158 | # ----------------------------------------------------------------------------- |
rakuco@webkit.org | 0bdd4d8 | 2014-05-03 18:52:45 +0000 | [diff] [blame] | 159 | # Install JavaScript shell |
| 160 | # ----------------------------------------------------------------------------- |
| 161 | option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell") |
| 162 | |
| 163 | # ----------------------------------------------------------------------------- |
jh718.park@samsung.com | 8aa3e9a | 2016-02-18 08:28:44 +0000 | [diff] [blame] | 164 | # Default output directories, which can be overwritten by ports |
mcatanzaro@igalia.com | ffb17be | 2016-01-19 01:23:08 +0000 | [diff] [blame] | 165 | #------------------------------------------------------------------------------ |
jh718.park@samsung.com | 8aa3e9a | 2016-02-18 08:28:44 +0000 | [diff] [blame] | 166 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 167 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 168 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
commit-queue@webkit.org | 143a7ff5 | 2012-09-25 03:22:13 +0000 | [diff] [blame] | 169 | |
| 170 | # ----------------------------------------------------------------------------- |
jh718.park@samsung.com | 3f8e333 | 2016-02-01 01:20:55 +0000 | [diff] [blame] | 171 | # Common configuration |
| 172 | #------------------------------------------------------------------------------ |
| 173 | include(WebKitCommon) |
| 174 | |
| 175 | # ----------------------------------------------------------------------------- |
commit-queue@webkit.org | 5b8a8ed | 2012-07-13 17:25:14 +0000 | [diff] [blame] | 176 | # Enable API unit tests and create a target for the test runner |
| 177 | # ----------------------------------------------------------------------------- |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 178 | if (ENABLE_API_TESTS) |
| 179 | enable_testing() |
| 180 | endif () |
commit-queue@webkit.org | 5b8a8ed | 2012-07-13 17:25:14 +0000 | [diff] [blame] | 181 | |
| 182 | # ----------------------------------------------------------------------------- |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 183 | # Add module directories |
| 184 | # ----------------------------------------------------------------------------- |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 185 | add_subdirectory(Source) |
paroga@webkit.org | 6e7e18f | 2011-11-23 09:08:11 +0000 | [diff] [blame] | 186 | |
| 187 | # ----------------------------------------------------------------------------- |
| 188 | # Add tools |
| 189 | # ----------------------------------------------------------------------------- |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 190 | if (ENABLE_TOOLS) |
| 191 | add_subdirectory(Tools) |
| 192 | endif () |
mcatanzaro@igalia.com | 7179e12 | 2015-04-11 21:28:34 +0000 | [diff] [blame] | 193 | |
don.olmstead@sony.com | 0183c33 | 2020-05-09 23:35:11 +0000 | [diff] [blame] | 194 | if (DEVELOPER_MODE) |
carlosgc@webkit.org | 130c403 | 2017-10-31 09:39:32 +0000 | [diff] [blame] | 195 | add_subdirectory(PerformanceTests) |
| 196 | endif () |
utatane.tea@gmail.com | deff2c1 | 2017-10-05 07:05:44 +0000 | [diff] [blame] | 197 | |
mcatanzaro@igalia.com | 7179e12 | 2015-04-11 21:28:34 +0000 | [diff] [blame] | 198 | # ----------------------------------------------------------------------------- |
| 199 | # Print the features list last, for maximum visibility. |
| 200 | # ----------------------------------------------------------------------------- |
| 201 | PRINT_WEBKIT_OPTIONS() |