mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Improved the definition of options in CMake files, they can now be overriden by a parent CMakeLists.txt
This commit is contained in:
parent
c0af511ed1
commit
9d0a0fe3f2
@ -1,11 +1,17 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# define a macro that helps defining an option
|
||||
macro(sfml_set_option var default type docstring)
|
||||
if(NOT ${var})
|
||||
set(${var} ${default})
|
||||
endif()
|
||||
set(${var} ${${var}} CACHE ${type} ${docstring} FORCE)
|
||||
endmacro()
|
||||
|
||||
# set a default build type if none was provided
|
||||
# this has to be done before the project() instruction!
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
|
||||
endif()
|
||||
sfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
|
||||
|
||||
# project name
|
||||
project(SFML)
|
||||
@ -22,24 +28,24 @@ set(VERSION_PATCH 0)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
# add an option for choosing the build type (shared or static)
|
||||
set(BUILD_SHARED_LIBS TRUE CACHE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries")
|
||||
sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries")
|
||||
|
||||
# add an option for building the examples
|
||||
set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
|
||||
sfml_set_option(BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
|
||||
|
||||
# add an option for building the API documentation
|
||||
set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
||||
sfml_set_option(BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
||||
|
||||
# Mac OS X specific options
|
||||
if(MACOSX)
|
||||
# add an option to build frameworks instead of dylibs (release only)
|
||||
set(BUILD_FRAMEWORKS FALSE CACHE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
||||
sfml_set_option(BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
||||
|
||||
# add an option to let the user specify a custom directory for frameworks installation (SFML, sndfile, ...)
|
||||
set(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" CACHE STRING "Frameworks installation directory")
|
||||
sfml_set_option(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" STRING "Frameworks installation directory")
|
||||
|
||||
# add an option to automatically install Xcode 4 templates
|
||||
set(INSTALL_XCODE4_TEMPLATES FALSE CACHE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it")
|
||||
sfml_set_option(INSTALL_XCODE4_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it")
|
||||
endif()
|
||||
|
||||
# define SFML_STATIC if the build type is not set to 'shared'
|
||||
@ -54,7 +60,7 @@ endif()
|
||||
|
||||
# define an option for choosing between static and dynamic C runtime (Windows only)
|
||||
if(WINDOWS)
|
||||
set(STATIC_STD_LIBS FALSE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
|
||||
sfml_set_option(STATIC_STD_LIBS FALSE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
|
||||
|
||||
# for VC++, we can apply it globally by modifying the compiler flags
|
||||
if(COMPILER_MSVC AND STATIC_STD_LIBS)
|
||||
@ -74,28 +80,22 @@ set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||
# Setup Mac OS X stuff
|
||||
if(MACOSX)
|
||||
# multi arch support - by default : i386 and x86_64
|
||||
if(NOT CMAKE_OSX_ARCHITECTURES)
|
||||
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
endif()
|
||||
sfml_set_option(CMAKE_OSX_ARCHITECTURES "i386;x86_64" STRING "Build architectures for OSX")
|
||||
|
||||
# multi SDK support - by default we choose the older SDK available starting by 10.5 SDK
|
||||
if(NOT OSX_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
if(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
||||
# target 10.5 system
|
||||
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk"
|
||||
CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value."
|
||||
FORCE)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5"
|
||||
CACHE STRING "Minimum OS X version to target for deployment (at runtime); ewer APIs weak linked."
|
||||
FORCE)
|
||||
sfml_set_option(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk"
|
||||
STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value.")
|
||||
sfml_set_option(CMAKE_OSX_DEPLOYMENT_TARGET "10.5"
|
||||
STRING "Minimum OS X version to target for deployment (at runtime); ewer APIs weak linked.")
|
||||
elseif(EXISTS /Developer/SDKs/MacOSX10.6.sdk)
|
||||
# target 10.6 system
|
||||
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk"
|
||||
CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value."
|
||||
FORCE)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6"
|
||||
CACHE STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked."
|
||||
FORCE)
|
||||
sfml_set_option(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk"
|
||||
STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value.")
|
||||
sfml_set_option(CMAKE_OSX_DEPLOYMENT_TARGET "10.6"
|
||||
STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked.")
|
||||
else()
|
||||
# use default SDK.
|
||||
endif()
|
||||
@ -115,13 +115,13 @@ if(MACOSX)
|
||||
if(BUILD_FRAMEWORKS)
|
||||
# requirement #1
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
message(WARNING "CMAKE_BUILD_TYPE should be \"Release\" when BUILD_FRAMEWORKS is TRUE")
|
||||
message(FATAL_ERROR "CMAKE_BUILD_TYPE should be \"Release\" when BUILD_FRAMEWORKS is TRUE")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# requirement #2
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
message(WARNING "BUILD_SHARED_LIBS should be TRUE when BUILD_FRAMEWORKS is TRUE")
|
||||
message(FATAL_ERROR "BUILD_SHARED_LIBS should be TRUE when BUILD_FRAMEWORKS is TRUE")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user