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