Build with -fPIC by default

Can be disabled with GLFW_FORCE_NOFPIC=YES. This can be important on 32-bit
systems, where position independant code is more expensive. On 64-bit systems,
there is no meaningful performance impact.

Closes #199
This commit is contained in:
Corey Richardson 2014-09-06 02:44:32 -04:00
parent c85294e0b2
commit 2b05626f06

View File

@ -11,6 +11,7 @@ set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA
set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib will be installed: lib or lib64") set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib will be installed: lib or lib64")
option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_FORCE_NOFPIC "Don't build with -fPIC" OFF)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
@ -22,6 +23,10 @@ if (WIN32)
option(GLFW_USE_OPTIMUS_HPG "Force use of high-performance GPU on Optimus systems" OFF) option(GLFW_USE_OPTIMUS_HPG "Force use of high-performance GPU on Optimus systems" OFF)
endif() endif()
if (UNIX AND NOT GLFW_FORCE_NOFPIC)
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
endif()
if (APPLE) if (APPLE)
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF) option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON) option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON)