0fe87deba32bbab8e5f9177bea969a01040e2268
[WebKit-https.git] / Source / cmake / OptionsCommon.cmake
1 add_definitions(-DBUILDING_WITH_CMAKE=1)
2 add_definitions(-DHAVE_CONFIG_H=1)
3
4 if (WTF_OS_UNIX)
5     add_definitions(-DXP_UNIX)
6 endif (WTF_OS_UNIX)
7
8 # CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS only matters with GCC >= 4.7.0.  Since this
9 # version, -P does not output empty lines, which currently breaks make_names.pl in
10 # WebCore. Investigating whether make_names.pl should be changed instead is left as an exercise to
11 # the reader.
12 if (MSVC)
13     # FIXME: Some codegenerators don't support paths with spaces. So use the executable name only.
14     get_filename_component(CODE_GENERATOR_PREPROCESSOR_EXECUTABLE ${CMAKE_CXX_COMPILER} NAME)
15     set(CODE_GENERATOR_PREPROCESSOR "${CODE_GENERATOR_PREPROCESSOR_EXECUTABLE} /nologo /EP")
16     set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CODE_GENERATOR_PREPROCESSOR}")
17 elseif (CMAKE_SYSTEM_NAME MATCHES QNX)
18     set(CODE_GENERATOR_PREPROCESSOR "${CMAKE_CXX_COMPILER} -E -Wp,-P -x c++")
19     set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CODE_GENERATOR_PREPROCESSOR}")
20 else ()
21     set(CODE_GENERATOR_PREPROCESSOR "${CMAKE_CXX_COMPILER} -E -P -x c++")
22     set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CMAKE_CXX_COMPILER} -E -x c++")
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_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
29 endif ()
30
31 string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR)
32 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(i[3-6]86|x86)")
33     # To avoid out of memory when building with debug option in 32bit system.
34     # See https://bugs.webkit.org/show_bug.cgi?id=77327
35     set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-Wl,--no-keep-memory ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
36 endif ()
37
38 if (UNIX AND NOT APPLE)
39     set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
40 endif ()
41
42 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
43
44 set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Where to install libraries (lib${LIB_SUFFIX})")
45 set(EXEC_INSTALL_DIR "bin" CACHE PATH "Where to install executables")