Merge pull request #25977 from sarbes/estuary_optimization
[xbmc.git] / cmake / modules / buildtools / LDGOLD.cmake
blobcdf71bfc002f1e5879159471f733e13b0a413978
1 if(ENABLE_GOLD)
2   execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
3   if(LD_VERSION MATCHES "GNU gold")
4     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
5     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
6     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
7     set(LDGOLD_FOUND TRUE)
8     message(STATUS "Linker: GNU gold")
9   else()
10     message(WARNING "GNU gold linker is not available, falling back to default system linker")
11   endif()
12 else()
13   message(STATUS "Linker: Default system linker")
14 endif()
16 set(DEFAULT_ENABLE_DEBUGFISSION FALSE)
17 if(CMAKE_BUILD_TYPE STREQUAL Debug OR
18    CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo AND
19    LDGOLD_FOUND)
20   set(DEFAULT_ENABLE_DEBUGFISSION TRUE)
21 endif()
23 include(CMakeDependentOption)
24 cmake_dependent_option(ENABLE_DEBUGFISSION "Enable Debug Fission support" ON
25                        "DEFAULT_ENABLE_DEBUGFISSION" OFF)
27 set(DEBUGFISSION_FOUND FALSE)
28 if(ENABLE_DEBUGFISSION)
29   include(TestCXXAcceptsFlag)
30   check_cxx_accepts_flag(-gsplit-dwarf CXX_ACCEPTS_GSPLIT_DWARF)
31   if(CXX_ACCEPTS_GSPLIT_DWARF)
32     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gsplit-dwarf")
33     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf")
34     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
35     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
36     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
37     set(DEBUGFISSION_FOUND TRUE)
38     message(STATUS "Debug Fission enabled")
39   else()
40     message(WARNING "Debug Fission is not available")
41   endif()
42 endif()