2010-06-17 Kenneth Russell <kbr@google.com>
[WebKit-https.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
2 PROJECT(WebKit)
3
4 SET(CMAKE_BUILD_TYPE Release)
5 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
6
7 SET(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/JavaScriptCore")
8 SET(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/WebCore")
9 SET(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/WebKit")
10 SET(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
11
12 INCLUDE(WebKitMacros)
13 INCLUDE(WebKitGenerators)
14 INCLUDE(WebKitHelpers)
15 INCLUDE(WebKitFeatures)
16
17 # -----------------------------------------------------------------------------
18 # Determine which port will be built
19 # -----------------------------------------------------------------------------
20 OPTION(PORT "choose which WebKit port to build" "NOPORT")
21
22 # -----------------------------------------------------------------------------
23 # Find common packages (used by all ports)
24 # -----------------------------------------------------------------------------
25 FIND_PACKAGE(BISON REQUIRED)
26 FIND_PACKAGE(FLEX REQUIRED)
27 FIND_PACKAGE(Perl REQUIRED)
28 FIND_PACKAGE(PythonInterp REQUIRED)
29
30 # -----------------------------------------------------------------------------
31 # Determine the target processor
32 # -----------------------------------------------------------------------------
33 IF (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
34     SET(WTF_CPU_ARM 1)
35 ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)")
36     SET(WTF_CPU_X86_64 1)
37 ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
38     SET(WTF_CPU_X86 1)
39 ELSE ()
40     MESSAGE(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
41 ENDIF ()
42
43 # -----------------------------------------------------------------------------
44 # Determine the operating system
45 # -----------------------------------------------------------------------------
46 IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
47     SET(WTF_OS_UNIX 1)
48
49     IF (APPLE)
50         SET(WTF_OS_MAC_OS_X 1)
51     ENDIF ()
52 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
53     SET(WTF_OS_WINDOWS 1)
54 ELSE ()
55     MESSAGE(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
56 ENDIF ()
57
58 # -----------------------------------------------------------------------------
59 # Default target names (can be overrriden in Options${PORT}.cmake file)
60 # -----------------------------------------------------------------------------
61 SET(JSC_EXECUTABLE_NAME JSC)
62 SET(WTF_LIBRARY_NAME WTF)
63 SET(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
64 SET(WebCore_LIBRARY_NAME WebCore)
65 SET(WebKit_LIBRARY_NAME WebKit)
66
67 # -----------------------------------------------------------------------------
68 # Default library types
69 # -----------------------------------------------------------------------------
70 OPTION(SHARED_CORE "build WTF, JavaScriptCore and WebCore as shared libraries")
71
72 IF (SHARED_CORE)
73     SET(WTF_LIBRARY_TYPE SHARED)
74     SET(JavaScriptCore_LIBRARY_TYPE SHARED)
75     SET(WebCore_LIBRARY_TYPE SHARED)
76 ELSE ()
77     SET(WTF_LIBRARY_TYPE STATIC)
78     SET(JavaScriptCore_LIBRARY_TYPE STATIC)
79     SET(WebCore_LIBRARY_TYPE STATIC)
80 ENDIF ()
81
82 SET(WebKit_LIBRARY_TYPE SHARED)
83
84 # -----------------------------------------------------------------------------
85 # Port-specific options
86 # -----------------------------------------------------------------------------
87 INCLUDE(OptionsCommon)
88 INCLUDE(Options${PORT})
89
90 # -----------------------------------------------------------------------------
91 # Add module directories
92 # -----------------------------------------------------------------------------
93 ADD_SUBDIRECTORY(JavaScriptCore)
94 ADD_SUBDIRECTORY(WebCore)
95 ADD_SUBDIRECTORY(WebKit)
96
97 # -----------------------------------------------------------------------------
98 # Set compiler flags for all targets
99 # -----------------------------------------------------------------------------
100 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WTF_LIBRARY_NAME})
101 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${JavaScriptCore_LIBRARY_NAME})
102 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebCore_LIBRARY_NAME})
103 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebKit_LIBRARY_NAME})
104
105 # -----------------------------------------------------------------------------
106 # Create the configuration file
107 # -----------------------------------------------------------------------------
108 CONFIGURE_FILE(cmakeconfig.h.cmake ${CMAKE_BINARY_DIR}/cmakeconfig.h @ONLY)
109
110 # -----------------------------------------------------------------------------
111 # Prints a summary of all enabled/disabled features
112 # -----------------------------------------------------------------------------
113 WEBKIT_PRINT_FEATURES()