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