[CMake] Use jsc target instead of ONLY_BUILD_JAVASCRIPTCORE
[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
11 # -----------------------------------------------------------------------------
12 # Default library type
13 # -----------------------------------------------------------------------------
14 SET(ENABLE_WEBCORE ON)
15
16 IF (NOT ENABLE_WEBKIT AND NOT ENABLE_WEBKIT2)
17     SET(ENABLE_WEBKIT ON)
18 ENDIF ()
19
20 SET(ENABLE_TOOLS ON)
21
22 SET(WTF_DIR "${CMAKE_SOURCE_DIR}/Source/WTF")
23 SET(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/Source/JavaScriptCore")
24 SET(WEBCORE_DIR "${CMAKE_SOURCE_DIR}/Source/WebCore")
25 SET(WEBKIT_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit")
26 SET(WEBKIT2_DIR "${CMAKE_SOURCE_DIR}/Source/WebKit2")
27 SET(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/Source/ThirdParty")
28
29 SET(TOOLS_DIR "${CMAKE_SOURCE_DIR}/Tools")
30
31 SET(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
32 SET(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
33 SET(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
34 SET(DERIVED_SOURCES_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit")
35 SET(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2")
36
37 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
38
39 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
40 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
41 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
42
43 INCLUDE(WebKitMacros)
44 INCLUDE(WebKitFS)
45 INCLUDE(WebKitHelpers)
46 INCLUDE(WebKitFeatures)
47
48 # -----------------------------------------------------------------------------
49 # Determine which port will be built
50 # -----------------------------------------------------------------------------
51 SET(ALL_PORTS Efl WinCE BlackBerry)
52 SET(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
53
54 LIST(FIND ALL_PORTS ${PORT} RET)
55 IF (${RET} EQUAL -1)
56     MESSAGE(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
57 ENDIF ()
58
59 STRING(TOLOWER ${PORT} WEBKIT_PORT_DIR)
60
61 # -----------------------------------------------------------------------------
62 # Find common packages (used by all ports)
63 # -----------------------------------------------------------------------------
64 FIND_PACKAGE(BISON REQUIRED)
65 FIND_PACKAGE(FLEX REQUIRED)
66 FIND_PACKAGE(Gperf REQUIRED)
67 FIND_PACKAGE(Perl REQUIRED)
68 FIND_PACKAGE(PythonInterp REQUIRED)
69
70 # -----------------------------------------------------------------------------
71 # Determine the target processor
72 # -----------------------------------------------------------------------------
73 STRING(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
74 IF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
75     SET(WTF_CPU_ARM 1)
76 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
77     SET(WTF_CPU_MIPS 1)
78 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)")
79     SET(WTF_CPU_X86_64 1)
80 ELSEIF (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
81     SET(WTF_CPU_X86 1)
82 ELSE ()
83     MESSAGE(FATAL_ERROR "Unknown CPU '${CMAKE_SYSTEM_PROCESSOR}'")
84 ENDIF ()
85
86 # -----------------------------------------------------------------------------
87 # Determine the operating system
88 # -----------------------------------------------------------------------------
89 IF (UNIX)
90     IF (APPLE)
91         SET(WTF_OS_MAC_OS_X 1)
92     ELSE ()
93         SET(WTF_OS_UNIX 1)
94     ENDIF ()
95 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
96     SET(WTF_OS_WINDOWS 1)
97 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "QNX")
98     SET(WTF_OS_QNX 1)
99     SET(WTF_OS_UNIX 1)
100 ELSE ()
101     MESSAGE(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
102 ENDIF ()
103
104 # -----------------------------------------------------------------------------
105 # Default target names (can be overrriden in Options${PORT}.cmake file)
106 # -----------------------------------------------------------------------------
107 SET(JSC_EXECUTABLE_NAME JSC)
108 SET(WTF_LIBRARY_NAME WTF)
109 SET(JavaScriptCore_LIBRARY_NAME JavaScriptCore)
110 SET(WebCore_LIBRARY_NAME WebCore)
111 SET(WebKit_LIBRARY_NAME WebKit)
112 SET(WebKit2_LIBRARY_NAME WebKit2)
113 SET(WebCoreTestSupport_LIBRARY_NAME WebCoreTestSupport)
114
115 # -----------------------------------------------------------------------------
116 # Default library types
117 # -----------------------------------------------------------------------------
118 OPTION(SHARED_CORE "build JavaScriptCore and WebCore as shared libraries")
119
120 IF (SHARED_CORE)
121     SET(JavaScriptCore_LIBRARY_TYPE SHARED)
122     SET(WebCore_LIBRARY_TYPE SHARED)
123 ELSE ()
124     SET(JavaScriptCore_LIBRARY_TYPE STATIC)
125     SET(WebCore_LIBRARY_TYPE STATIC)
126 ENDIF ()
127
128 SET(WebKit_LIBRARY_TYPE SHARED)
129 SET(WebKit2_LIBRARY_TYPE SHARED)
130 SET(WebCoreTestSupport_LIBRARY_TYPE STATIC)
131
132 # -----------------------------------------------------------------------------
133 # Port-specific options
134 # -----------------------------------------------------------------------------
135 INCLUDE(OptionsCommon)
136 INCLUDE(Options${PORT})
137
138 # -----------------------------------------------------------------------------
139 # Install JavaScript shell
140 # -----------------------------------------------------------------------------
141 OPTION(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
142
143 # -----------------------------------------------------------------------------
144 # Define packaging
145 # -----------------------------------------------------------------------------
146 INCLUDE(WebKitPackaging)
147
148 # -----------------------------------------------------------------------------
149 # Add module directories
150 # -----------------------------------------------------------------------------
151 ADD_SUBDIRECTORY(Source)
152
153 # -----------------------------------------------------------------------------
154 # Add tools
155 # -----------------------------------------------------------------------------
156 IF (ENABLE_TOOLS)
157     ADD_SUBDIRECTORY(Tools)
158 ENDIF ()
159