2021-12-02 03:14:15 +08:00
cmake_minimum_required ( VERSION 3.8 )
2014-09-30 22:07:25 +08:00
2021-04-19 10:20:43 +08:00
# customize the compiler options CMake uses to initialize variables with
set ( CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CompilerOptionsOverride.cmake" )
2014-09-30 22:07:25 +08:00
# define a macro that helps defining an option
macro ( sfml_set_option var default type docstring )
if ( NOT DEFINED ${ var } )
set ( ${ var } ${ default } )
endif ( )
set ( ${ var } ${ ${var } } CACHE ${ type } ${ docstring } FORCE )
endmacro ( )
2015-01-30 22:37:06 +08:00
# these options have to be set before CMake detects/configures the toolchain
# determine whether to create a debug or release build
2014-09-30 22:07:25 +08:00
sfml_set_option ( CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)" )
2016-09-22 21:26:07 +08:00
# Suppress Cygwin legacy warning
set ( CMAKE_LEGACY_CYGWIN_WIN32 0 )
2016-12-20 05:16:07 +08:00
# Suppress Mac OS X RPATH warnings and adopt new related behaviors
2018-03-21 02:46:57 +08:00
cmake_policy ( SET CMP0042 NEW )
2018-02-11 01:07:21 +08:00
if ( NOT CMAKE_VERSION VERSION_LESS 3.9 )
cmake_policy ( SET CMP0068 NEW )
endif ( )
2016-12-20 05:16:07 +08:00
2017-04-06 03:56:06 +08:00
# add some default value for some additional macOS variable
# note that those variables are ignored on other systems
if ( NOT CMAKE_OSX_ARCHITECTURES )
set ( CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS architecture to build; 64-bit is expected" FORCE )
endif ( )
if ( NOT CMAKE_OSX_SYSROOT )
# query the path to the default SDK, will fail on non-macOS, but it's okay.
execute_process ( COMMAND xcodebuild -sdk macosx -version Path
C O M M A N D h e a d - n 1
C O M M A N D t r - d ' \ n '
O U T P U T _ V A R I A B L E C M A K E _ O S X _ S Y S R O O T
E R R O R _ Q U I E T )
endif ( )
2014-09-30 22:07:25 +08:00
# project name
project ( SFML )
# include the configuration file
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/Config.cmake )
2019-04-09 18:02:17 +08:00
# we use the paths from the cmake GNUInstallDirs module as defaults
# you can override these if you like
# https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html
include ( GNUInstallDirs )
2014-09-30 22:07:25 +08:00
# setup version numbers
2021-11-30 20:39:40 +08:00
set ( VERSION_MAJOR 3 )
set ( VERSION_MINOR 0 )
set ( VERSION_PATCH 0 )
set ( VERSION_IS_RELEASE OFF )
2014-09-30 22:07:25 +08:00
# add an option for choosing the build type (shared or static)
if ( NOT ( SFML_OS_IOS OR SFML_OS_ANDROID ) )
sfml_set_option ( BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries" )
else ( )
if ( SFML_OS_IOS )
set ( BUILD_SHARED_LIBS FALSE )
elseif ( SFML_OS_ANDROID )
set ( BUILD_SHARED_LIBS TRUE )
endif ( )
endif ( )
# add an option for building the examples
2018-02-28 04:17:08 +08:00
if ( NOT SFML_OS_ANDROID )
2014-09-30 22:07:25 +08:00
sfml_set_option ( SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, FALSE to ignore them" )
else ( )
set ( SFML_BUILD_EXAMPLES FALSE )
endif ( )
2015-02-21 21:46:46 +08:00
# add options to select which modules to build
sfml_set_option ( SFML_BUILD_WINDOW TRUE BOOL "TRUE to build SFML's Window module. This setting is ignored, if the graphics module is built." )
sfml_set_option ( SFML_BUILD_GRAPHICS TRUE BOOL "TRUE to build SFML's Graphics module." )
2018-01-05 06:23:49 +08:00
sfml_set_option ( SFML_BUILD_AUDIO TRUE BOOL "TRUE to build SFML's Audio module." )
2015-02-21 21:46:46 +08:00
sfml_set_option ( SFML_BUILD_NETWORK TRUE BOOL "TRUE to build SFML's Network module." )
2014-09-30 22:07:25 +08:00
# add an option for building the API documentation
sfml_set_option ( SFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it" )
# add an option for choosing the OpenGL implementation
2015-02-21 21:46:46 +08:00
if ( SFML_BUILD_WINDOW )
sfml_set_option ( SFML_OPENGL_ES ${ OPENGL_ES } BOOL "TRUE to use an OpenGL ES implementation, FALSE to use a desktop OpenGL implementation" )
endif ( )
2014-09-30 22:07:25 +08:00
2014-08-26 15:52:37 +08:00
# add an option for building the test suite
2018-08-21 05:49:56 +08:00
sfml_set_option ( SFML_BUILD_TEST_SUITE FALSE BOOL "TRUE to build the SFML test suite, FALSE to ignore it" )
2014-08-26 15:52:37 +08:00
2018-04-12 03:45:36 +08:00
# macOS specific options
2014-09-30 22:07:25 +08:00
if ( SFML_OS_MACOSX )
# add an option to build frameworks instead of dylibs (release only)
sfml_set_option ( SFML_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 automatically install Xcode templates
sfml_set_option ( SFML_INSTALL_XCODE_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode templates, FALSE to do nothing about it. The templates are compatible with Xcode 4 and 5." )
endif ( )
2018-04-12 03:45:36 +08:00
# iOS specific options
if ( SFML_OS_IOS )
# At the moment the minimal deployement target version is 10.2 only because the externals for iOS were built with that requirement.
sfml_set_option ( SFML_IOS_DEPLOYMENT_TARGET "10.2" STRING "The minimal iOS version that will be able to run the built binaries. Cannot be lower than 10.2." )
sfml_set_option ( SFML_CODE_SIGN_IDENTITY "iPhone Developer" STRING "The code signing identity to use when building for a real device" )
endif ( )
2014-09-30 22:07:25 +08:00
# Android options
if ( SFML_OS_ANDROID )
2019-04-09 01:17:26 +08:00
# avoid missing libraries when building SFML for Android with NDK r19c and later
set ( CMAKE_FIND_ROOT_PATH "${PROJECT_SOURCE_DIR};${CMAKE_FIND_ROOT_PATH}" )
2014-09-30 22:07:25 +08:00
# make sure there's the android library available
2018-01-30 05:35:04 +08:00
if ( CMAKE_ANDROID_API LESS 14 )
message ( FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 14." )
2015-01-30 22:37:06 +08:00
endif ( )
2015-04-01 10:08:23 +08:00
2015-01-30 22:37:06 +08:00
# CMake doesn't support defining the STL to be used with Nsight Tegra, so warn the user
if ( CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android" )
message ( WARNING "CMake might not properly support setting the STL. Make sure to adjust all generated library projects!" )
endif ( )
2015-04-01 10:08:23 +08:00
2014-09-30 22:07:25 +08:00
# install everything in $NDK/sources/ because this path is appended by the NDK (convenient)
2018-01-25 22:06:30 +08:00
set ( CMAKE_INSTALL_PREFIX ${ CMAKE_ANDROID_NDK } /sources/third_party/sfml )
2014-09-30 22:07:25 +08:00
2019-04-09 18:02:17 +08:00
# we install libs in a subdirectory named after the ABI
set ( CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CMAKE_ANDROID_ARCH_ABI}" )
2015-01-30 22:37:06 +08:00
# pass shared STL configuration (if any)
2018-01-25 22:06:30 +08:00
if ( CMAKE_ANDROID_STL_TYPE MATCHES "_shared" )
add_definitions ( "-DSTL_LIBRARY=${CMAKE_ANDROID_STL_TYPE}" )
2018-02-04 16:43:50 +08:00
# if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "c\\+\\+_shared")
# message("Android: Using ${CMAKE_ANDROID_STL_TYPE} as STL. Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.")
# endif()
2018-01-25 22:06:30 +08:00
else ( )
2018-02-04 16:43:50 +08:00
# message(WARNING "Android: You're using a static STL (${CMAKE_ANDROID_STL_TYPE}). Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.")
2015-01-30 22:37:06 +08:00
endif ( )
2015-04-01 10:08:23 +08:00
2017-09-20 03:20:07 +08:00
# let the user switch ABIs
set ( ANDROID_ABI "armeabi-v7a" CACHE STRING "Look at the NDK docs for currently supported ABIs" )
2015-01-30 22:37:06 +08:00
# this is a workaround to compile sfml-activity without the stl library as a dependency
2014-09-30 22:07:25 +08:00
# we save the original compilation command line to restore it later in Macro.cmake
2015-01-30 22:37:06 +08:00
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY_WITH_STL ${ CMAKE_CXX_CREATE_SHARED_LIBRARY } )
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY_WITHOUT_STL "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
2014-09-30 22:07:25 +08:00
endif ( )
2018-03-21 02:46:57 +08:00
# Install directories
# For miscellaneous files
if ( SFML_OS_WINDOWS OR SFML_OS_IOS )
set ( DEFAULT_INSTALL_MISC_DIR . )
2020-12-05 15:41:26 +08:00
elseif ( SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD )
2018-03-21 02:46:57 +08:00
set ( DEFAULT_INSTALL_MISC_DIR share/SFML )
elseif ( SFML_OS_MACOSX )
set ( DEFAULT_INSTALL_MISC_DIR /usr/local/share/SFML )
elseif ( SFML_OS_ANDROID )
set ( DEFAULT_INSTALL_MISC_DIR ${ CMAKE_ANDROID_NDK } /sources/third_party/sfml )
2014-09-30 22:07:25 +08:00
endif ( )
2015-02-21 21:46:46 +08:00
# force building sfml-window, if sfml-graphics module is built
if ( SFML_BUILD_GRAPHICS AND NOT SFML_BUILD_WINDOW )
message ( WARNING "You're trying to build SFML's Graphics module without the Window module. Forcing building of the Window module as a dependency." )
set ( SFML_BUILD_WINDOW TRUE )
endif ( )
2016-12-20 05:16:07 +08:00
# allow not using bundled dependencies with a switch
# (except for stb_image)
# yes this is horrible, but GLOB_RECURSE sucks
sfml_set_option ( SFML_USE_SYSTEM_DEPS FALSE BOOL "TRUE to use system dependencies, FALSE to use the bundled ones." )
if ( SFML_USE_SYSTEM_DEPS )
if ( SFML_INSTALL_XCODE_TEMPLATES )
message ( FATAL_ERROR "XCode templates installation cannot be used with the SFML_USE_SYSTEM_DEPS option (the bundled frameworks are required.)" )
endif ( )
file ( GLOB_RECURSE DEP_LIBS "${CMAKE_SOURCE_DIR}/extlibs/libs*/*" )
file ( GLOB_RECURSE DEP_BINS "${CMAKE_SOURCE_DIR}/extlibs/bin*/*" )
file ( GLOB_RECURSE DEP_HEADERS "${CMAKE_SOURCE_DIR}/extlibs/headers/*" )
foreach ( DEP_FILE ${ DEP_LIBS } ${ DEP_BINS } ${ DEP_HEADERS } )
get_filename_component ( DEP_DIR ${ DEP_FILE } PATH )
if ( NOT DEP_DIR MATCHES "/stb_image(/|$)" )
set ( CMAKE_IGNORE_PATH ${ CMAKE_IGNORE_PATH } ${ DEP_DIR } )
endif ( )
get_filename_component ( DEP_PARENT_DIR ${ DEP_DIR } PATH )
while ( NOT DEP_PARENT_DIR STREQUAL "${CMAKE_SOURCE_DIR}/extlibs" )
if ( NOT DEP_DIR MATCHES "/stb_image(/|$)" )
set ( CMAKE_IGNORE_PATH ${ CMAKE_IGNORE_PATH } ${ DEP_PARENT_DIR } )
endif ( )
get_filename_component ( DEP_PARENT_DIR ${ DEP_PARENT_DIR } PATH )
endwhile ( )
endforeach ( )
list ( REMOVE_DUPLICATES CMAKE_IGNORE_PATH )
endif ( )
2015-10-12 13:54:21 +08:00
# Visual C++: remove warnings regarding SL security and algorithms on pointers
2014-09-30 22:07:25 +08:00
if ( SFML_COMPILER_MSVC )
2016-01-01 21:18:13 +08:00
# add an option to choose whether PDB debug symbols should be generated (defaults to true when possible)
if ( CMAKE_VERSION VERSION_LESS 3.1 )
sfml_set_option ( SFML_GENERATE_PDB FALSE BOOL "True to generate PDB debug symbols, FALSE otherwise. Requires CMake 3.1." )
if ( SFML_GENERATE_PDB )
message ( FATAL_ERROR "Generation of PDB files (SFML_GENERATE_PDB) requires at least CMake 3.1.0" )
endif ( )
else ( )
sfml_set_option ( SFML_GENERATE_PDB TRUE BOOL "True to generate PDB debug symbols, FALSE otherwise. Requires CMake 3.1." )
endif ( )
2015-10-12 13:54:21 +08:00
add_definitions ( -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS )
2014-09-30 22:07:25 +08:00
endif ( )
# define SFML_OPENGL_ES if needed
if ( SFML_OPENGL_ES )
add_definitions ( -DSFML_OPENGL_ES )
add_definitions ( -DGL_GLEXT_PROTOTYPES )
endif ( )
# define an option for choosing between static and dynamic C runtime (Windows only)
if ( SFML_OS_WINDOWS )
sfml_set_option ( SFML_USE_STATIC_STD_LIBS FALSE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs" )
# the following combination of flags is not valid
2021-05-04 02:09:34 +08:00
if ( BUILD_SHARED_LIBS AND SFML_USE_STATIC_STD_LIBS )
2014-09-30 22:07:25 +08:00
message ( FATAL_ERROR "BUILD_SHARED_LIBS and SFML_USE_STATIC_STD_LIBS cannot be used together" )
endif ( )
# for VC++, we can apply it globally by modifying the compiler flags
2021-05-04 02:09:34 +08:00
if ( ( SFML_COMPILER_MSVC OR ( SFML_COMPILER_CLANG AND NOT MINGW ) ) AND SFML_USE_STATIC_STD_LIBS )
2014-09-30 22:07:25 +08:00
foreach ( flag
C M A K E _ C X X _ F L A G S C M A K E _ C X X _ F L A G S _ D E B U G C M A K E _ C X X _ F L A G S _ R E L E A S E
C M A K E _ C X X _ F L A G S _ M I N S I Z E R E L C M A K E _ C X X _ F L A G S _ R E L W I T H D E B I N F O )
if ( ${ flag } MATCHES "/MD" )
string ( REGEX REPLACE "/MD" "/MT" ${ flag } "${${flag}}" )
endif ( )
endforeach ( )
endif ( )
endif ( )
# setup Mac OS X stuff
if ( SFML_OS_MACOSX )
# SFML_BUILD_FRAMEWORKS needs two things:
# first, it's available only for release
# (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible)
# secondly, it works only with BUILD_SHARED_LIBS enabled
if ( SFML_BUILD_FRAMEWORKS )
# requirement #1
if ( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
message ( FATAL_ERROR "CMAKE_BUILD_TYPE should be \" Release\ " when SFML_BUILD_FRAMEWORKS is TRUE" )
return ( )
endif ( )
# requirement #2
if ( NOT BUILD_SHARED_LIBS )
message ( FATAL_ERROR "BUILD_SHARED_LIBS should be TRUE when SFML_BUILD_FRAMEWORKS is TRUE" )
return ( )
endif ( )
endif ( )
2021-02-08 23:51:30 +08:00
# only the default x86_64 or arm64 are supported
foreach ( arch IN LISTS CMAKE_OSX_ARCHITECTURES )
if ( NOT ( arch STREQUAL "x86_64" OR arch STREQUAL "arm64" ) )
message ( FATAL_ERROR "Invalid arch ${arch}" )
endif ( )
endforeach ( )
2017-04-06 03:56:06 +08:00
2016-04-01 01:05:08 +08:00
# configure Xcode templates
set ( XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)" )
2014-09-30 22:07:25 +08:00
endif ( )
# enable project folders
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
set_property ( GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake" )
# add the subdirectories
add_subdirectory ( src/SFML )
if ( SFML_BUILD_EXAMPLES )
add_subdirectory ( examples )
endif ( )
if ( SFML_BUILD_DOC )
add_subdirectory ( doc )
endif ( )
2018-08-19 07:30:53 +08:00
if ( SFML_BUILD_TEST_SUITE )
2018-11-30 02:38:27 +08:00
if ( SFML_OS_IOS )
message ( WARNING "Unit testing not supported on iOS" )
else ( )
enable_testing ( )
add_subdirectory ( test )
endif ( )
2014-08-26 15:52:37 +08:00
endif ( )
2014-09-30 22:07:25 +08:00
2018-08-10 04:20:35 +08:00
# on Linux and BSD-like OS, install pkg-config files by default
set ( SFML_INSTALL_PKGCONFIG_DEFAULT FALSE )
2020-12-05 15:41:26 +08:00
if ( SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD )
2018-08-10 04:20:35 +08:00
set ( SFML_INSTALL_PKGCONFIG_DEFAULT TRUE )
endif ( )
sfml_set_option ( SFML_INSTALL_PKGCONFIG_FILES ${ SFML_INSTALL_PKGCONFIG_DEFAULT } BOOL "TRUE to automatically install pkg-config files so other projects can find SFML" )
if ( SFML_INSTALL_PKGCONFIG_FILES )
sfml_set_option ( SFML_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${SFML_PKGCONFIG_DIR}" PATH "Install directory for SFML's pkg-config .pc files" )
2016-12-20 05:16:07 +08:00
foreach ( sfml_module IN ITEMS all system window graphics audio network )
CONFIGURE_FILE (
" t o o l s / p k g - c o n f i g / s f m l - $ { s f m l _ m o d u l e } . p c . i n "
" t o o l s / p k g - c o n f i g / s f m l - $ { s f m l _ m o d u l e } . p c "
@ O N L Y )
INSTALL ( FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/sfml-${sfml_module}.pc"
2018-08-10 04:20:35 +08:00
D E S T I N A T I O N " $ { S F M L _ P K G C O N F I G _ I N S T A L L _ P R E F I X } " )
2016-12-20 05:16:07 +08:00
endforeach ( )
endif ( )
2014-09-30 22:07:25 +08:00
# setup the install rules
if ( NOT SFML_BUILD_FRAMEWORKS )
install ( DIRECTORY include
D E S T I N A T I O N .
C O M P O N E N T d e v e l
F I L E S _ M A T C H I N G P A T T E R N " * . h p p " P A T T E R N " * . i n l " )
2015-12-31 03:30:59 +08:00
2016-01-01 21:18:13 +08:00
if ( SFML_GENERATE_PDB )
install ( DIRECTORY ${ PROJECT_BINARY_DIR } /lib
D E S T I N A T I O N .
C O M P O N E N T d e v e l
F I L E S _ M A T C H I N G P A T T E R N " * . p d b " )
endif ( )
2014-09-30 22:07:25 +08:00
else ( )
# find only "root" headers
file ( GLOB SFML_HEADERS RELATIVE ${ PROJECT_SOURCE_DIR } "include/SFML/*" )
# in fact we have to fool cmake to copy all the headers in subdirectories
# to do that we have to add the "root" headers to the PUBLIC_HEADER
# then we can run a post script to copy the remaining headers
# we need a dummy file in order to compile the framework
add_custom_command ( OUTPUT ${ CMAKE_CURRENT_BINARY_DIR } /dummy.cpp
C O M M A N D t o u c h $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / d u m m y . c p p )
set ( SFML_SOURCES ${ SFML_HEADERS } )
list ( APPEND SFML_SOURCES ${ CMAKE_CURRENT_BINARY_DIR } /dummy.cpp )
# create SFML.framework
add_library ( SFML ${ SFML_SOURCES } )
2021-12-02 03:14:15 +08:00
# enable C++17 support
target_compile_features ( SFML PUBLIC cxx_std_17 )
2018-01-29 01:35:00 +08:00
# set the target flags to use the appropriate C++ standard library
sfml_set_stdlib ( SFML )
2014-09-30 22:07:25 +08:00
# edit target properties
set_target_properties ( SFML PROPERTIES
F R A M E W O R K T R U E
F R A M E W O R K _ V E R S I O N $ { V E R S I O N _ M A J O R } . $ { V E R S I O N _ M I N O R } . $ { V E R S I O N _ P A T C H }
M A C O S X _ F R A M E W O R K _ I D E N T I F I E R o r g . s f m l - d e v . S F M L
M A C O S X _ F R A M E W O R K _ S H O R T _ V E R S I O N _ S T R I N G $ { V E R S I O N _ M A J O R } . $ { V E R S I O N _ M I N O R } . $ { V E R S I O N _ P A T C H }
M A C O S X _ F R A M E W O R K _ B U N D L E _ V E R S I O N $ { V E R S I O N _ M A J O R } . $ { V E R S I O N _ M I N O R } . $ { V E R S I O N _ P A T C H }
P U B L I C _ H E A D E R " $ { S F M L _ H E A D E R S } " )
2015-02-21 21:46:46 +08:00
# add the non-optional SFML headers
add_custom_command ( TARGET SFML POST_BUILD COMMAND cp -r
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / C o n f i g . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / O p e n G L . h p p
2018-04-07 08:17:05 +08:00
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / G p u P r e f e r e n c e . h p p
2015-02-21 21:46:46 +08:00
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / S y s t e m . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / M a i n . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / S y s t e m
$ < T A R G E T _ F I L E _ D I R : S F M L > / H e a d e r s )
# add window module headers if enabled
if ( SFML_BUILD_WINDOW )
add_custom_command ( TARGET SFML POST_BUILD COMMAND cp -r
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / W i n d o w . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / W i n d o w
$ < T A R G E T _ F I L E _ D I R : S F M L > / H e a d e r s )
endif ( )
# add network module headers if enabled
2017-07-19 12:40:34 +08:00
if ( SFML_BUILD_NETWORK )
2015-02-21 21:46:46 +08:00
add_custom_command ( TARGET SFML POST_BUILD COMMAND cp -r
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / N e t w o r k . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / N e t w o r k
$ < T A R G E T _ F I L E _ D I R : S F M L > / H e a d e r s )
endif ( )
# add graphics module headers if enabled
if ( SFML_BUILD_GRAPHICS )
add_custom_command ( TARGET SFML POST_BUILD COMMAND cp -r
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / G r a p h i c s . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / G r a p h i c s
$ < T A R G E T _ F I L E _ D I R : S F M L > / H e a d e r s )
endif ( )
# add audio module headers if enabled
if ( SFML_BUILD_AUDIO )
add_custom_command ( TARGET SFML POST_BUILD COMMAND cp -r
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / A u d i o . h p p
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e / S F M L / A u d i o
$ < T A R G E T _ F I L E _ D I R : S F M L > / H e a d e r s )
endif ( )
2014-09-30 22:07:25 +08:00
2015-03-10 07:56:04 +08:00
# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
2016-04-01 01:05:08 +08:00
# NOTE: it's not required to link against SFML.framework
2018-02-11 01:07:21 +08:00
set_target_properties ( SFML PROPERTIES INSTALL_NAME_DIR "@rpath" )
if ( NOT CMAKE_SKIP_BUILD_RPATH )
if ( CMAKE_VERSION VERSION_LESS 3.9 )
set_target_properties ( ${ target } PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE )
else ( )
set_target_properties ( ${ target } PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE )
endif ( )
endif ( )
2014-09-30 22:07:25 +08:00
# install rule
install ( TARGETS SFML
2018-03-21 02:46:57 +08:00
F R A M E W O R K D E S T I N A T I O N " . "
2014-09-30 22:07:25 +08:00
C O M P O N E N T d e v e l )
endif ( )
2019-04-09 18:02:17 +08:00
install ( FILES license.md DESTINATION ${ CMAKE_INSTALL_DOCDIR } )
install ( FILES readme.md DESTINATION ${ CMAKE_INSTALL_DOCDIR } )
2014-09-30 22:07:25 +08:00
# install 3rd-party libraries and tools
if ( SFML_OS_WINDOWS )
2017-06-02 16:57:15 +08:00
if ( NOT SFML_USE_SYSTEM_DEPS )
# install the binaries of SFML dependencies
if ( ARCH_32BITS )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/bin/x86/ DESTINATION ${ CMAKE_INSTALL_BINDIR } )
2017-06-02 16:57:15 +08:00
if ( SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14 )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-msvc/x86/ DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2021-05-04 02:09:34 +08:00
elseif ( SFML_COMPILER_MSVC OR ( SFML_COMPILER_CLANG AND NOT MINGW ) )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2017-06-02 16:57:15 +08:00
else ( )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-mingw/x86/ DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2017-06-02 16:57:15 +08:00
endif ( )
elseif ( ARCH_64BITS )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/bin/x64/ DESTINATION ${ CMAKE_INSTALL_BINDIR } )
2017-06-02 16:57:15 +08:00
if ( SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14 )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-msvc/x64/ DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2021-05-04 02:09:34 +08:00
elseif ( SFML_COMPILER_MSVC OR ( SFML_COMPILER_CLANG AND NOT MINGW ) )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2017-06-02 16:57:15 +08:00
else ( )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-mingw/x64/ DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2017-06-02 16:57:15 +08:00
endif ( )
2014-09-30 22:07:25 +08:00
endif ( )
endif ( )
elseif ( SFML_OS_MACOSX )
2015-01-08 23:21:39 +08:00
# install extlibs dependencies only when used
2015-02-21 21:46:46 +08:00
if ( SFML_BUILD_GRAPHICS )
if ( FREETYPE_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/freetype.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2015-01-08 23:21:39 +08:00
endif ( )
2015-02-21 21:46:46 +08:00
if ( SFML_BUILD_AUDIO )
if ( FLAC_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/FLAC.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-osx/Frameworks/FLAC.framework DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2014-09-30 22:07:25 +08:00
2015-02-21 21:46:46 +08:00
if ( OGG_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/ogg.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-osx/Frameworks/ogg.framework DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2014-10-29 01:00:51 +08:00
2015-02-21 21:46:46 +08:00
if ( VORBIS_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbis.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-osx/Frameworks/vorbis.framework DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2014-10-29 01:00:51 +08:00
2015-02-21 21:46:46 +08:00
if ( VORBISENC_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisenc.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-osx/Frameworks/vorbisenc.framework DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2014-10-29 01:00:51 +08:00
2015-02-21 21:46:46 +08:00
if ( VORBISFILE_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisfile.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY extlibs/libs-osx/Frameworks/vorbisfile.framework DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2014-10-29 01:00:51 +08:00
2015-02-21 21:46:46 +08:00
if ( OPENAL_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/OpenAL.framework" )
2019-04-09 18:02:17 +08:00
install ( DIRECTORY "${OPENAL_LIBRARY}" DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2015-02-21 21:46:46 +08:00
endif ( )
2015-03-14 19:15:41 +08:00
endif ( )
2014-09-30 22:07:25 +08:00
# install the Xcode templates if requested
if ( SFML_INSTALL_XCODE_TEMPLATES )
2014-10-08 17:08:04 +08:00
# configure the templates plist files
foreach ( TEMPLATE "SFML Compiler" "SFML App" )
configure_file (
" t o o l s / x c o d e / t e m p l a t e s / S F M L / $ { T E M P L A T E } . x c t e m p l a t e / T e m p l a t e I n f o . p l i s t . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / t o o l s / x c o d e / t e m p l a t e s / S F M L / $ { T E M P L A T E } . x c t e m p l a t e / T e m p l a t e I n f o . p l i s t "
@ O N L Y )
endforeach ( )
2014-09-30 22:07:25 +08:00
install ( DIRECTORY "tools/xcode/templates/SFML" "${CMAKE_CURRENT_BINARY_DIR}/tools/xcode/templates/SFML"
D E S T I N A T I O N / L i b r a r y / D e v e l o p e r / X c o d e / T e m p l a t e s
2014-10-08 17:08:04 +08:00
P A T T E R N " * . i n " E X C L U D E
P A T T E R N " . D S _ S t o r e " E X C L U D E )
2014-09-30 22:07:25 +08:00
endif ( )
elseif ( SFML_OS_IOS )
2018-01-25 08:52:07 +08:00
# fix CMake install rules broken for iOS (see http://public.kitware.com/Bug/view.php?id=12506)
2019-04-09 18:02:17 +08:00
install ( DIRECTORY "${CMAKE_BINARY_DIR}/lib/\$ENV{CONFIGURATION}/" DESTINATION ${ CMAKE_INSTALL_LIBDIR } )
2014-09-30 22:07:25 +08:00
2017-06-02 16:57:15 +08:00
if ( NOT SFML_USE_SYSTEM_DEPS )
# since the iOS libraries are built as static, we must install the SFML dependencies
# too so that the end user can easily link them to its final application
if ( SFML_BUILD_GRAPHICS )
2017-09-08 15:38:51 +08:00
install ( FILES extlibs/libs-ios/libfreetype.a DESTINATION lib )
2017-06-02 16:57:15 +08:00
endif ( )
2018-01-25 08:52:07 +08:00
if ( SFML_BUILD_AUDIO )
2018-04-12 03:45:36 +08:00
install ( FILES extlibs/libs-ios/libflac.a
2018-01-25 08:52:07 +08:00
e x t l i b s / l i b s - i o s / l i b v o r b i s . a
e x t l i b s / l i b s - i o s / l i b o g g . a
D E S T I N A T I O N l i b )
endif ( )
2015-02-21 21:46:46 +08:00
endif ( )
2014-09-30 22:07:25 +08:00
elseif ( SFML_OS_ANDROID )
2017-06-02 16:57:15 +08:00
if ( NOT SFML_USE_SYSTEM_DEPS )
# install extlibs
2018-01-25 22:06:30 +08:00
install ( DIRECTORY extlibs/libs-android/ ${ CMAKE_ANDROID_ARCH_ABI } DESTINATION extlibs/lib )
2017-06-02 16:57:15 +08:00
install ( FILES extlibs/Android.mk DESTINATION extlibs )
endif ( )
2014-09-30 22:07:25 +08:00
# install Android.mk so the NDK knows how to set up SFML
install ( FILES src/SFML/Android.mk DESTINATION . )
endif ( )
2018-03-21 02:47:29 +08:00
sfml_export_targets ( )
2016-07-21 21:35:48 +08:00
set ( CPACK_PACKAGE_NAME_SUMMARY "Simple and Fast Multimedia Library" )
set ( CPACK_PACKAGE_VENDOR "SFML Team" )
set ( CPACK_PACKAGE_FILE_NAME "SFML-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}-${CMAKE_BUILD_TYPE}" )
set ( CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.md" )
set ( CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}" )
set ( CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}" )
set ( CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}" )
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "SFML ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
set ( CPACK_MONOLITHIC_INSTALL ON )
# NSIS configurations
set ( CPACK_NSIS_DISPLAY_NAME "SFML ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})" )
set ( CPACK_NSIS_CONTACT "team@sfml-dev.org" )
set ( NSIS_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/nsis/" )
string ( REGEX REPLACE "/" "\\\\\\\\" NSIS_IMAGE_PATH ${ NSIS_IMAGE_PATH } )
set ( CPACK_NSIS_INSTALLER_MUI_ICON_CODE "!define MUI_WELCOMEFINISHPAGE_BITMAP \\\" ${ NSIS_IMAGE_PATH } sidebar.bmp\\\ "\n!define MUI_HEADERIMAGE_BITMAP \\\" ${ NSIS_IMAGE_PATH } header.bmp\\\ "\n!define MUI_ICON \\\" ${ NSIS_IMAGE_PATH } sfml.ico\\\ "" )
include ( CPack )