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