OSDN Git Service

[BUILD][CMAKE] .
[csp-qt/common_source_project-fm7.git] / source / build-cmake / 3rdparty / SetMSVCDebugPath.cmake
1 # Split debug information from an executable into a separate file.
2 # SPLIT_DEBUG_INFORMATION(EXE_TARGET)
3 #
4 # References:
5 # - http://cmake.3232098.n2.nabble.com/Save-stripped-debugging-information-td6819195.html
6 # - http://sourceware.org/bugzilla/show_bug.cgi?id=14527
7 #   - If debug symbols are stripped before .gnu_debuglink is added,
8 #     the section will be truncated to .gnu_deb, and hence won't
9 #     be recognized by gdb.
10 # - FIXME: If the above .gnu_debuglink workaround is used, Windows XP
11 #   and Windows 7 will claim that the executable isn't a valid Win32
12 #   executable. (Wine ignores it and works fine!)
13 #
14 MACRO(SET_MSVC_DEBUG_PATH _target)
15 IF(MSVC)
16         # CMake seems to use weird settings for the PDB file.
17         # (at least version 2.8.12.2; 3.0.0 might be different)
18         STRING(REGEX REPLACE
19                 "/Fd<OBJECT_DIR>/"
20                 "/Fd<TARGET_PDB>"
21                 CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
22         STRING(REGEX REPLACE
23                 "/Fd<OBJECT_DIR>/"
24                 "/Fd<TARGET_PDB>"
25                 CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
26
27         # Set the target PDB filename.
28         SET_TARGET_PROPERTIES(${_target}
29                 PROPERTIES PDB "${CMAKE_CURRENT_BINARY_DIRECTORY}/${_target}.pdb")
30 ENDIF(MSVC)
31 ENDMACRO(SET_MSVC_DEBUG_PATH)