[CMake] Bump the minimum required version
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.11)
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)
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.4.1 REQUIRED)
58 find_package(FLEX 2.5.34 REQUIRED)
59
60 # TODO Enforce version requirement for gperf
61 find_package(Gperf 3.0.1 REQUIRED)
62
63 # TODO Enforce version requirement for perl
64 find_package(Perl 5.10.0 REQUIRED)
65
66 find_package(PythonInterp 2.6.0 REQUIRED)
67 find_package(Ruby 1.8.7)
68
69 # -----------------------------------------------------------------------------
70 # Determine the target processor
71 # -----------------------------------------------------------------------------
72 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
73 # since the later one just resolves to the host processor on Windows.
74 if (MSVC_CXX_ARCHITECTURE_ID)
75     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
76 else ()
77     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
78 endif ()
79 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
80     set(WTF_CPU_ARM 1)
81 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
82     set(WTF_CPU_ARM64 1)
83 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
84     set(WTF_CPU_MIPS 1)
85 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
86     set(WTF_CPU_SH4 1)
87 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
88     set(WTF_CPU_X86_64 1)
89 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
90     set(WTF_CPU_X86 1)
91 else ()
92     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
93 endif ()
94
95 # -----------------------------------------------------------------------------
96 # Determine the operating system
97 # -----------------------------------------------------------------------------
98 if (UNIX)
99     if (APPLE)
100         set(WTF_OS_MAC_OS_X 1)
101     else ()
102         set(WTF_OS_UNIX 1)
103     endif ()
104 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
105     set(WTF_OS_WINDOWS 1)
106 else ()
107     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
108 endif ()
109
110 # -----------------------------------------------------------------------------
111 # Default library types
112 # -----------------------------------------------------------------------------
113 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
114
115 if (SHARED_CORE)
116     set(JavaScriptCore_LIBRARY_TYPE SHARED)
117     set(WebCore_LIBRARY_TYPE SHARED)
118 else ()
119     if (${PORT} STREQUAL GTK)
120         set(JavaScriptCore_LIBRARY_TYPE SHARED)
121     else ()
122         set(JavaScriptCore_LIBRARY_TYPE STATIC)
123     endif ()
124     set(WebCore_LIBRARY_TYPE STATIC)
125 endif ()
126
127 set(WebKit_LIBRARY_TYPE SHARED)
128 set(WebKit2_LIBRARY_TYPE SHARED)
129 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
130
131 # -----------------------------------------------------------------------------
132 # Install JavaScript shell
133 # -----------------------------------------------------------------------------
134 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
135
136 # -----------------------------------------------------------------------------
137 # Common options
138 #------------------------------------------------------------------------------
139 include(OptionsCommon)
140 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
141 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
142 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
143
144 # -----------------------------------------------------------------------------
145 # Port-specific options
146 # -----------------------------------------------------------------------------
147 include(Options${PORT})
148
149 # -----------------------------------------------------------------------------
150 # Enable API unit tests and create a target for the test runner
151 # -----------------------------------------------------------------------------
152 if (ENABLE_API_TESTS)
153     enable_testing()
154 endif ()
155
156 # -----------------------------------------------------------------------------
157 # Define packaging
158 # -----------------------------------------------------------------------------
159 include(WebKitPackaging)
160
161 # -----------------------------------------------------------------------------
162 # Add module directories
163 # -----------------------------------------------------------------------------
164 add_subdirectory(Source)
165
166 # -----------------------------------------------------------------------------
167 # Add tools
168 # -----------------------------------------------------------------------------
169 if (ENABLE_TOOLS)
170     add_subdirectory(Tools)
171 endif ()