2010-06-23 Leandro Pereira <leandro@profusion.mobi>
[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(Perl REQUIRED)
31 FIND_PACKAGE(PythonInterp REQUIRED)
32
33 # -----------------------------------------------------------------------------
34 # Determine the target processor
35 # -----------------------------------------------------------------------------
36 IF (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
37     SET(WTF_CPU_ARM 1)
38 ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)")
39     SET(WTF_CPU_X86_64 1)
40 ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
41     SET(WTF_CPU_X86 1)
42 ELSE ()
43     MESSAGE(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
44 ENDIF ()
45
46 # -----------------------------------------------------------------------------
47 # Determine the operating system
48 # -----------------------------------------------------------------------------
49 IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
50     SET(WTF_OS_UNIX 1)
51
52     IF (APPLE)
53         SET(WTF_OS_MAC_OS_X 1)
54     ENDIF ()
55 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
56     SET(WTF_OS_WINDOWS 1)
57 ELSE ()
58     MESSAGE(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
59 ENDIF ()
60
61 # -----------------------------------------------------------------------------
62 # Default target names (can be overrriden in Options${PORT}.cmake file)
63 # -----------------------------------------------------------------------------
64 SET(JSC_EXECUTABLE_NAME JSC)
65 SET(WTF_LIBRARY_NAME WTF)
66 SET(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
67 SET(WebCore_LIBRARY_NAME WebCore)
68 SET(WebKit_LIBRARY_NAME WebKit)
69
70 # -----------------------------------------------------------------------------
71 # Default library types
72 # -----------------------------------------------------------------------------
73 OPTION(SHARED_CORE "build WTF, JavaScriptCore and WebCore as shared libraries")
74
75 IF (SHARED_CORE)
76     SET(WTF_LIBRARY_TYPE SHARED)
77     SET(JavaScriptCore_LIBRARY_TYPE SHARED)
78     SET(WebCore_LIBRARY_TYPE SHARED)
79 ELSE ()
80     SET(WTF_LIBRARY_TYPE STATIC)
81     SET(JavaScriptCore_LIBRARY_TYPE STATIC)
82     SET(WebCore_LIBRARY_TYPE STATIC)
83 ENDIF ()
84
85 SET(WebKit_LIBRARY_TYPE SHARED)
86
87 # -----------------------------------------------------------------------------
88 # Port-specific options
89 # -----------------------------------------------------------------------------
90 INCLUDE(OptionsCommon)
91 INCLUDE(Options${PORT})
92
93 # -----------------------------------------------------------------------------
94 # Define packaging
95 # -----------------------------------------------------------------------------
96 INCLUDE(WebKitPackaging)
97
98 # -----------------------------------------------------------------------------
99 # Add module directories
100 # -----------------------------------------------------------------------------
101 ADD_SUBDIRECTORY(JavaScriptCore)
102 ADD_SUBDIRECTORY(WebCore)
103 ADD_SUBDIRECTORY(WebKit)
104
105 # -----------------------------------------------------------------------------
106 # Set compiler flags for all targets
107 # -----------------------------------------------------------------------------
108 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WTF_LIBRARY_NAME})
109 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${JavaScriptCore_LIBRARY_NAME})
110 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebCore_LIBRARY_NAME})
111 WEBKIT_SET_EXTRA_COMPILER_FLAGS(${WebKit_LIBRARY_NAME})
112
113 # -----------------------------------------------------------------------------
114 # Create the configuration file
115 # -----------------------------------------------------------------------------
116 CONFIGURE_FILE(cmakeconfig.h.cmake ${CMAKE_BINARY_DIR}/cmakeconfig.h @ONLY)
117
118 # -----------------------------------------------------------------------------
119 # Prints a summary of all enabled/disabled features
120 # -----------------------------------------------------------------------------
121 WEBKIT_PRINT_FEATURES()