[CMake] Add minimum version information for tool dependencies
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.3)
2 project(WebKit)
3
4 # Set a default build type if and only if user did not define one as command
5 # line options and he did not give custom CFLAGS or CXXFLAGS. Otherwise, flags
6 # from default build type would overwrite user-defined ones.
7 if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_C_FLAGS AND NOT CMAKE_CXX_FLAGS)
8     set(CMAKE_BUILD_TYPE Release)
9 endif ()
10 string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
11
12 # -----------------------------------------------------------------------------
13 # Default library type
14 # -----------------------------------------------------------------------------
15 set(WTF_DIR "${CMAKE_SOURCE_DIR}/Source/WTF")
16 set(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/Source/JavaScriptCore")
17 set(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/Source/WebCore")
18 set(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit")
19 set(WEBKIT2_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit2")
20 set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/Source/ThirdParty")
21
22 set(TOOLS_DIR "${CMAKE_SOURCE_DIR}/Tools")
23
24 set(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
25 set(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
26 set(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
27 set(DERIVED_SOURCES_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit")
28 set(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
29
30 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
31
32 set(ENABLE_WEBCORE ON)
33
34 if (NOT DEFINED ENABLE_WEBKIT)
35     set(ENABLE_WEBKIT ON)
36 endif ()
37
38 if (NOT DEFINED ENABLE_TOOLS AND EXISTS ${TOOLS_DIR})
39     set(ENABLE_TOOLS ON)
40 endif ()
41
42 include(WebKitMacros)
43 include(WebKitFS)
44 include(WebKitHelpers)
45 include(WebKitFeatures)
46
47 # -----------------------------------------------------------------------------
48 # Determine which port will be built
49 # -----------------------------------------------------------------------------
50 set(ALL_PORTS Efl WinCE BlackBerry)
51 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
52
53 list(FIND ALL_PORTS ${PORT} RET)
54 if (${RET} EQUAL -1)
55     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
56 endif ()
57
58 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
59
60 # -----------------------------------------------------------------------------
61 # Find common packages (used by all ports)
62 # -----------------------------------------------------------------------------
63 find_package(BISON 2.4.1 REQUIRED)
64 find_package(FLEX 2.5.34 REQUIRED)
65
66 # TODO Enforce version requirement for gperf
67 find_package(Gperf 3.0.1 REQUIRED)
68
69 # TODO Enforce version requirement for perl
70 find_package(Perl 5.10.0 REQUIRED)
71
72 find_package(PythonInterp 2.6.0 REQUIRED)
73 find_package(Ruby 1.8.7)
74
75 # -----------------------------------------------------------------------------
76 # Determine the target processor
77 # -----------------------------------------------------------------------------
78 string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
79 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
80     set(WTF_CPU_ARM 1)
81 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
82     set(WTF_CPU_MIPS 1)
83 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)")
84     set(WTF_CPU_X86_64 1)
85 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
86     set(WTF_CPU_X86 1)
87 else ()
88     message(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
89 endif ()
90
91 # -----------------------------------------------------------------------------
92 # Determine the operating system
93 # -----------------------------------------------------------------------------
94 if (UNIX)
95     if (APPLE)
96         set(WTF_OS_MAC_OS_X 1)
97     else ()
98         set(WTF_OS_UNIX 1)
99     endif ()
100 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
101     set(WTF_OS_WINDOWS 1)
102 elseif (CMAKE_SYSTEM_NAME MATCHES "QNX")
103     set(WTF_OS_QNX 1)
104     set(WTF_OS_UNIX 1)
105 else ()
106     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
107 endif ()
108
109 # -----------------------------------------------------------------------------
110 # Default target names (can be overrriden in Options${PORT}.cmake file)
111 # -----------------------------------------------------------------------------
112 set(JSC_EXECUTABLE_NAME JSC)
113 set(WTF_LIBRARY_NAME WTF)
114 set(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
115 set(WebCore_LIBRARY_NAME WebCore)
116 set(WebKit_LIBRARY_NAME WebKit)
117 set(WebKit2_LIBRARY_NAME WebKit2)
118 set(WebCoreTestSupport_LIBRARY_NAME WebCoreTestSupport)
119
120 # -----------------------------------------------------------------------------
121 # Default library types
122 # -----------------------------------------------------------------------------
123 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
124
125 if (SHARED_CORE)
126     set(JavaScriptCore_LIBRARY_TYPE SHARED)
127     set(WebCore_LIBRARY_TYPE SHARED)
128 else ()
129     set(JavaScriptCore_LIBRARY_TYPE STATIC)
130     set(WebCore_LIBRARY_TYPE STATIC)
131 endif ()
132
133 set(WebKit_LIBRARY_TYPE SHARED)
134 set(WebKit2_LIBRARY_TYPE SHARED)
135 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
136
137 # -----------------------------------------------------------------------------
138 # Common options
139 #------------------------------------------------------------------------------
140 include(OptionsCommon)
141 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR})
142 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR})
143 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXEC_INSTALL_DIR})
144
145 # -----------------------------------------------------------------------------
146 # Port-specific options
147 # -----------------------------------------------------------------------------
148 include(Options${PORT})
149
150 # -----------------------------------------------------------------------------
151 # Enable API unit tests and create a target for the test runner
152 # -----------------------------------------------------------------------------
153 if (ENABLE_API_TESTS)
154     enable_testing()
155 endif ()
156
157 # -----------------------------------------------------------------------------
158 # Install JavaScript shell
159 # -----------------------------------------------------------------------------
160 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
161
162 # -----------------------------------------------------------------------------
163 # Define packaging
164 # -----------------------------------------------------------------------------
165 include(WebKitPackaging)
166
167 # -----------------------------------------------------------------------------
168 # Add module directories
169 # -----------------------------------------------------------------------------
170 add_subdirectory(Source)
171
172 # -----------------------------------------------------------------------------
173 # Add tools
174 # -----------------------------------------------------------------------------
175 if (ENABLE_TOOLS)
176     add_subdirectory(Tools)
177 endif ()