CMakeLists.txt
changeset 8136 175cac5d90a6
parent 8133 f24acf2403c0
child 8137 6dbd80731aa0
equal deleted inserted replaced
8135:dd4729596096 8136:175cac5d90a6
   146   list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
   146   list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
   147 endif("$ENV{CFLAGS}" STREQUAL "")
   147 endif("$ENV{CFLAGS}" STREQUAL "")
   148 if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
   148 if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
   149   list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
   149   list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
   150 endif(NOT ("$ENV{CFLAGS}" STREQUAL ""))
   150 endif(NOT ("$ENV{CFLAGS}" STREQUAL ""))
       
   151 
       
   152 if(MSVC)
       
   153   option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
       
   154   if(FORCE_STATIC_VCRT)
       
   155     foreach(flag_var
       
   156         CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
       
   157         CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
       
   158       if(${flag_var} MATCHES "/MD")
       
   159         string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
       
   160       endif()
       
   161     endforeach(flag_var)
       
   162   endif()
       
   163 endif(MSVC)
   151 
   164 
   152 # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
   165 # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
   153 # etc. are created correctly.
   166 # etc. are created correctly.
   154 set(SDL_LIBS "-lSDL2")
   167 set(SDL_LIBS "-lSDL2")
   155 set(SDL_CFLAGS "")
   168 set(SDL_CFLAGS "")
  1232  set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1245  set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1233  target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1246  target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1234 endif(SDL_SHARED)
  1247 endif(SDL_SHARED)
  1235 
  1248 
  1236 if(SDL_STATIC)
  1249 if(SDL_STATIC)
       
  1250   set (BUILD_SHARED_LIBS FALSE)
  1237   add_library(SDL2-static STATIC ${SOURCE_FILES})
  1251   add_library(SDL2-static STATIC ${SOURCE_FILES})
  1238   set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
  1252   set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
       
  1253   if(WINDOWS)
       
  1254     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
       
  1255     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
       
  1256     set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
       
  1257   endif(WINDOWS)
  1239   # TODO: Win32 platforms keep the same suffix .lib for import and static
  1258   # TODO: Win32 platforms keep the same suffix .lib for import and static
  1240   # libraries - do we need to consider this?
  1259   # libraries - do we need to consider this?
  1241   set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
  1260   set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
  1242   target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1261   target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1243 endif(SDL_STATIC)
  1262 endif(SDL_STATIC)