[sh4] Add sh4 support when building with CMake.
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.3)
2 project(WebKit)
3
4 # -----------------------------------------------------------------------------
5 # Default library type
6 # -----------------------------------------------------------------------------
7 set(WTF_DIR "${CMAKE_SOURCE_DIR}/Source/WTF")
8 set(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/Source/JavaScriptCore")
9 set(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/Source/WebCore")
10 set(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit")
11 set(WEBKIT2_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit2")
12 set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/Source/ThirdParty")
13
14 set(TOOLS_DIR "${CMAKE_SOURCE_DIR}/Tools")
15
16 set(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
17 set(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
18 set(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
19 set(DERIVED_SOURCES_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit")
20 set(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
21
22 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
23
24 set(ENABLE_WEBCORE ON)
25
26 if (NOT DEFINED ENABLE_WEBKIT)
27     set(ENABLE_WEBKIT ON)
28 endif ()
29
30 if (NOT DEFINED ENABLE_TOOLS AND EXISTS ${TOOLS_DIR})
31     set(ENABLE_TOOLS ON)
32 endif ()
33
34 include(WebKitMacros)
35 include(WebKitFS)
36 include(WebKitHelpers)
37 include(WebKitFeatures)
38
39 # -----------------------------------------------------------------------------
40 # Determine which port will be built
41 # -----------------------------------------------------------------------------
42 set(ALL_PORTS Efl WinCE BlackBerry GTK)
43 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
44
45 list(FIND ALL_PORTS ${PORT} RET)
46 if (${RET} EQUAL -1)
47     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
48 endif ()
49
50 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
51
52 # -----------------------------------------------------------------------------
53 # Find common packages (used by all ports)
54 # -----------------------------------------------------------------------------
55 find_package(BISON 2.4.1 REQUIRED)
56 find_package(FLEX 2.5.34 REQUIRED)
57
58 # TODO Enforce version requirement for gperf
59 find_package(Gperf 3.0.1 REQUIRED)
60
61 # TODO Enforce version requirement for perl
62 find_package(Perl 5.10.0 REQUIRED)
63
64 find_package(PythonInterp 2.6.0 REQUIRED)
65 find_package(Ruby 1.8.7)
66
67 # -----------------------------------------------------------------------------
68 # Determine the target processor
69 # -----------------------------------------------------------------------------
70 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
71 # since the later one just resolves to the host processor on Windows.
72 if (MSVC_CXX_ARCHITECTURE_ID)
73     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
74 else ()
75     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
76 endif ()
77 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
78     set(WTF_CPU_ARM 1)
79 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
80     set(WTF_CPU_MIPS 1)
81 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
82     set(WTF_CPU_SH4 1)
83 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
84     set(WTF_CPU_X86_64 1)
85 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
86     set(WTF_CPU_X86 1)
87 else ()
88     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
89 endif ()
90
91 # -----------------------------------------------------------------------------
92 # Determine the operating system
93 # -----------------------------------------------------------------------------
94 if (UNIX)
95     if (APPLE)
96         set(WTF_OS_MAC_OS_X 1)
97     else ()
98         set(WTF_OS_UNIX 1)
99     endif ()
100 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
101     set(WTF_OS_WINDOWS 1)
102 elseif (CMAKE_SYSTEM_NAME MATCHES "QNX")
103     set(WTF_OS_QNX 1)
104     set(WTF_OS_UNIX 1)
105 else ()
106     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
107 endif ()
108
109 # -----------------------------------------------------------------------------
110 # Default library types
111 # -----------------------------------------------------------------------------
112 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
113
114 if (SHARED_CORE)
115     set(JavaScriptCore_LIBRARY_TYPE SHARED)
116     set(WebCore_LIBRARY_TYPE SHARED)
117 else ()
118     set(JavaScriptCore_LIBRARY_TYPE STATIC)
119     set(WebCore_LIBRARY_TYPE STATIC)
120 endif ()
121
122 set(WebKit_LIBRARY_TYPE SHARED)
123 set(WebKit2_LIBRARY_TYPE SHARED)
124 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
125
126 # -----------------------------------------------------------------------------
127 # Common options
128 #------------------------------------------------------------------------------
129 include(OptionsCommon)
130 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR})
131 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_INSTALL_DIR})
132 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXEC_INSTALL_DIR})
133
134 # -----------------------------------------------------------------------------
135 # Port-specific options
136 # -----------------------------------------------------------------------------
137 include(Options${PORT})
138
139 # -----------------------------------------------------------------------------
140 # Enable API unit tests and create a target for the test runner
141 # -----------------------------------------------------------------------------
142 if (ENABLE_API_TESTS)
143     enable_testing()
144 endif ()
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 ()