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