Added the STATIC_STD_LIBS option to CSFML makefiles

This commit is contained in:
Laurent Gomila 2011-05-16 07:57:41 +02:00
parent effc31327b
commit 04ae896457
2 changed files with 19 additions and 3 deletions

View File

@ -30,6 +30,22 @@ set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to
# disable the rpath stuff # disable the rpath stuff
set(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_SKIP_BUILD_RPATH TRUE)
# define an option for choosing between static and dynamic C runtime (Windows only)
if(WINDOWS)
set(STATIC_STD_LIBS TRUE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
# for VC++, we can apply it globally by modifying the compiler flags
if(COMPILER_MSVC AND STATIC_STD_LIBS)
foreach(flag
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
endforeach()
endif()
endif()
# add the subdirectories # add the subdirectories
add_subdirectory(src/SFML) add_subdirectory(src/SFML)
if(BUILD_DOC) if(BUILD_DOC)

View File

@ -76,10 +76,10 @@ macro(csfml_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()