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