[CMake] Properly test if compiler supports compiler flags
[WebKit-https.git] / Source / cmake / WebKitCommon.cmake
1 # -----------------------------------------------------------------------------
2 # This file is included individually from various subdirectories (JSC, WTF,
3 # WebCore, WebKit) in order to allow scripts to build only part of WebKit.
4 # We want to run this file only once.
5 # -----------------------------------------------------------------------------
6 if (NOT HAS_RUN_WEBKIT_COMMON)
7     set(HAS_RUN_WEBKIT_COMMON TRUE)
8
9     # -----------------------------------------------------------------------------
10     # Find common packages (used by all ports)
11     # -----------------------------------------------------------------------------
12     if (WIN32)
13         list(APPEND CMAKE_PROGRAM_PATH $ENV{SystemDrive}/cygwin/bin)
14     endif ()
15
16     # TODO Enforce version requirement for gperf
17     find_package(Gperf 3.0.1 REQUIRED)
18
19     # TODO Enforce version requirement for perl
20     find_package(Perl 5.10.0 REQUIRED)
21
22     find_package(PythonInterp 2.7.0 REQUIRED)
23     if (PYTHON_VERSION_MAJOR GREATER 2)
24         message(FATAL_ERROR "Python 2 is required, but Python ${PYTHON_VERSION_MAJOR} was found.")
25     endif ()
26
27     # We cannot check for RUBY_FOUND because it is set only when the full package is installed and
28     # the only thing we need is the interpreter. Unlike Python, cmake does not provide a macro
29     # for finding only the Ruby interpreter.
30     find_package(Ruby 1.9)
31     if (NOT RUBY_EXECUTABLE OR RUBY_VERSION VERSION_LESS 1.9)
32         message(FATAL_ERROR "Ruby 1.9 or higher is required.")
33     endif ()
34
35     # -----------------------------------------------------------------------------
36     # Helper macros and feature defines
37     # -----------------------------------------------------------------------------
38
39     # To prevent multiple inclusion, most modules should be included once here.
40     include(CheckCCompilerFlag)
41     include(CheckCXXCompilerFlag)
42     include(CheckCXXSourceCompiles)
43     include(CheckFunctionExists)
44     include(CheckIncludeFile)
45     include(CheckSymbolExists)
46     include(CheckStructHasMember)
47     include(CheckTypeSize)
48     include(CMakeDependentOption)
49     include(CMakeParseArguments)
50     include(ProcessorCount)
51
52     include(WebKitPackaging)
53     include(WebKitMacros)
54     include(WebKitFS)
55     include(WebKitCompilerFlags)
56     include(WebKitFeatures)
57
58     include(OptionsCommon)
59     include(Options${PORT})
60
61     # -----------------------------------------------------------------------------
62     # Create derived sources directories
63     # -----------------------------------------------------------------------------
64
65     if (ENABLE_WEBCORE)
66         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBCORE_DIR})
67     endif ()
68
69     if (ENABLE_WEBKIT)
70         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKIT2_DIR})
71     endif ()
72
73     if (ENABLE_WEBKIT_LEGACY)
74         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKITLEGACY_DIR})
75         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKIT_DIR})
76     endif ()
77
78     if (ENABLE_WEBDRIVER)
79         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBDRIVER_DIR})
80     endif ()
81
82     # -----------------------------------------------------------------------------
83     # config.h
84     # -----------------------------------------------------------------------------
85     CREATE_CONFIGURATION_HEADER()
86 endif ()