Remove Source/Platform cruft
[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
14 set(TOOLS_DIR "${CMAKE_SOURCE_DIR}/Tools")
15
16 set(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
17 set(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
18 set(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
19 set(DERIVED_SOURCES_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit")
20 set(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
21 set(DERIVED_SOURCES_WEBINSPECTORUI_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebInspectorUI")
22
23 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
24
25 set(ENABLE_WEBCORE ON)
26
27 if (NOT DEFINED ENABLE_WEBKIT)
28     set(ENABLE_WEBKIT ON)
29 endif ()
30
31 if (NOT DEFINED ENABLE_TOOLS AND EXISTS ${TOOLS_DIR})
32     set(ENABLE_TOOLS ON)
33 endif ()
34
35 # Do not create transitive library dependencies by default
36 set(CMAKE_LINK_INTERFACE_LIBRARIES "")
37
38 include(WebKitMacros)
39 include(WebKitFS)
40 include(WebKitHelpers)
41 include(WebKitFeatures)
42
43 # -----------------------------------------------------------------------------
44 # Determine which port will be built
45 # -----------------------------------------------------------------------------
46 set(ALL_PORTS Efl WinCE GTK AppleWin WinCairo Mac)
47 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
48
49 list(FIND ALL_PORTS ${PORT} RET)
50 if (${RET} EQUAL -1)
51     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
52 endif ()
53
54 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
55
56 # -----------------------------------------------------------------------------
57 # Find common packages (used by all ports)
58 # -----------------------------------------------------------------------------
59 find_package(BISON 2.3 REQUIRED)
60 if (!APPLE)
61     find_package(FLEX 2.5.34 REQUIRED)
62 endif ()
63
64 # TODO Enforce version requirement for gperf
65 find_package(Gperf 3.0.1 REQUIRED)
66
67 # TODO Enforce version requirement for perl
68 find_package(Perl 5.10.0 REQUIRED)
69
70 find_package(PythonInterp 2.6.0 REQUIRED)
71 find_package(Ruby 1.8.7)
72
73 # -----------------------------------------------------------------------------
74 # Determine the target processor
75 # -----------------------------------------------------------------------------
76 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
77 # since the later one just resolves to the host processor on Windows.
78 if (MSVC_CXX_ARCHITECTURE_ID)
79     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
80 else ()
81     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
82 endif ()
83 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
84     set(WTF_CPU_ARM 1)
85 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
86     set(WTF_CPU_ARM64 1)
87 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
88     set(WTF_CPU_MIPS 1)
89 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
90     set(WTF_CPU_SH4 1)
91 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
92     set(WTF_CPU_X86_64 1)
93 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
94     set(WTF_CPU_X86 1)
95 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
96     set(WTF_CPU_PPC 1)
97 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
98     set(WTF_CPU_PPC64 1)
99 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
100     set(WTF_CPU_PPC64LE 1)
101 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390")
102     set(WTF_CPU_S390 1)
103 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
104     set(WTF_CPU_S390X 1)
105 else ()
106     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
107 endif ()
108
109 # -----------------------------------------------------------------------------
110 # Determine the operating system
111 # -----------------------------------------------------------------------------
112 if (UNIX)
113     if (APPLE)
114         set(WTF_OS_MAC_OS_X 1)
115     else ()
116         set(WTF_OS_UNIX 1)
117     endif ()
118 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
119     set(WTF_OS_WINDOWS 1)
120 else ()
121     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
122 endif ()
123
124 # -----------------------------------------------------------------------------
125 # Default library types
126 # -----------------------------------------------------------------------------
127 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
128
129 if (SHARED_CORE)
130     set(JavaScriptCore_LIBRARY_TYPE SHARED)
131     set(WebCore_LIBRARY_TYPE SHARED)
132 else ()
133     set(JavaScriptCore_LIBRARY_TYPE SHARED)
134     set(WebCore_LIBRARY_TYPE STATIC)
135 endif ()
136
137 set(WebKit_LIBRARY_TYPE SHARED)
138 set(WebKit2_LIBRARY_TYPE SHARED)
139 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
140
141 # -----------------------------------------------------------------------------
142 # Install JavaScript shell
143 # -----------------------------------------------------------------------------
144 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
145
146 # -----------------------------------------------------------------------------
147 # Common options
148 #------------------------------------------------------------------------------
149 include(OptionsCommon)
150 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
151 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
152 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
153
154 # -----------------------------------------------------------------------------
155 # Port-specific options
156 # -----------------------------------------------------------------------------
157 include(Options${PORT})
158
159 # -----------------------------------------------------------------------------
160 # Enable API unit tests and create a target for the test runner
161 # -----------------------------------------------------------------------------
162 if (ENABLE_API_TESTS)
163     enable_testing()
164 endif ()
165
166 # -----------------------------------------------------------------------------
167 # Define packaging
168 # -----------------------------------------------------------------------------
169 include(WebKitPackaging)
170
171 # -----------------------------------------------------------------------------
172 # Add module directories
173 # -----------------------------------------------------------------------------
174 add_subdirectory(Source)
175
176 # -----------------------------------------------------------------------------
177 # Add tools
178 # -----------------------------------------------------------------------------
179 if (ENABLE_TOOLS)
180     add_subdirectory(Tools)
181 endif ()