Unreviewed. In r165709 I mistakenly appended the -fno-exceptions
[WebKit-https.git] / Source / cmake / OptionsCommon.cmake
1 add_definitions(-DBUILDING_WITH_CMAKE=1)
2 add_definitions(-DHAVE_CONFIG_H=1)
3
4 # CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS only matters with GCC >= 4.7.0.  Since this
5 # version, -P does not output empty lines, which currently breaks make_names.pl in
6 # WebCore. Investigating whether make_names.pl should be changed instead is left as an exercise to
7 # the reader.
8 if (MSVC)
9     # FIXME: Some codegenerators don't support paths with spaces. So use the executable name only.
10     get_filename_component(CODE_GENERATOR_PREPROCESSOR_EXECUTABLE ${CMAKE_CXX_COMPILER} NAME)
11     set(CODE_GENERATOR_PREPROCESSOR "${CODE_GENERATOR_PREPROCESSOR_EXECUTABLE} /nologo /EP")
12     set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CODE_GENERATOR_PREPROCESSOR}")
13 else ()
14     set(CODE_GENERATOR_PREPROCESSOR "${CMAKE_CXX_COMPILER} -E -P -x c++")
15     set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CMAKE_CXX_COMPILER} -E -x c++")
16 endif ()
17
18 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
19     set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
20     set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
21     set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
22     set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
23 endif ()
24
25 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
26
27 if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
28     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -fno-strict-aliasing")
29     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions -fno-strict-aliasing -fno-rtti")
30 endif ()
31
32 option(DEBUG_FISSION "Use Debug Fission support")
33 if (DEBUG_FISSION)
34     execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
35     if (NOT "${LD_VERSION}" MATCHES "GNU gold")
36         message(FATAL_ERROR "Need GNU gold linker for Debug Fission support")
37     endif ()
38     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gsplit-dwarf -fuse-ld=gold")
39     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf -fuse-ld=gold")
40     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
41     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
42 endif ()
43
44 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
45     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
46     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
47 endif ()
48
49 string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR)
50 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(i[3-6]86|x86)")
51     # To avoid out of memory when building with debug option in 32bit system.
52     # See https://bugs.webkit.org/show_bug.cgi?id=77327
53     set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-Wl,--no-keep-memory ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
54 endif ()
55
56 if (UNIX AND NOT APPLE)
57     set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
58 endif ()
59
60 # GTK uses the GNU installation directories as defaults.
61 if (NOT PORT STREQUAL "GTK")
62     set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Absolute path to library installation directory")
63     set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Absolute path to executable installation directory")
64     set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Absolute path to install executables executed by the library")
65 endif ()
66
67 # The Ninja generator does not yet know how to build archives in pieces, and so response
68 # files must be used to deal with very long linker command lines.
69 # See https://bugs.webkit.org/show_bug.cgi?id=129771
70 set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)