Create and install PDB debug symbols alongside binaries

This commit is contained in:
Jan Haller 2015-12-30 20:30:59 +01:00 committed by Lukas Dürrenberger
parent 687f260a46
commit 2bd897c513
2 changed files with 28 additions and 1 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.1)
# define a macro that helps defining an option
macro(sfml_set_option var default type docstring)
@ -231,6 +231,11 @@ if(NOT SFML_BUILD_FRAMEWORKS)
DESTINATION .
COMPONENT devel
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
install(DIRECTORY ${PROJECT_BINARY_DIR}/lib
DESTINATION .
COMPONENT devel
FILES_MATCHING PATTERN "*.pdb")
else()
# find only "root" headers
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")

View File

@ -59,6 +59,28 @@ macro(sfml_add_library target)
endif()
endif()
# For Visual Studio on Windows, export debug symbols (PDB files) to lib directory
if(SFML_OS_WINDOWS AND SFML_COMPILER_MSVC)
# PDB files are only generated in Debug and RelWithDebInfo configurations, find out which one
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(SFML_PDB_POSTFIX "-d")
else()
set(SFML_PDB_POSTFIX "")
endif()
if(BUILD_SHARED_LIBS)
# DLLs export debug symbols in the linker PDB (the compiler PDB is an intermediate file)
set_target_properties(${target} PROPERTIES
PDB_NAME "${target}${SFML_PDB_POSTFIX}"
PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
else()
# Static libraries have no linker PDBs, thus the compiler PDBs are relevant
set_target_properties(${target} PROPERTIES
COMPILE_PDB_NAME "${target}-s${SFML_PDB_POSTFIX}"
COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
endif()
endif()
# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
# (exported ones are explicitly marked)
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))