Unreviewed, rolling out r188428.
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12)
2 project(WebKit)
3
4 # -----------------------------------------------------------------------------
5 # Default library type
6 # -----------------------------------------------------------------------------
7 set(BMALLOC_DIR "${CMAKE_SOURCE_DIR}/Source/bmalloc")
8 set(WTF_DIR "${CMAKE_SOURCE_DIR}/Source/WTF")
9 set(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/Source/JavaScriptCore")
10 set(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/Source/WebCore")
11 set(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit")
12 set(WEBKIT2_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit2")
13 set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/Source/ThirdParty")
14
15 set(TOOLS_DIR "${CMAKE_SOURCE_DIR}/Tools")
16
17 set(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
18 set(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
19 set(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
20 set(DERIVED_SOURCES_WEBKITLEGACY_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKitLegacy")
21 set(DERIVED_SOURCES_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit")
22 set(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
23 set(DERIVED_SOURCES_WEBINSPECTORUI_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebInspectorUI")
24 set(DERIVED_SOURCES_WTF_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WTF")
25
26 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
27
28 if (NOT DEFINED ENABLE_WEBKIT)
29     set(ENABLE_WEBKIT ON)
30 endif ()
31
32 if (NOT DEFINED ENABLE_TOOLS AND EXISTS ${TOOLS_DIR})
33     set(ENABLE_TOOLS ON)
34 endif ()
35
36 include(WebKitMacros)
37 include(WebKitFS)
38 include(WebKitHelpers)
39 include(WebKitFeatures)
40
41 # -----------------------------------------------------------------------------
42 # Determine which port will be built
43 # -----------------------------------------------------------------------------
44 set(ALL_PORTS Efl GTK AppleWin WinCairo Mac)
45 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
46
47 list(FIND ALL_PORTS ${PORT} RET)
48 if (${RET} EQUAL -1)
49     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
50 endif ()
51
52 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
53
54 # -----------------------------------------------------------------------------
55 # Find common packages (used by all ports)
56 # -----------------------------------------------------------------------------
57 find_package(BISON 2.3 REQUIRED)
58 if (!APPLE)
59     find_package(FLEX 2.5.34 REQUIRED)
60 endif ()
61
62 # TODO Enforce version requirement for gperf
63 find_package(Gperf 3.0.1 REQUIRED)
64
65 # TODO Enforce version requirement for perl
66 find_package(Perl 5.10.0 REQUIRED)
67
68 find_package(PythonInterp 2.7.0 REQUIRED)
69
70 # We cannot check for RUBY_FOUND because it is set only when the full package is installed and
71 # the only thing we need is the interpreter. Unlike Python, cmake does not provide a macro
72 # for finding only the Ruby interpreter.
73 find_package(Ruby 1.8.7)
74 if (NOT RUBY_EXECUTABLE OR RUBY_VERSION VERSION_LESS 1.8.7)
75     message(FATAL_ERROR "Ruby 1.8.7 or higher is required.")
76 endif ()
77
78 # -----------------------------------------------------------------------------
79 # Determine the target processor
80 # -----------------------------------------------------------------------------
81 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
82 # since the later one just resolves to the host processor on Windows.
83 if (MSVC_CXX_ARCHITECTURE_ID)
84     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
85 else ()
86     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
87 endif ()
88 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
89     set(WTF_CPU_ARM 1)
90 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
91     set(WTF_CPU_ARM64 1)
92 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
93     set(WTF_CPU_MIPS 1)
94 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
95     set(WTF_CPU_SH4 1)
96 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
97     set(WTF_CPU_X86_64 1)
98 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
99     set(WTF_CPU_X86 1)
100 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
101     set(WTF_CPU_PPC 1)
102 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
103     set(WTF_CPU_PPC64 1)
104 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
105     set(WTF_CPU_PPC64LE 1)
106 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "parisc*")
107     set(WTF_CPU_HPPA 1)
108 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390")
109     set(WTF_CPU_S390 1)
110 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
111     set(WTF_CPU_S390X 1)
112 else ()
113     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
114 endif ()
115
116 # -----------------------------------------------------------------------------
117 # Determine the operating system
118 # -----------------------------------------------------------------------------
119 if (UNIX)
120     if (APPLE)
121         set(WTF_OS_MAC_OS_X 1)
122     else ()
123         set(WTF_OS_UNIX 1)
124     endif ()
125 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
126     set(WTF_OS_WINDOWS 1)
127 else ()
128     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
129 endif ()
130
131 # -----------------------------------------------------------------------------
132 # Default library types
133 # -----------------------------------------------------------------------------
134 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
135
136 if (SHARED_CORE)
137     set(JavaScriptCore_LIBRARY_TYPE SHARED)
138     set(WebCore_LIBRARY_TYPE SHARED)
139 else ()
140     set(JavaScriptCore_LIBRARY_TYPE SHARED)
141     set(WebCore_LIBRARY_TYPE STATIC)
142 endif ()
143
144 set(WebKit_LIBRARY_TYPE SHARED)
145 set(WebKit2_LIBRARY_TYPE SHARED)
146 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
147
148 # -----------------------------------------------------------------------------
149 # Install JavaScript shell
150 # -----------------------------------------------------------------------------
151 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
152
153 # -----------------------------------------------------------------------------
154 # Common options
155 #------------------------------------------------------------------------------
156 include(OptionsCommon)
157 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
158 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
159 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
160
161 # -----------------------------------------------------------------------------
162 # Port-specific options
163 # -----------------------------------------------------------------------------
164 include(Options${PORT})
165
166 # -----------------------------------------------------------------------------
167 # Enable API unit tests and create a target for the test runner
168 # -----------------------------------------------------------------------------
169 if (ENABLE_API_TESTS)
170     enable_testing()
171 endif ()
172
173 # -----------------------------------------------------------------------------
174 # Define packaging
175 # -----------------------------------------------------------------------------
176 include(WebKitPackaging)
177
178 # -----------------------------------------------------------------------------
179 # Add module directories
180 # -----------------------------------------------------------------------------
181 add_subdirectory(Source)
182
183 # -----------------------------------------------------------------------------
184 # Add tools
185 # -----------------------------------------------------------------------------
186 if (ENABLE_TOOLS)
187     add_subdirectory(Tools)
188 endif ()
189
190 # -----------------------------------------------------------------------------
191 # Print the features list last, for maximum visibility.
192 # -----------------------------------------------------------------------------
193 PRINT_WEBKIT_OPTIONS()
194
195 # -----------------------------------------------------------------------------
196 # Create the configuration header
197 # -----------------------------------------------------------------------------
198 CREATE_CONFIGURATION_HEADER()