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