Add support for ppc, ppc64, ppc64le, s390, s390x into the CMake build
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.8)
2 project(WebKit)
3
4 # -----------------------------------------------------------------------------
5 # Default library type
6 # -----------------------------------------------------------------------------
7 set(WTF_DIR "${CMAKE_SOURCE_DIR}/Source/WTF")
8 set(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/Source/JavaScriptCore")
9 set(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/Source/WebCore")
10 set(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit")
11 set(WEBKIT2_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit2")
12 set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/Source/ThirdParty")
13 set(PLATFORM_DIR "${CMAKE_SOURCE_DIR}/Source/Platform")
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_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit")
21 set(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
22 set(DERIVED_SOURCES_WEBINSPECTORUI_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebInspectorUI")
23
24 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
25
26 set(ENABLE_WEBCORE ON)
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 WinCE 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.6.0 REQUIRED)
69 find_package(Ruby 1.8.7)
70
71 # -----------------------------------------------------------------------------
72 # Determine the target processor
73 # -----------------------------------------------------------------------------
74 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
75 # since the later one just resolves to the host processor on Windows.
76 if (MSVC_CXX_ARCHITECTURE_ID)
77     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
78 else ()
79     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
80 endif ()
81 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
82     set(WTF_CPU_ARM 1)
83 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
84     set(WTF_CPU_ARM64 1)
85 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
86     set(WTF_CPU_MIPS 1)
87 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
88     set(WTF_CPU_SH4 1)
89 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
90     set(WTF_CPU_X86_64 1)
91 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
92     set(WTF_CPU_X86 1)
93 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
94     set(WTF_CPU_PPC 1)
95 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
96     set(WTF_CPU_PPC64 1)
97 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
98     set(WTF_CPU_PPC64LE 1)
99 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390")
100     set(WTF_CPU_S390 1)
101 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
102     set(WTF_CPU_S390X 1)
103 else ()
104     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
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 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
126
127 if (SHARED_CORE)
128     set(JavaScriptCore_LIBRARY_TYPE SHARED)
129     set(WebCore_LIBRARY_TYPE SHARED)
130 else ()
131     if (${PORT} STREQUAL GTK)
132         set(JavaScriptCore_LIBRARY_TYPE SHARED)
133     else ()
134         set(JavaScriptCore_LIBRARY_TYPE STATIC)
135     endif ()
136     set(WebCore_LIBRARY_TYPE STATIC)
137 endif ()
138
139 set(WebKit_LIBRARY_TYPE SHARED)
140 set(WebKit2_LIBRARY_TYPE SHARED)
141 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
142
143 # -----------------------------------------------------------------------------
144 # Install JavaScript shell
145 # -----------------------------------------------------------------------------
146 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
147
148 # -----------------------------------------------------------------------------
149 # Common options
150 #------------------------------------------------------------------------------
151 include(OptionsCommon)
152 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
153 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
154 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
155
156 # -----------------------------------------------------------------------------
157 # Port-specific options
158 # -----------------------------------------------------------------------------
159 include(Options${PORT})
160
161 # -----------------------------------------------------------------------------
162 # Enable API unit tests and create a target for the test runner
163 # -----------------------------------------------------------------------------
164 if (ENABLE_API_TESTS)
165     enable_testing()
166 endif ()
167
168 # -----------------------------------------------------------------------------
169 # Define packaging
170 # -----------------------------------------------------------------------------
171 include(WebKitPackaging)
172
173 # -----------------------------------------------------------------------------
174 # Add module directories
175 # -----------------------------------------------------------------------------
176 add_subdirectory(Source)
177
178 # -----------------------------------------------------------------------------
179 # Add tools
180 # -----------------------------------------------------------------------------
181 if (ENABLE_TOOLS)
182     add_subdirectory(Tools)
183 endif ()