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