CMakeLists.txt
changeset 9994 d3e4f7b44d4d
parent 9982 9145e51b15bb
child 10004 8f2f519d1e61
equal deleted inserted replaced
9993:e05d46c27ce3 9994:d3e4f7b44d4d
   167       if(${flag_var} MATCHES "/MD")
   167       if(${flag_var} MATCHES "/MD")
   168         string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
   168         string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
   169       endif()
   169       endif()
   170     endforeach()
   170     endforeach()
   171   endif()
   171   endif()
       
   172 
       
   173   # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
       
   174   foreach(flag_var
       
   175       CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
       
   176       CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
       
   177     string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
       
   178   endforeach(flag_var)
   172 endif()
   179 endif()
   173 
   180 
   174 # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
   181 # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
   175 # etc. are created correctly.
   182 # etc. are created correctly.
   176 set(SDL_LIBS "-lSDL2")
   183 set(SDL_LIBS "-lSDL2")
   942     int main(int argc, char **argv) { }" HAVE_WIN32_CC)
   949     int main(int argc, char **argv) { }" HAVE_WIN32_CC)
   943 
   950 
   944   file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
   951   file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
   945   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   952   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   946 
   953 
       
   954   if(MSVC)
       
   955     # Prevent codegen that would use the VC runtime libraries.
       
   956     add_definitions(/GS-)
       
   957     if(NOT ARCH_64)
       
   958       add_definitions(/arch:SSE)
       
   959     endif()
       
   960   endif()
       
   961 
   947   # Check for DirectX
   962   # Check for DirectX
   948   if(DIRECTX)
   963   if(DIRECTX)
   949     if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
   964     if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
   950         set(USE_WINSDK_DIRECTX TRUE)
   965         set(USE_WINSDK_DIRECTX TRUE)
   951     endif()
   966     endif()
  1450     set_target_properties(SDL2 PROPERTIES
  1465     set_target_properties(SDL2 PROPERTIES
  1451       VERSION ${SDL_VERSION}
  1466       VERSION ${SDL_VERSION}
  1452       SOVERSION ${LT_REVISION}
  1467       SOVERSION ${LT_REVISION}
  1453       OUTPUT_NAME "SDL2")
  1468       OUTPUT_NAME "SDL2")
  1454   endif()
  1469   endif()
  1455  set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1470   if(MSVC)
  1456  target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1471     # Don't try to link with the default set of libraries.
       
  1472     set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
       
  1473     set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
       
  1474     set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
       
  1475   endif()
       
  1476   set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
       
  1477   target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1457 endif()
  1478 endif()
  1458 
  1479 
  1459 if(SDL_STATIC)
  1480 if(SDL_STATIC)
  1460   set (BUILD_SHARED_LIBS FALSE)
  1481   set (BUILD_SHARED_LIBS FALSE)
  1461   add_library(SDL2-static STATIC ${SOURCE_FILES})
  1482   add_library(SDL2-static STATIC ${SOURCE_FILES})