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

@ -28,15 +28,15 @@ set(BUILD_SHARED_LIBS TRUE CACHE BOOL "TRUE to build SFML as shared libraries, F
set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to ignore them") set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
# add an option for building the API documentation # add an option for building the API documentation
set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it") set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
# Mac OS X specific options # Mac OS X specific options
if (MACOSX) if (MACOSX)
# (Not supported anymore by extlibs) add an option to compile ppc/ppc64 # (Not supported anymore by extlibs) add an option to compile ppc/ppc64
#set(BUILD_PPC FALSE CACHE BOOL "TRUE to build SFML for ppc and ppc64, too, FALSE to only compile i386 and x86_64") #set(BUILD_PPC FALSE CACHE BOOL "TRUE to build SFML for ppc and ppc64, too, FALSE to only compile i386 and x86_64")
# add an option to build against 10.5 SDK # add an option to build against 10.5 SDK
set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile for default SDK") set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile for default SDK")
endif() endif()
# define SFML_STATIC if the build type is not set to 'shared' # define SFML_STATIC if the build type is not set to 'shared'
@ -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)
@ -64,39 +66,39 @@ if(COMPILER_MSVC)
endif() endif()
# disable the rpath stuff # disable the rpath stuff
set(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_SKIP_BUILD_RPATH TRUE)
# Setup Mac OS X multi arch/SDK support. # Setup Mac OS X multi arch/SDK support.
if (MACOSX) if (MACOSX)
# # compile for PPC ? # # compile for PPC ?
# if (BUILD_PPC) # if (BUILD_PPC)
# if (NOT CMAKE_OSX_ARCHITECTURES) # if (NOT CMAKE_OSX_ARCHITECTURES)
# # Custom : ppc, ppc64, i386 and x86_64 # # Custom : ppc, ppc64, i386 and x86_64
# set(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64") # set(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64")
# else() # else()
# # We got some conflict with custom user settings ; let him know his on his own. # # We got some conflict with custom user settings ; let him know his on his own.
# message("You set BUILD_PPC to TRUE but CMAKE_OSX_ARCHITECTURES is not empty.") # message("You set BUILD_PPC to TRUE but CMAKE_OSX_ARCHITECTURES is not empty.")
# message("You're on your own : I won't change your settings.") # message("You're on your own : I won't change your settings.")
# endif() # endif()
# else() # else()
# if (NOT CMAKE_OSX_ARCHITECTURES) # if (NOT CMAKE_OSX_ARCHITECTURES)
# # Default : i386 and x86_64 # # Default : i386 and x86_64
# set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") # set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
# else() # else()
# # We got some conflict with custom user settings ; let him know his on his own. # # We got some conflict with custom user settings ; let him know his on his own.
# message("CMAKE_OSX_ARCHITECTURES is not empty.") # message("CMAKE_OSX_ARCHITECTURES is not empty.")
# message("You're on your own : I won't change your settings.") # message("You're on your own : I won't change your settings.")
# endif() # endif()
# endif() # endif()
# use 10.5 SDK ? # use 10.5 SDK ?
if (BUILD_LEOPARD) if (BUILD_LEOPARD)
# Use 10.5 SDK : override default value # Use 10.5 SDK : override default value
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk") set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5")
else() else()
# Default SDK, let either the user or CMake decide which one to use. # Default SDK, let either the user or CMake decide which one to use.
endif() endif()
endif() endif()
# add the subdirectories # add the subdirectories

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()