Add Fuchsia support to build-jsc
[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     Fuchsia
41     GTK
42     JSCOnly
43     Mac
44     WPE
45     WinCairo
46 )
47 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
48
49 list(FIND ALL_PORTS ${PORT} RET)
50 if (${RET} EQUAL -1)
51     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
52 endif ()
53
54 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
55
56 # -----------------------------------------------------------------------------
57 # Determine the compiler
58 # -----------------------------------------------------------------------------
59 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
60     set(COMPILER_IS_CLANG ON)
61 endif ()
62
63 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
64     if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "6.0.0")
65         message(FATAL_ERROR "GCC 6.0.0 is required to build WebKitGTK+, use a newer GCC version or clang")
66     endif ()
67 endif ()
68
69 if (CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
70     set(COMPILER_IS_GCC_OR_CLANG ON)
71 endif ()
72
73 if (MSVC AND COMPILER_IS_CLANG)
74     set(COMPILER_IS_CLANG_CL ON)
75 endif ()
76
77 # -----------------------------------------------------------------------------
78 # Determine the target processor
79 # -----------------------------------------------------------------------------
80 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
81 # since the later one just resolves to the host processor on Windows.
82 if (MSVC_CXX_ARCHITECTURE_ID)
83     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
84 else ()
85     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
86 endif ()
87 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
88     set(WTF_CPU_ARM 1)
89 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
90     set(WTF_CPU_ARM64 1)
91 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
92     set(WTF_CPU_MIPS 1)
93 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
94     set(WTF_CPU_X86_64 1)
95 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
96     set(WTF_CPU_X86 1)
97 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
98     set(WTF_CPU_PPC 1)
99 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
100     set(WTF_CPU_PPC64 1)
101 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
102     set(WTF_CPU_PPC64LE 1)
103 else ()
104     set(WTF_CPU_UNKNOWN 1)
105 endif ()
106
107 # -----------------------------------------------------------------------------
108 # Determine the operating system
109 # -----------------------------------------------------------------------------
110 if (UNIX)
111     if (APPLE)
112         set(WTF_OS_MAC_OS_X 1)
113     else ()
114         set(WTF_OS_UNIX 1)
115     endif ()
116 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
117     set(WTF_OS_WINDOWS 1)
118 else ()
119     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
120 endif ()
121
122 # -----------------------------------------------------------------------------
123 # Default library types
124 # -----------------------------------------------------------------------------
125 # By default, only the highest-level libraries, WebKitLegacy and WebKit, are
126 # shared, because properly building shared libraries that depend on each other
127 # can be tricky. Override these in Options*.cmake for your port as needed.
128 set(WTF_LIBRARY_TYPE STATIC)
129 set(JavaScriptCore_LIBRARY_TYPE STATIC)
130 set(PAL_LIBRARY_TYPE STATIC)
131 set(WebCore_LIBRARY_TYPE STATIC)
132 set(WebKitLegacy_LIBRARY_TYPE SHARED)
133 set(WebKit_LIBRARY_TYPE SHARED)
134 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
135
136 set(CMAKE_POSITION_INDEPENDENT_CODE True)
137
138 # -----------------------------------------------------------------------------
139 # Install JavaScript shell
140 # -----------------------------------------------------------------------------
141 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
142
143 # -----------------------------------------------------------------------------
144 # Default output directories, which can be overwritten by ports
145 #------------------------------------------------------------------------------
146 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
147 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
148 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
149
150 # -----------------------------------------------------------------------------
151 # Common configuration
152 #------------------------------------------------------------------------------
153 include(WebKitCommon)
154
155 # -----------------------------------------------------------------------------
156 # Enable API unit tests and create a target for the test runner
157 # -----------------------------------------------------------------------------
158 if (ENABLE_API_TESTS)
159     enable_testing()
160 endif ()
161
162 # -----------------------------------------------------------------------------
163 # Add module directories
164 # -----------------------------------------------------------------------------
165 add_subdirectory(Source)
166
167 # -----------------------------------------------------------------------------
168 # Add tools
169 # -----------------------------------------------------------------------------
170 if (ENABLE_TOOLS)
171     add_subdirectory(Tools)
172 endif ()
173
174 if ("${PORT}" STREQUAL "GTK" OR "${PORT}" STREQUAL "WPE")
175     if (DEVELOPER_MODE)
176         add_subdirectory(PerformanceTests)
177     endif ()
178 else ()
179     add_subdirectory(PerformanceTests)
180 endif ()
181
182 # -----------------------------------------------------------------------------
183 # Print the features list last, for maximum visibility.
184 # -----------------------------------------------------------------------------
185 PRINT_WEBKIT_OPTIONS()