[CMake] Detect amd64 as a valid 64-bit architecture.
[WebKit.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)
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 # -----------------------------------------------------------------------------
49 # Find common packages (used by all ports)
50 # -----------------------------------------------------------------------------
51 FIND_PACKAGE(BISON REQUIRED)
52 FIND_PACKAGE(FLEX REQUIRED)
53 FIND_PACKAGE(Gperf REQUIRED)
54 FIND_PACKAGE(Perl REQUIRED)
55 FIND_PACKAGE(PythonInterp REQUIRED)
56
57 # -----------------------------------------------------------------------------
58 # Determine the target processor
59 # -----------------------------------------------------------------------------
60 STRING(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
61 IF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
62     SET(WTF_CPU_ARM 1)
63 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
64     SET(WTF_CPU_MIPS 1)
65 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)")
66     SET(WTF_CPU_X86_64 1)
67 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
68     SET(WTF_CPU_X86 1)
69 ELSE ()
70     MESSAGE(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
71 ENDIF ()
72
73 # -----------------------------------------------------------------------------
74 # Determine the operating system
75 # -----------------------------------------------------------------------------
76 IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
77     SET(WTF_OS_UNIX 1)
78
79     IF (APPLE)
80         SET(WTF_OS_MAC_OS_X 1)
81     ENDIF ()
82 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
83     SET(WTF_OS_WINDOWS 1)
84 ELSE ()
85     MESSAGE(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
86 ENDIF ()
87
88 # -----------------------------------------------------------------------------
89 # Default target names (can be overrriden in Options${PORT}.cmake file)
90 # -----------------------------------------------------------------------------
91 SET(JSC_EXECUTABLE_NAME JSC)
92 SET(WTF_LIBRARY_NAME WTF)
93 SET(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
94 SET(WebCore_LIBRARY_NAME WebCore)
95 SET(WebKit_LIBRARY_NAME WebKit)
96 SET(WebKit2_LIBRARY_NAME WebKit2)
97
98 # -----------------------------------------------------------------------------
99 # Default library types
100 # -----------------------------------------------------------------------------
101 OPTION(SHARED_CORE "build WTF, JavaScriptCore and WebCore as shared libraries")
102
103 IF (SHARED_CORE)
104     SET(WTF_LIBRARY_TYPE SHARED)
105     SET(JavaScriptCore_LIBRARY_TYPE SHARED)
106     SET(WebCore_LIBRARY_TYPE SHARED)
107 ELSE ()
108     SET(WTF_LIBRARY_TYPE STATIC)
109     SET(JavaScriptCore_LIBRARY_TYPE STATIC)
110     SET(WebCore_LIBRARY_TYPE STATIC)
111 ENDIF ()
112
113 SET(WebKit_LIBRARY_TYPE SHARED)
114 SET(WebKit2_LIBRARY_TYPE SHARED)
115
116 # -----------------------------------------------------------------------------
117 # Port-specific options
118 # -----------------------------------------------------------------------------
119 INCLUDE(OptionsCommon)
120 INCLUDE(Options${PORT})
121
122 # -----------------------------------------------------------------------------
123 # Define packaging
124 # -----------------------------------------------------------------------------
125 INCLUDE(WebKitPackaging)
126
127 # -----------------------------------------------------------------------------
128 # Add module directories
129 # -----------------------------------------------------------------------------
130 ADD_SUBDIRECTORY(JavaScriptCore)
131 ADD_SUBDIRECTORY(WebCore)
132
133 IF (ENABLE_WEBKIT)
134     ADD_SUBDIRECTORY(WebKit)
135 ENDIF ()
136
137 IF (ENABLE_WEBKIT2)
138     ADD_SUBDIRECTORY(WebKit2)
139 ENDIF ()
140
141 # -----------------------------------------------------------------------------
142 # Add test browser if exists
143 # -----------------------------------------------------------------------------
144 INCLUDE_IF_EXISTS(${TOOLS_DIR}/CMakeLists${PORT}.txt)
145
146 # -----------------------------------------------------------------------------
147 # Set compiler flags for all targets
148 # -----------------------------------------------------------------------------
149 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WTF_LIBRARY_NAME})
150 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${JavaScriptCore_LIBRARY_NAME})
151 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebCore_LIBRARY_NAME})
152
153 IF (ENABLE_WEBKIT)
154     WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebKit_LIBRARY_NAME})
155 ENDIF ()
156
157 IF (ENABLE_WEBKIT2)
158     WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebKit2_LIBRARY_NAME})
159 ENDIF ()
160
161 # -----------------------------------------------------------------------------
162 # Create the configuration file
163 # -----------------------------------------------------------------------------
164 CONFIGURE_FILE(cmakeconfig.h.cmake ${CMAKE_BINARY_DIR}/cmakeconfig.h @ONLY)
165
166 # -----------------------------------------------------------------------------
167 # Prints a summary of all enabled/disabled features
168 # -----------------------------------------------------------------------------
169 WEBKIT_PRINT_FEATURES()