Changed the FORCE_STATIC_VCRT to STATIC_STD_LIBS, made it available for MinGW/gcc and set it to TRUE by default

This commit is contained in:
Laurent Gomila 2011-05-15 23:53:36 +02:00
parent 0e826d8dec
commit effc31327b
2 changed files with 54 additions and 52 deletions

View File

@ -49,10 +49,12 @@ if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif() endif()
# define an option for choosing between static CRT and DLL CRT (with Visual C++) # define an option for choosing between static and dynamic C runtime (Windows only)
if(COMPILER_MSVC) if(WINDOWS)
set(FORCE_STATIC_VCRT FALSE CACHE BOOL "TRUE to force static VC++ runtimes, FALSE to use the DLL ones") set(STATIC_STD_LIBS TRUE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
if(FORCE_STATIC_VCRT)
# for VC++, we can apply it globally by modifying the compiler flags
if(COMPILER_MSVC AND STATIC_STD_LIBS)
foreach(flag foreach(flag
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)

View File

@ -126,10 +126,10 @@ macro(sfml_add_library target)
set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}) set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR})
set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# for gcc 4.x on Windows, we add the -static-libgcc linker flag to get rid of an extra gcc DLL # for gcc 4.x on Windows, apply the STATIC_STD_LIBS option if it is enabled
if(WINDOWS AND COMPILER_GCC) if(WINDOWS AND COMPILER_GCC AND STATIC_STD_LIBS)
if(${GCC_VERSION} MATCHES "4\\..*") if(${GCC_VERSION} MATCHES "4\\..*")
set_target_properties(${target} PROPERTIES LINK_FLAGS -static-libgcc) set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif() endif()
endif() endif()
@ -178,10 +178,10 @@ macro(sfml_add_example target)
# set the debug suffix # set the debug suffix
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
# for gcc 4.x on Windows, we add the -static-libgcc linker flag to get rid of an extra gcc DLL # for gcc 4.x on Windows, apply the STATIC_STD_LIBS option if it is enabled
if(WINDOWS AND COMPILER_GCC) if(WINDOWS AND COMPILER_GCC AND STATIC_STD_LIBS)
if(${GCC_VERSION} MATCHES "4\\..*") if(${GCC_VERSION} MATCHES "4\\..*")
set_target_properties(${target} PROPERTIES LINK_FLAGS -static-libgcc) set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif() endif()
endif() endif()