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