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