Progress towards CMake on Mac.
[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(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_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.7.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     set(JavaScriptCore_LIBRARY_TYPE SHARED)
132     set(WebCore_LIBRARY_TYPE STATIC)
133 endif ()
134
135 set(WebKit_LIBRARY_TYPE SHARED)
136 set(WebKit2_LIBRARY_TYPE SHARED)
137 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
138
139 # -----------------------------------------------------------------------------
140 # Install JavaScript shell
141 # -----------------------------------------------------------------------------
142 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
143
144 # -----------------------------------------------------------------------------
145 # Common options
146 #------------------------------------------------------------------------------
147 include(OptionsCommon)
148 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
149 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
150 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
151
152 # -----------------------------------------------------------------------------
153 # Port-specific options
154 # -----------------------------------------------------------------------------
155 include(Options${PORT})
156
157 # -----------------------------------------------------------------------------
158 # Enable API unit tests and create a target for the test runner
159 # -----------------------------------------------------------------------------
160 if (ENABLE_API_TESTS)
161     enable_testing()
162 endif ()
163
164 # -----------------------------------------------------------------------------
165 # Define packaging
166 # -----------------------------------------------------------------------------
167 include(WebKitPackaging)
168
169 # -----------------------------------------------------------------------------
170 # Add module directories
171 # -----------------------------------------------------------------------------
172 add_subdirectory(Source)
173
174 # -----------------------------------------------------------------------------
175 # Add tools
176 # -----------------------------------------------------------------------------
177 if (ENABLE_TOOLS)
178     add_subdirectory(Tools)
179 endif ()