d5832158a683da99964d64f8274ee318f09acee5
[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 Efl GTK AppleWin WinCairo Mac)
23 set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
24
25 list(FIND ALL_PORTS ${PORT} RET)
26 if (${RET} EQUAL -1)
27     message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
28 endif ()
29
30 string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
31
32 # -----------------------------------------------------------------------------
33 # Determine the target processor
34 # -----------------------------------------------------------------------------
35 # Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
36 # since the later one just resolves to the host processor on Windows.
37 if (MSVC_CXX_ARCHITECTURE_ID)
38     string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
39 else ()
40     string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
41 endif ()
42 if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
43     set(WTF_CPU_ARM 1)
44 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
45     set(WTF_CPU_ARM64 1)
46 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
47     set(WTF_CPU_MIPS 1)
48 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sh4")
49     set(WTF_CPU_SH4 1)
50 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
51     set(WTF_CPU_X86_64 1)
52 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
53     set(WTF_CPU_X86 1)
54 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
55     set(WTF_CPU_PPC 1)
56 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
57     set(WTF_CPU_PPC64 1)
58 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
59     set(WTF_CPU_PPC64LE 1)
60 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "parisc*")
61     set(WTF_CPU_HPPA 1)
62 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390")
63     set(WTF_CPU_S390 1)
64 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
65     set(WTF_CPU_S390X 1)
66 else ()
67     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
68 endif ()
69
70 # -----------------------------------------------------------------------------
71 # Determine the operating system
72 # -----------------------------------------------------------------------------
73 if (UNIX)
74     if (APPLE)
75         set(WTF_OS_MAC_OS_X 1)
76     else ()
77         set(WTF_OS_UNIX 1)
78     endif ()
79 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
80     set(WTF_OS_WINDOWS 1)
81 else ()
82     message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
83 endif ()
84
85 # -----------------------------------------------------------------------------
86 # Default library types
87 # -----------------------------------------------------------------------------
88 option(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
89
90 if (SHARED_CORE)
91     set(JavaScriptCore_LIBRARY_TYPE SHARED)
92     set(WebCore_LIBRARY_TYPE SHARED)
93 else ()
94     set(JavaScriptCore_LIBRARY_TYPE SHARED)
95     set(WebCore_LIBRARY_TYPE STATIC)
96 endif ()
97
98 set(WebKit_LIBRARY_TYPE SHARED)
99 set(WebKit2_LIBRARY_TYPE SHARED)
100 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
101
102 # -----------------------------------------------------------------------------
103 # Install JavaScript shell
104 # -----------------------------------------------------------------------------
105 option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
106
107 # -----------------------------------------------------------------------------
108 # Output directories
109 #------------------------------------------------------------------------------
110 if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
111     set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
112 endif ()
113 if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
114     set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
115 endif ()
116 if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
117     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
118 endif ()
119
120 # -----------------------------------------------------------------------------
121 # Common configuration
122 #------------------------------------------------------------------------------
123 include(WebKitCommon)
124
125 # -----------------------------------------------------------------------------
126 # Enable API unit tests and create a target for the test runner
127 # -----------------------------------------------------------------------------
128 if (ENABLE_API_TESTS)
129     enable_testing()
130 endif ()
131
132 # -----------------------------------------------------------------------------
133 # Define packaging
134 # -----------------------------------------------------------------------------
135 include(WebKitPackaging)
136
137 # -----------------------------------------------------------------------------
138 # Add module directories
139 # -----------------------------------------------------------------------------
140 add_subdirectory(Source)
141
142 # -----------------------------------------------------------------------------
143 # Add tools
144 # -----------------------------------------------------------------------------
145 if (ENABLE_TOOLS)
146     add_subdirectory(Tools)
147 endif ()
148
149 # -----------------------------------------------------------------------------
150 # Print the features list last, for maximum visibility.
151 # -----------------------------------------------------------------------------
152 PRINT_WEBKIT_OPTIONS()