This commit is contained in:
Camilla Berglund 2013-06-17 11:58:46 +02:00
parent 1de60a4ff7
commit 10017b27bb
5 changed files with 61 additions and 85 deletions

View File

@ -10,26 +10,28 @@ set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}") 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(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(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_INSTALL "Generate installation target" ON)
set(DOXYGEN_SKIP_DOT TRUE)
find_package(Doxygen)
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
if (GLFW_DOCUMENT_INTERNALS)
set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox")
endif()
if (APPLE) if (APPLE)
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)
option(GLFW_USE_MENUBAR "Populate the menu bar on first window creation" ON) option(GLFW_USE_MENUBAR "Populate the menu bar on first window creation" ON)
else() else()
option(GLFW_USE_EGL "Use EGL for context creation" OFF) option(GLFW_USE_EGL "Use EGL for context creation" OFF)
endif() endif()
if (MSVC)
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON)
endif()
if (BUILD_SHARED_LIBS)
set(_GLFW_BUILD_DLL 1)
endif()
if (GLFW_USE_EGL) if (GLFW_USE_EGL)
set(GLFW_CLIENT_LIBRARY "opengl" CACHE STRING set(GLFW_CLIENT_LIBRARY "opengl" CACHE STRING
"The client library to use; one of opengl, glesv1 or glesv2") "The client library to use; one of opengl, glesv1 or glesv2")
@ -66,22 +68,43 @@ endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
set(DOXYGEN_SKIP_DOT TRUE)
find_package(Doxygen)
if (GLFW_DOCUMENT_INTERNALS)
set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox")
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Set GCC-specific flags # Set compiler specific flags
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCC) if (UNIX)
add_definitions(-Wall) add_definitions(-Wall)
if (UNIX AND BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
add_definitions(-fvisibility=hidden) add_definitions(-fvisibility=hidden)
endif() endif()
endif() endif()
#-------------------------------------------------------------------- if (MSVC)
# Export shared library / dynamic library / DLL build option add_definitions(-D_CRT_SECURE_NO_WARNINGS)
#--------------------------------------------------------------------
if (BUILD_SHARED_LIBS) if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
set(_GLFW_BUILD_DLL 1) foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO)
if (${flag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
if (${flag} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
endforeach()
endif()
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -122,31 +145,10 @@ endif()
# Use Win32 for window creation # Use Win32 for window creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_WIN32) if (_GLFW_WIN32)
# The DLL links against winmm; the static library loads it
if (MSVC) # That way, both code paths receive testing
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON)
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO)
if (${flag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
if (${flag} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
endforeach()
endif()
endif()
set(_GLFW_NO_DLOAD_WINMM ${BUILD_SHARED_LIBS})
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
set(_GLFW_NO_DLOAD_WINMM 1)
list(APPEND glfw_LIBRARIES winmm) list(APPEND glfw_LIBRARIES winmm)
endif() endif()
endif() endif()
@ -244,16 +246,9 @@ if (_GLFW_GLX)
include(CheckFunctionExists) include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS) check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
if (NOT _GLFW_HAS_GLXGETPROCADDRESS)
check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB) check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
endif()
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB)
check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT) check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
endif()
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND
@ -292,8 +287,6 @@ if (_GLFW_EGL)
list(APPEND glfw_INCLUDE_DIRS ${EGL_INCLUDE_DIR}) list(APPEND glfw_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${EGL_LIBRARY}) list(APPEND glfw_LIBRARIES ${EGL_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${EGL_LIBRARY})
if (UNIX) if (UNIX)
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl") set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl")
endif() endif()
@ -319,8 +312,6 @@ endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_COCOA AND _GLFW_NSGL) if (_GLFW_COCOA AND _GLFW_NSGL)
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
if (GLFW_USE_MENUBAR) if (GLFW_USE_MENUBAR)
set(_GLFW_USE_MENUBAR 1) set(_GLFW_USE_MENUBAR 1)
endif() endif()
@ -329,7 +320,6 @@ if (_GLFW_COCOA AND _GLFW_NSGL)
set(_GLFW_USE_CHDIR 1) set(_GLFW_USE_CHDIR 1)
endif() endif()
# Universal build
if (GLFW_BUILD_UNIVERSAL) if (GLFW_BUILD_UNIVERSAL)
message(STATUS "Building GLFW as Universal Binaries") message(STATUS "Building GLFW as Universal Binaries")
set(CMAKE_OSX_ARCHITECTURES i386;x86_64) set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
@ -403,7 +393,7 @@ if (DOXYGEN_FOUND)
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Install files # Install files other than the library
# The library is installed by src/CMakeLists.txt # The library is installed by src/CMakeLists.txt
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (GLFW_INSTALL) if (GLFW_INSTALL)
@ -419,13 +409,9 @@ if (GLFW_INSTALL)
install(FILES ${GLFW_BINARY_DIR}/src/glfw3.pc install(FILES ${GLFW_BINARY_DIR}/src/glfw3.pc
DESTINATION lib${LIB_SUFFIX}/pkgconfig) DESTINATION lib${LIB_SUFFIX}/pkgconfig)
endif() endif()
endif()
#-------------------------------------------------------------------- # Only generate this target if no higher-level project already has
# Uninstall operation if (NOT TARGET uninstall)
# Don't generate this target if a higher-level project already has
#--------------------------------------------------------------------
if (GLFW_INSTALL AND NOT TARGET uninstall)
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY) ${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
@ -433,4 +419,5 @@ if (GLFW_INSTALL AND NOT TARGET uninstall)
${CMAKE_COMMAND} -P ${CMAKE_COMMAND} -P
${GLFW_BINARY_DIR}/cmake_uninstall.cmake) ${GLFW_BINARY_DIR}/cmake_uninstall.cmake)
endif() endif()
endif()

View File

@ -11,8 +11,7 @@ API changes.
If you are new to GLFW, you may find the If you are new to GLFW, you may find the
[introductory tutorial](http://www.glfw.org/docs/3.0/quick.html) for GLFW [introductory tutorial](http://www.glfw.org/docs/3.0/quick.html) for GLFW
3 useful. If 3 useful. If you have used GLFW 2 in the past, there is a
you have used GLFW 2 in the past, there is a
[transition guide](http://www.glfw.org/docs/3.0/moving.html) for moving to the [transition guide](http://www.glfw.org/docs/3.0/moving.html) for moving to the
GLFW 3 API. GLFW 3 API.
@ -70,8 +69,8 @@ directory of bundled applications to the `Contents/Resources` directory.
#### Windows specific options #### Windows specific options
`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version of the `USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
Visual C++ runtime library. static library version of the Visual C++ runtime library.
#### EGL specific options #### EGL specific options
@ -100,6 +99,8 @@ See the [GLFW 3.0 documentation](http://www.glfw.org/docs/3.0/).
## Changelog ## Changelog
- Bugfix: The `-Wall` flag was not used with Clang and other GCC compatibles
## Contact ## Contact
@ -167,7 +168,7 @@ skills.
- Jeff Molofee - Jeff Molofee
- Jon Morton - Jon Morton
- Julian Møller - Julian Møller
- Ozzy at Orkysquad - Ozzy
- Peoro - Peoro
- Braden Pellett - Braden Pellett
- Arturo J. Pérez - Arturo J. Pérez

View File

@ -11,10 +11,6 @@ endif()
include_directories(${GLFW_SOURCE_DIR}/include include_directories(${GLFW_SOURCE_DIR}/include
${GLFW_SOURCE_DIR}/deps) ${GLFW_SOURCE_DIR}/deps)
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if (NOT APPLE) if (NOT APPLE)
# HACK: This is NOTFOUND on OS X 10.8 # HACK: This is NOTFOUND on OS X 10.8
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})

View File

@ -3,10 +3,6 @@ include_directories(${GLFW_SOURCE_DIR}/src
${GLFW_BINARY_DIR}/src ${GLFW_BINARY_DIR}/src
${glfw_INCLUDE_DIRS}) ${glfw_INCLUDE_DIRS})
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
set(common_HEADERS ${GLFW_BINARY_DIR}/src/config.h internal.h set(common_HEADERS ${GLFW_BINARY_DIR}/src/config.h internal.h
${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h ${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h
${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h) ${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h)

View File

@ -11,10 +11,6 @@ endif()
include_directories(${GLFW_SOURCE_DIR}/include include_directories(${GLFW_SOURCE_DIR}/include
${GLFW_SOURCE_DIR}/deps) ${GLFW_SOURCE_DIR}/deps)
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if (NOT APPLE) if (NOT APPLE)
# HACK: This is NOTFOUND on OS X 10.8 # HACK: This is NOTFOUND on OS X 10.8
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})