Added new port JSCOnly.
[WebKit-https.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12)
2 project(WebKit)
3
4 # This should be removed once we require CMake 3.3.
5 if (POLICY CMP0058)
6     cmake_policy(SET CMP0058 NEW)
7 endif ()
8
9 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
10
11 if (NOT DEFINED ENABLE_WEBKIT)
12     set(ENABLE_WEBKIT ON)
13 endif ()
14
15 if (NOT DEFINED ENABLE_TOOLS AND EXISTS "${CMAKE_SOURCE_DIR}/Tools")
16     set(ENABLE_TOOLS ON)
17 endif ()
18
19 # -----------------------------------------------------------------------------
20 # Determine which port will be built
21 # -----------------------------------------------------------------------------
22 set(ALL_PORTS
23     AppleWin
24     Efl
25     GTK
26     JSCOnly
27     Mac
28     WinCairo
29 )
30 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
31
32 list(FIND ALL_PORTS ${PORT} RET)
33 if (${RET} EQUAL -1)
34     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
35 endif ()
36
37 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
38
39 # -----------------------------------------------------------------------------
40 # Determine the target processor
41 # -----------------------------------------------------------------------------
42 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
43 # since the later one just resolves to the host processor on Windows.
44 if (MSVC_CXX_ARCHITECTURE_ID)
45     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
46 else ()
47     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
48 endif ()
49 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
50     set(WTF_CPU_ARM 1)
51 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
52     set(WTF_CPU_ARM64 1)
53 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
54     set(WTF_CPU_MIPS 1)
55 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
56     set(WTF_CPU_SH4 1)
57 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
58     set(WTF_CPU_X86_64 1)
59 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
60     set(WTF_CPU_X86 1)
61 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
62     set(WTF_CPU_PPC 1)
63 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
64     set(WTF_CPU_PPC64 1)
65 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
66     set(WTF_CPU_PPC64LE 1)
67 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "parisc*")
68     set(WTF_CPU_HPPA 1)
69 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390")
70     set(WTF_CPU_S390 1)
71 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
72     set(WTF_CPU_S390X 1)
73 else ()
74     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
75 endif ()
76
77 # -----------------------------------------------------------------------------
78 # Determine the operating system
79 # -----------------------------------------------------------------------------
80 if (UNIX)
81     if (APPLE)
82         set(WTF_OS_MAC_OS_X 1)
83     else ()
84         set(WTF_OS_UNIX 1)
85     endif ()
86 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
87     set(WTF_OS_WINDOWS 1)
88 else ()
89     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
90 endif ()
91
92 # -----------------------------------------------------------------------------
93 # Default library types
94 # -----------------------------------------------------------------------------
95 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
96
97 if (SHARED_CORE)
98     set(JavaScriptCore_LIBRARY_TYPE SHARED)
99     set(WebCore_LIBRARY_TYPE SHARED)
100 else ()
101     set(JavaScriptCore_LIBRARY_TYPE SHARED)
102     set(WebCore_LIBRARY_TYPE STATIC)
103 endif ()
104
105 set(WebKit_LIBRARY_TYPE SHARED)
106 set(WebKit2_LIBRARY_TYPE SHARED)
107 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
108
109 # -----------------------------------------------------------------------------
110 # Install JavaScript shell
111 # -----------------------------------------------------------------------------
112 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
113
114 # -----------------------------------------------------------------------------
115 # Default output directories, which can be overwritten by ports
116 #------------------------------------------------------------------------------
117 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
118 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
119 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
120
121 # -----------------------------------------------------------------------------
122 # Common configuration
123 #------------------------------------------------------------------------------
124 include(WebKitCommon)
125
126 # -----------------------------------------------------------------------------
127 # Enable API unit tests and create a target for the test runner
128 # -----------------------------------------------------------------------------
129 if (ENABLE_API_TESTS)
130     enable_testing()
131 endif ()
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 if (ENABLE_TOOLS)
147     add_subdirectory(Tools)
148 endif ()
149
150 # -----------------------------------------------------------------------------
151 # Print the features list last, for maximum visibility.
152 # -----------------------------------------------------------------------------
153 PRINT_WEBKIT_OPTIONS()