Progress towards using 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(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 else ()
94     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
95 endif ()
96
97 # -----------------------------------------------------------------------------
98 # Determine the operating system
99 # -----------------------------------------------------------------------------
100 if (UNIX)
101     if (APPLE)
102         set(WTF_OS_MAC_OS_X 1)
103     else ()
104         set(WTF_OS_UNIX 1)
105     endif ()
106 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
107     set(WTF_OS_WINDOWS 1)
108 else ()
109     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
110 endif ()
111
112 # -----------------------------------------------------------------------------
113 # Default library types
114 # -----------------------------------------------------------------------------
115 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
116
117 if (SHARED_CORE)
118     set(JavaScriptCore_LIBRARY_TYPE SHARED)
119     set(WebCore_LIBRARY_TYPE SHARED)
120 else ()
121     if (${PORT} STREQUAL GTK)
122         set(JavaScriptCore_LIBRARY_TYPE SHARED)
123     else ()
124         set(JavaScriptCore_LIBRARY_TYPE STATIC)
125     endif ()
126     set(WebCore_LIBRARY_TYPE STATIC)
127 endif ()
128
129 set(WebKit_LIBRARY_TYPE SHARED)
130 set(WebKit2_LIBRARY_TYPE SHARED)
131 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
132
133 # -----------------------------------------------------------------------------
134 # Install JavaScript shell
135 # -----------------------------------------------------------------------------
136 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
137
138 # -----------------------------------------------------------------------------
139 # Common options
140 #------------------------------------------------------------------------------
141 include(OptionsCommon)
142 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
143 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
144 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
145
146 # -----------------------------------------------------------------------------
147 # Port-specific options
148 # -----------------------------------------------------------------------------
149 include(Options${PORT})
150
151 # -----------------------------------------------------------------------------
152 # Enable API unit tests and create a target for the test runner
153 # -----------------------------------------------------------------------------
154 if (ENABLE_API_TESTS)
155     enable_testing()
156 endif ()
157
158 # -----------------------------------------------------------------------------
159 # Define packaging
160 # -----------------------------------------------------------------------------
161 include(WebKitPackaging)
162
163 # -----------------------------------------------------------------------------
164 # Add module directories
165 # -----------------------------------------------------------------------------
166 add_subdirectory(Source)
167
168 # -----------------------------------------------------------------------------
169 # Add tools
170 # -----------------------------------------------------------------------------
171 if (ENABLE_TOOLS)
172     add_subdirectory(Tools)
173 endif ()