[CMake] Use thin archives if building on Linux for non-shared-core debug builds
[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 else ()
18     set(CODE_GENERATOR_PREPROCESSOR "${CMAKE_CXX_COMPILER} -E -P -x c++")
19     set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CMAKE_CXX_COMPILER} -E -x c++")
20 endif ()
21
22 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
23     set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
24     set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
25     set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
26     set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
27 endif ()
28
29 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
30
31 if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
32     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
33 endif ()
34
35 string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR)
36 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(i[3-6]86|x86)")
37     # To avoid out of memory when building with debug option in 32bit system.
38     # See https://bugs.webkit.org/show_bug.cgi?id=77327
39     set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-Wl,--no-keep-memory ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
40 endif ()
41
42 if (UNIX AND NOT APPLE)
43     set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
44 endif ()
45
46 # GTK uses the GNU installation directories.
47 if (NOT PORT STREQUAL "GTK")
48     set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
49     set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Where to install libraries (lib${LIB_SUFFIX})")
50     set(EXEC_INSTALL_DIR "bin" CACHE PATH "Where to install executables")
51     set(LIBEXEC_INSTALL_DIR "bin" CACHE PATH "Where to install executables executed by the library")
52 endif ()