2010-08-19 23:59:24 +08:00
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
|
|
|
# project name
|
|
|
|
project(SFML)
|
|
|
|
|
|
|
|
# include the configuration file
|
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake)
|
|
|
|
|
|
|
|
# setup version numbers
|
|
|
|
set(VERSION_MAJOR 2)
|
|
|
|
set(VERSION_MINOR 0)
|
|
|
|
set(VERSION_PATCH 0)
|
|
|
|
|
|
|
|
# add the SFML header path
|
|
|
|
include_directories(${CMAKE_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")
|
|
|
|
|
|
|
|
# add an option for building the examples
|
|
|
|
set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
|
|
|
|
|
|
|
|
# add an option for building the API documentation
|
2011-05-16 05:53:36 +08:00
|
|
|
set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
|
|
|
|
|
|
|
# Mac OS X specific options
|
|
|
|
if (MACOSX)
|
|
|
|
# (Not supported anymore by extlibs) add an option to compile ppc/ppc64
|
|
|
|
#set(BUILD_PPC FALSE CACHE BOOL "TRUE to build SFML for ppc and ppc64, too, FALSE to only compile i386 and x86_64")
|
|
|
|
|
|
|
|
# add an option to build against 10.5 SDK
|
|
|
|
set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile for default SDK")
|
2011-03-31 01:52:36 +08:00
|
|
|
endif()
|
2010-08-19 23:59:24 +08:00
|
|
|
|
2010-11-05 21:58:29 +08:00
|
|
|
# define SFML_STATIC if the build type is not set to 'shared'
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
add_definitions(-DSFML_STATIC)
|
2010-08-19 23:59:24 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# remove SL security warnings with Visual C++
|
|
|
|
if(MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
|
|
|
endif()
|
|
|
|
|
2011-05-16 05:53:36 +08:00
|
|
|
# define an option for choosing between static and dynamic C runtime (Windows only)
|
|
|
|
if(WINDOWS)
|
|
|
|
set(STATIC_STD_LIBS TRUE CACHE 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)
|
2011-03-27 06:24:09 +08:00
|
|
|
foreach(flag
|
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
|
|
if(${flag} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2010-08-19 23:59:24 +08:00
|
|
|
# disable the rpath stuff
|
2011-05-16 05:53:36 +08:00
|
|
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
|
|
|
|
|
|
|
# Setup Mac OS X multi arch/SDK support.
|
|
|
|
if (MACOSX)
|
|
|
|
# # compile for PPC ?
|
|
|
|
# if (BUILD_PPC)
|
|
|
|
# if (NOT CMAKE_OSX_ARCHITECTURES)
|
|
|
|
# # Custom : ppc, ppc64, i386 and x86_64
|
|
|
|
# set(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64")
|
|
|
|
# else()
|
|
|
|
# # We got some conflict with custom user settings ; let him know his on his own.
|
|
|
|
# message("You set BUILD_PPC to TRUE but CMAKE_OSX_ARCHITECTURES is not empty.")
|
|
|
|
# message("You're on your own : I won't change your settings.")
|
|
|
|
# endif()
|
|
|
|
# else()
|
|
|
|
# if (NOT CMAKE_OSX_ARCHITECTURES)
|
|
|
|
# # Default : i386 and x86_64
|
|
|
|
# set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
|
|
|
|
# else()
|
|
|
|
# # We got some conflict with custom user settings ; let him know his on his own.
|
|
|
|
# message("CMAKE_OSX_ARCHITECTURES is not empty.")
|
|
|
|
# message("You're on your own : I won't change your settings.")
|
|
|
|
# endif()
|
|
|
|
# endif()
|
|
|
|
|
|
|
|
# use 10.5 SDK ?
|
|
|
|
if (BUILD_LEOPARD)
|
|
|
|
# Use 10.5 SDK : override default value
|
|
|
|
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk")
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5")
|
|
|
|
else()
|
|
|
|
# Default SDK, let either the user or CMake decide which one to use.
|
|
|
|
endif()
|
2011-03-31 01:52:36 +08:00
|
|
|
endif()
|
2010-08-19 23:59:24 +08:00
|
|
|
|
|
|
|
# add the subdirectories
|
|
|
|
add_subdirectory(src/SFML)
|
|
|
|
if(BUILD_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
|
|
|
if(BUILD_DOC)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# setup the install rules
|
|
|
|
install(DIRECTORY include
|
|
|
|
DESTINATION .
|
|
|
|
COMPONENT devel
|
|
|
|
PATTERN ".svn" EXCLUDE)
|
2010-11-08 02:53:18 +08:00
|
|
|
install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${CMAKE_ROOT}/Modules)
|
2010-08-19 23:59:24 +08:00
|
|
|
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
|
|
|
|
if(WINDOWS)
|
2011-03-29 00:20:27 +08:00
|
|
|
if(ARCH_32BITS)
|
|
|
|
install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin)
|
|
|
|
install(FILES extlibs/bin/x86/openal32.dll DESTINATION bin)
|
|
|
|
else()
|
|
|
|
install(FILES extlibs/bin/x64/libsndfile-1.dll DESTINATION bin)
|
|
|
|
install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin)
|
|
|
|
endif()
|
2011-03-27 06:24:09 +08:00
|
|
|
elseif(MACOSX)
|
2010-11-26 00:45:03 +08:00
|
|
|
install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION /Library/Frameworks PATTERN ".svn" EXCLUDE)
|
2010-08-19 23:59:24 +08:00
|
|
|
endif()
|