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