[CMake][JSCOnly] Fix build with GLib event loop
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12)
2 project(WebKit)
3
4 # This should be removed once we require CMake 3.3.
5 if (POLICY CMP0058)
6     cmake_policy(SET CMP0058 NEW)
7 endif ()
8
9 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
10
11 set(ENABLE_WEBCORE ON)
12
13 if (NOT DEFINED ENABLE_WEBKIT)
14     set(ENABLE_WEBKIT ON)
15 endif ()
16
17 if (NOT DEFINED ENABLE_TOOLS AND EXISTS "${CMAKE_SOURCE_DIR}/Tools")
18     set(ENABLE_TOOLS ON)
19 endif ()
20
21 # -----------------------------------------------------------------------------
22 # Determine which port will be built
23 # -----------------------------------------------------------------------------
24 set(ALL_PORTS
25     AppleWin
26     Efl
27     GTK
28     JSCOnly
29     Mac
30     WinCairo
31 )
32 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
33
34 list(FIND ALL_PORTS ${PORT} RET)
35 if (${RET} EQUAL -1)
36     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
37 endif ()
38
39 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
40
41 # -----------------------------------------------------------------------------
42 # Determine the compiler
43 # -----------------------------------------------------------------------------
44 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
45     set(COMPILER_IS_CLANG ON)
46 endif ()
47
48 if (CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
49     set(COMPILER_IS_GCC_OR_CLANG ON)
50 endif ()
51
52 # -----------------------------------------------------------------------------
53 # Determine the target processor
54 # -----------------------------------------------------------------------------
55 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
56 # since the later one just resolves to the host processor on Windows.
57 if (MSVC_CXX_ARCHITECTURE_ID)
58     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
59 else ()
60     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
61 endif ()
62 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
63     set(WTF_CPU_ARM 1)
64 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
65     set(WTF_CPU_ARM64 1)
66 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
67     set(WTF_CPU_MIPS 1)
68 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
69     set(WTF_CPU_SH4 1)
70 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
71     set(WTF_CPU_X86_64 1)
72 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
73     set(WTF_CPU_X86 1)
74 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
75     set(WTF_CPU_PPC 1)
76 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
77     set(WTF_CPU_PPC64 1)
78 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
79     set(WTF_CPU_PPC64LE 1)
80 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "parisc*")
81     set(WTF_CPU_HPPA 1)
82 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390")
83     set(WTF_CPU_S390 1)
84 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
85     set(WTF_CPU_S390X 1)
86 else ()
87     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
88 endif ()
89
90 # -----------------------------------------------------------------------------
91 # Determine the operating system
92 # -----------------------------------------------------------------------------
93 if (UNIX)
94     if (APPLE)
95         set(WTF_OS_MAC_OS_X 1)
96     else ()
97         set(WTF_OS_UNIX 1)
98     endif ()
99 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
100     set(WTF_OS_WINDOWS 1)
101 else ()
102     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
103 endif ()
104
105 # -----------------------------------------------------------------------------
106 # Default library types
107 # -----------------------------------------------------------------------------
108 option(SHARED_CORE "build WebCore as a shared library")
109
110 if (SHARED_CORE)
111     set(WebCore_LIBRARY_TYPE SHARED)
112 else ()
113     set(WebCore_LIBRARY_TYPE STATIC)
114 endif ()
115
116 set(JavaScriptCore_LIBRARY_TYPE SHARED)
117 set(PAL_LIBRARY_TYPE STATIC)
118 set(WebKit_LIBRARY_TYPE SHARED)
119 set(WebKit2_LIBRARY_TYPE SHARED)
120 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
121
122 # -----------------------------------------------------------------------------
123 # Install JavaScript shell
124 # -----------------------------------------------------------------------------
125 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
126
127 # -----------------------------------------------------------------------------
128 # Default output directories, which can be overwritten by ports
129 #------------------------------------------------------------------------------
130 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
131 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
132 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
133
134 # -----------------------------------------------------------------------------
135 # Common configuration
136 #------------------------------------------------------------------------------
137 include(WebKitCommon)
138
139 # -----------------------------------------------------------------------------
140 # Enable API unit tests and create a target for the test runner
141 # -----------------------------------------------------------------------------
142 if (ENABLE_API_TESTS)
143     enable_testing()
144 endif ()
145
146 # -----------------------------------------------------------------------------
147 # Define packaging
148 # -----------------------------------------------------------------------------
149 include(WebKitPackaging)
150
151 # -----------------------------------------------------------------------------
152 # Add module directories
153 # -----------------------------------------------------------------------------
154 add_subdirectory(Source)
155
156 # -----------------------------------------------------------------------------
157 # Add tools
158 # -----------------------------------------------------------------------------
159 if (ENABLE_TOOLS)
160     add_subdirectory(Tools)
161 endif ()
162
163 # -----------------------------------------------------------------------------
164 # Print the features list last, for maximum visibility.
165 # -----------------------------------------------------------------------------
166 PRINT_WEBKIT_OPTIONS()