From 004c12cfd2e4076d6ac5c8105948fa052e4a4406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Tue, 15 Oct 2013 15:46:50 +0200 Subject: [PATCH] Changed VS version to MSVC version and added support for VS 2013 and TDM compilers. --- cmake/Config.cmake | 12 ++++++++---- cmake/Macros.cmake | 16 ++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 5010f0d9..29b25e84 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -45,6 +45,8 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) set(SFML_COMPILER_GCC 1) execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT) string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}") + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION) + string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}") execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE) string(STRIP "${GCC_MACHINE}" GCC_MACHINE) if(${GCC_MACHINE} MATCHES ".*w64.*") @@ -53,13 +55,15 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) elseif(MSVC) set(SFML_COMPILER_MSVC 1) if(MSVC_VERSION EQUAL 1400) - set(SFML_MSVC_VERSION 2005) + set(SFML_MSVC_VERSION 8) elseif(MSVC_VERSION EQUAL 1500) - set(SFML_MSVC_VERSION 2008) + set(SFML_MSVC_VERSION 9) elseif(MSVC_VERSION EQUAL 1600) - set(SFML_MSVC_VERSION 2010) + set(SFML_MSVC_VERSION 10) elseif(MSVC_VERSION EQUAL 1700) - set(SFML_MSVC_VERSION 2011) + set(SFML_MSVC_VERSION 11) + elseif(MSVC_VERSION EQUAL 1800) + set(SFML_MSVC_VERSION 12) endif() else() message(FATAL_ERROR "Unsupported compiler") diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 03845cf4..cbced584 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -37,8 +37,8 @@ macro(sfml_static_add_libraries target) if(NOT ${lib} MATCHES ".*\\.lib") set(lib ${lib}.lib) endif() - if(MSVC_IDE AND SFML_MSVC_VERSION LESS 2010) - # for Visual Studio projects < 2010, we must add double quotes + if(MSVC_IDE AND SFML_MSVC_VERSION LESS 10) + # for Visual Studio projects < 10, we must add double quotes # around paths because they may contain spaces set(LIBRARIES "${LIBRARIES} "\\;${lib}"\\;") else() @@ -99,9 +99,11 @@ macro(sfml_add_library target) set_target_properties(${target} PROPERTIES FOLDER "SFML") # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled - if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS) - if(NOT SFML_GCC_VERSION VERSION_LESS "4") + if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") + if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM) set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++") + elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM) + set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++") endif() endif() @@ -182,9 +184,11 @@ macro(sfml_add_example target) set_target_properties(${target} PROPERTIES FOLDER "Examples") # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled - if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS) - if(NOT SFML_GCC_VERSION VERSION_LESS "4") + if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") + if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM) set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++") + elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM) + set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++") endif() endif()