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