Add CMake build infrastructure for the BlackBerry port
[WebKit-https.git] / Source / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
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 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
11
12 # -----------------------------------------------------------------------------
13 # Default library type
14 # -----------------------------------------------------------------------------
15 IF (NOT ENABLE_WEBKIT AND NOT ENABLE_WEBKIT2)
16     SET(ENABLE_WEBKIT On)
17 ENDIF ()
18
19 SET(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/JavaScriptCore")
20 SET(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/WebCore")
21 SET(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/WebKit")
22 SET(WEBKIT2_DIR "${CMAKE_SOURCE_DIR}/WebKit2")
23
24 SET(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/ThirdParty")
25 SET(TOOLS_DIR "${CMAKE_SOURCE_DIR}/../Tools")
26
27 SET(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
28 SET(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
29 SET(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
30 SET(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
31
32 INCLUDE(WebKitMacros)
33 INCLUDE(WebKitFS)
34 INCLUDE(WebKitHelpers)
35 INCLUDE(WebKitFeatures)
36
37 # -----------------------------------------------------------------------------
38 # Determine which port will be built
39 # -----------------------------------------------------------------------------
40 SET(ALL_PORTS Efl WinCE BlackBerry)
41 SET(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
42
43 LIST(FIND ALL_PORTS ${PORT} RET)
44 IF (${RET} EQUAL -1)
45     MESSAGE(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
46 ENDIF ()
47
48 STRING(TOLOWER ${PORT} WEBKIT_PORT_DIR)
49
50 # -----------------------------------------------------------------------------
51 # Find common packages (used by all ports)
52 # -----------------------------------------------------------------------------
53 FIND_PACKAGE(BISON REQUIRED)
54 FIND_PACKAGE(FLEX REQUIRED)
55 FIND_PACKAGE(Gperf REQUIRED)
56 FIND_PACKAGE(Perl REQUIRED)
57 FIND_PACKAGE(PythonInterp REQUIRED)
58
59 # -----------------------------------------------------------------------------
60 # Determine the target processor
61 # -----------------------------------------------------------------------------
62 STRING(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
63 IF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
64     SET(WTF_CPU_ARM 1)
65 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
66     SET(WTF_CPU_MIPS 1)
67 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)")
68     SET(WTF_CPU_X86_64 1)
69 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
70     SET(WTF_CPU_X86 1)
71 ELSE ()
72     MESSAGE(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
73 ENDIF ()
74
75 # -----------------------------------------------------------------------------
76 # Determine the operating system
77 # -----------------------------------------------------------------------------
78 IF (UNIX)
79     IF (APPLE)
80         SET(WTF_OS_MAC_OS_X 1)
81     ELSE ()
82         SET(WTF_OS_UNIX 1)
83     ENDIF ()
84 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
85     SET(WTF_OS_WINDOWS 1)
86 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "QNX")
87     SET(WTF_OS_QNX 1)
88     SET(WTF_OS_UNIX 1)
89 ELSE ()
90     MESSAGE(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
91 ENDIF ()
92
93 # -----------------------------------------------------------------------------
94 # Default target names (can be overrriden in Options${PORT}.cmake file)
95 # -----------------------------------------------------------------------------
96 SET(JSC_EXECUTABLE_NAME JSC)
97 SET(WTF_LIBRARY_NAME WTF)
98 SET(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
99 SET(WebCore_LIBRARY_NAME WebCore)
100 SET(WebKit_LIBRARY_NAME WebKit)
101 SET(WebKit2_LIBRARY_NAME WebKit2)
102
103 # -----------------------------------------------------------------------------
104 # Default library types
105 # -----------------------------------------------------------------------------
106 OPTION(SHARED_CORE "build WTF, JavaScriptCore and WebCore as shared libraries")
107
108 IF (SHARED_CORE)
109     SET(WTF_LIBRARY_TYPE SHARED)
110     SET(JavaScriptCore_LIBRARY_TYPE SHARED)
111     SET(WebCore_LIBRARY_TYPE SHARED)
112 ELSE ()
113     SET(WTF_LIBRARY_TYPE STATIC)
114     SET(JavaScriptCore_LIBRARY_TYPE STATIC)
115     SET(WebCore_LIBRARY_TYPE STATIC)
116 ENDIF ()
117
118 SET(WebKit_LIBRARY_TYPE SHARED)
119 SET(WebKit2_LIBRARY_TYPE SHARED)
120
121 # -----------------------------------------------------------------------------
122 # Port-specific options
123 # -----------------------------------------------------------------------------
124 INCLUDE(OptionsCommon)
125 INCLUDE(Options${PORT})
126
127 # -----------------------------------------------------------------------------
128 # Define packaging
129 # -----------------------------------------------------------------------------
130 INCLUDE(WebKitPackaging)
131
132 # -----------------------------------------------------------------------------
133 # Add module directories
134 # -----------------------------------------------------------------------------
135 ADD_SUBDIRECTORY(JavaScriptCore)
136 ADD_SUBDIRECTORY(WebCore)
137
138 IF (ENABLE_WEBKIT)
139     ADD_SUBDIRECTORY(WebKit)
140 ENDIF ()
141
142 IF (ENABLE_WEBKIT2)
143     ADD_SUBDIRECTORY(WebKit2)
144 ENDIF ()
145
146 # -----------------------------------------------------------------------------
147 # Install JavaScript shell
148 # -----------------------------------------------------------------------------
149 OPTION(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
150
151 # -----------------------------------------------------------------------------
152 # Add test browser if exists
153 # -----------------------------------------------------------------------------
154 INCLUDE_IF_EXISTS(${TOOLS_DIR}/CMakeLists${PORT}.txt)
155
156 # -----------------------------------------------------------------------------
157 # Set compiler flags for all targets
158 # -----------------------------------------------------------------------------
159 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WTF_LIBRARY_NAME})
160 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${JavaScriptCore_LIBRARY_NAME})
161 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebCore_LIBRARY_NAME})
162
163 IF (ENABLE_WEBKIT)
164     WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebKit_LIBRARY_NAME})
165 ENDIF ()
166
167 IF (ENABLE_WEBKIT2)
168     WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebKit2_LIBRARY_NAME})
169 ENDIF ()
170
171 # -----------------------------------------------------------------------------
172 # Create the configuration file
173 # -----------------------------------------------------------------------------
174 CONFIGURE_FILE(cmakeconfig.h.cmake ${CMAKE_BINARY_DIR}/cmakeconfig.h @ONLY)
175
176 # -----------------------------------------------------------------------------
177 # Prints a summary of all enabled/disabled features
178 # -----------------------------------------------------------------------------
179 WEBKIT_PRINT_FEATURES()