CMakeLists.txt
changeset 10013 9f758c4d746a
parent 10012 ed02c7a84612
child 10034 8764bcc13666
     1.1 --- a/CMakeLists.txt	Tue Jan 05 01:25:54 2016 -0500
     1.2 +++ b/CMakeLists.txt	Tue Jan 05 01:26:32 2016 -0500
     1.3 @@ -310,6 +310,8 @@
     1.4  set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
     1.5  set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
     1.6  
     1.7 +dep_option(SDL_STATIC_PIC      "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
     1.8 +
     1.9  # General source files
    1.10  file(GLOB SOURCE_FILES
    1.11    ${SDL2_SOURCE_DIR}/src/*.c
    1.12 @@ -1461,6 +1463,9 @@
    1.13  message(STATUS "")
    1.14  message(STATUS " Build Shared Library: ${SDL_SHARED}")
    1.15  message(STATUS " Build Static Library: ${SDL_STATIC}")
    1.16 +if(SDL_STATIC)
    1.17 +    message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}")
    1.18 +endif()
    1.19  message(STATUS "")
    1.20  if(UNIX)
    1.21    message(STATUS "If something was not detected, although the libraries")
    1.22 @@ -1503,6 +1508,7 @@
    1.23    set (BUILD_SHARED_LIBS FALSE)
    1.24    add_library(SDL2-static STATIC ${SOURCE_FILES})
    1.25    set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
    1.26 +  set_target_properties(SDL2-static PROPERTIES POSITION_INDEPENDENT_CODE ${SDL_STATIC_PIC})
    1.27    if(MSVC)
    1.28      set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
    1.29      set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")