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