[GTK] Add a basic cmake build for WTF and JavaScriptCore
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.3)
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
22 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
23
24 set(ENABLE_WEBCORE ON)
25
26 if (NOT DEFINED ENABLE_WEBKIT)
27     set(ENABLE_WEBKIT ON)
28 endif ()
29
30 if (NOT DEFINED ENABLE_TOOLS AND EXISTS ${TOOLS_DIR})
31     set(ENABLE_TOOLS ON)
32 endif ()
33
34 include(WebKitMacros)
35 include(WebKitFS)
36 include(WebKitHelpers)
37 include(WebKitFeatures)
38
39 # -----------------------------------------------------------------------------
40 # Determine which port will be built
41 # -----------------------------------------------------------------------------
42 set(ALL_PORTS Efl WinCE BlackBerry GTK)
43 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
44
45 list(FIND ALL_PORTS ${PORT} RET)
46 if (${RET} EQUAL -1)
47     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
48 endif ()
49
50 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
51
52 # -----------------------------------------------------------------------------
53 # Find common packages (used by all ports)
54 # -----------------------------------------------------------------------------
55 find_package(BISON 2.4.1 REQUIRED)
56 find_package(FLEX 2.5.34 REQUIRED)
57
58 # TODO Enforce version requirement for gperf
59 find_package(Gperf 3.0.1 REQUIRED)
60
61 # TODO Enforce version requirement for perl
62 find_package(Perl 5.10.0 REQUIRED)
63
64 find_package(PythonInterp 2.6.0 REQUIRED)
65 find_package(Ruby 1.8.7)
66
67 # -----------------------------------------------------------------------------
68 # Determine the target processor
69 # -----------------------------------------------------------------------------
70 string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
71 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
72     set(WTF_CPU_ARM 1)
73 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
74     set(WTF_CPU_MIPS 1)
75 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)")
76     set(WTF_CPU_X86_64 1)
77 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
78     set(WTF_CPU_X86 1)
79 else ()
80     message(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
81 endif ()
82
83 # -----------------------------------------------------------------------------
84 # Determine the operating system
85 # -----------------------------------------------------------------------------
86 if (UNIX)
87     if (APPLE)
88         set(WTF_OS_MAC_OS_X 1)
89     else ()
90         set(WTF_OS_UNIX 1)
91     endif ()
92 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
93     set(WTF_OS_WINDOWS 1)
94 elseif (CMAKE_SYSTEM_NAME MATCHES "QNX")
95     set(WTF_OS_QNX 1)
96     set(WTF_OS_UNIX 1)
97 else ()
98     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
99 endif ()
100
101 # -----------------------------------------------------------------------------
102 # Default target names (can be overrriden in Options${PORT}.cmake file)
103 # -----------------------------------------------------------------------------
104 set(JSC_EXECUTABLE_NAME JSC)
105 set(WTF_LIBRARY_NAME WTF)
106 set(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
107 set(WebCore_LIBRARY_NAME WebCore)
108 set(WebKit_LIBRARY_NAME WebKit)
109 set(WebKit2_LIBRARY_NAME WebKit2)
110 set(WebCoreTestSupport_LIBRARY_NAME WebCoreTestSupport)
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     set(JavaScriptCore_LIBRARY_TYPE STATIC)
122     set(WebCore_LIBRARY_TYPE STATIC)
123 endif ()
124
125 set(WebKit_LIBRARY_TYPE SHARED)
126 set(WebKit2_LIBRARY_TYPE SHARED)
127 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
128
129 # -----------------------------------------------------------------------------
130 # Common options
131 #------------------------------------------------------------------------------
132 include(OptionsCommon)
133 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR})
134 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR})
135 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXEC_INSTALL_DIR})
136
137 # -----------------------------------------------------------------------------
138 # Port-specific options
139 # -----------------------------------------------------------------------------
140 include(Options${PORT})
141
142 # -----------------------------------------------------------------------------
143 # Enable API unit tests and create a target for the test runner
144 # -----------------------------------------------------------------------------
145 if (ENABLE_API_TESTS)
146     enable_testing()
147 endif ()
148
149 # -----------------------------------------------------------------------------
150 # Install JavaScript shell
151 # -----------------------------------------------------------------------------
152 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
153
154 # -----------------------------------------------------------------------------
155 # Define packaging
156 # -----------------------------------------------------------------------------
157 include(WebKitPackaging)
158
159 # -----------------------------------------------------------------------------
160 # Add module directories
161 # -----------------------------------------------------------------------------
162 add_subdirectory(Source)
163
164 # -----------------------------------------------------------------------------
165 # Add tools
166 # -----------------------------------------------------------------------------
167 if (ENABLE_TOOLS)
168     add_subdirectory(Tools)
169 endif ()