From 77609e166a8defe7fb633ab23bda3e63ec644de4 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Fri, 1 Jan 2016 14:18:13 +0100 Subject: [PATCH] Added SFML_GENERATE_PDB CMake option; check CMake version dynamically --- CMakeLists.txt | 22 +++++++++++++++++----- cmake/Macros.cmake | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56e3acdf..570df91c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 2.8.3) # define a macro that helps defining an option macro(sfml_set_option var default type docstring) @@ -127,6 +127,16 @@ endif() # Visual C++: remove warnings regarding SL security and algorithms on pointers if(SFML_COMPILER_MSVC) + # add an option to choose whether PDB debug symbols should be generated (defaults to true when possible) + if(CMAKE_VERSION VERSION_LESS 3.1) + sfml_set_option(SFML_GENERATE_PDB FALSE BOOL "True to generate PDB debug symbols, FALSE otherwise. Requires CMake 3.1.") + if(SFML_GENERATE_PDB) + message(FATAL_ERROR "Generation of PDB files (SFML_GENERATE_PDB) requires at least CMake 3.1.0") + endif() + else() + sfml_set_option(SFML_GENERATE_PDB TRUE BOOL "True to generate PDB debug symbols, FALSE otherwise. Requires CMake 3.1.") + endif() + add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) endif() @@ -232,10 +242,12 @@ if(NOT SFML_BUILD_FRAMEWORKS) COMPONENT devel FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl") - install(DIRECTORY ${PROJECT_BINARY_DIR}/lib - DESTINATION . - COMPONENT devel - FILES_MATCHING PATTERN "*.pdb") + if(SFML_GENERATE_PDB) + install(DIRECTORY ${PROJECT_BINARY_DIR}/lib + DESTINATION . + COMPONENT devel + FILES_MATCHING PATTERN "*.pdb") + endif() else() # find only "root" headers file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*") diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 601367e3..cd2ca8fc 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -60,7 +60,7 @@ macro(sfml_add_library target) endif() # For Visual Studio on Windows, export debug symbols (PDB files) to lib directory - if(SFML_OS_WINDOWS AND SFML_COMPILER_MSVC) + if(SFML_GENERATE_PDB) # 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")