Source code changes.
* Changed newlines to \n. * Removed whitespace before colons. * Fixed several alignments.
This commit is contained in:
parent
b27cbd5036
commit
f24ca9a840
268 changed files with 40227 additions and 40227 deletions
|
@ -1,117 +1,117 @@
|
|||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(SFML_OS_WINDOWS 1)
|
||||
|
||||
# don't use the OpenGL ES implementation on Windows
|
||||
set(OPENGL_ES 0)
|
||||
|
||||
# detect the architecture (note: this test won't work for cross-compilation)
|
||||
include(CheckTypeSize)
|
||||
check_type_size(void* SIZEOF_VOID_PTR)
|
||||
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
|
||||
set(ARCH_32BITS 1)
|
||||
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
|
||||
set(ARCH_64BITS 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture")
|
||||
return()
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(SFML_OS_WINDOWS 1)
|
||||
|
||||
# don't use the OpenGL ES implementation on Windows
|
||||
set(OPENGL_ES 0)
|
||||
|
||||
# detect the architecture (note: this test won't work for cross-compilation)
|
||||
include(CheckTypeSize)
|
||||
check_type_size(void* SIZEOF_VOID_PTR)
|
||||
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
|
||||
set(ARCH_32BITS 1)
|
||||
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
|
||||
set(ARCH_64BITS 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture")
|
||||
return()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(SFML_OS_UNIX 1)
|
||||
if(ANDROID)
|
||||
set(SFML_OS_ANDROID 1)
|
||||
# use the OpenGL ES implementation on Android
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
set(SFML_OS_LINUX 1)
|
||||
# don't use the OpenGL ES implementation on Linux
|
||||
set(OPENGL_ES 0)
|
||||
if(ANDROID)
|
||||
set(SFML_OS_ANDROID 1)
|
||||
# use the OpenGL ES implementation on Android
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
set(SFML_OS_LINUX 1)
|
||||
# don't use the OpenGL ES implementation on Linux
|
||||
set(OPENGL_ES 0)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(SFML_OS_FREEBSD 1)
|
||||
# don't use the OpenGL ES implementation on FreeBSD
|
||||
set(OPENGL_ES 0)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(SFML_OS_FREEBSD 1)
|
||||
# don't use the OpenGL ES implementation on FreeBSD
|
||||
set(OPENGL_ES 0)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
if(IOS)
|
||||
set(SFML_OS_IOS 1)
|
||||
|
||||
# set the target framework and platforms
|
||||
set(CMAKE_OSX_SYSROOT "iphoneos")
|
||||
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386")
|
||||
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
|
||||
|
||||
# help the compiler detection script below
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
|
||||
# use the OpenGL ES implementation on iOS
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
set(SFML_OS_MACOSX 1)
|
||||
|
||||
# don't use the OpenGL ES implementation on Mac OS X
|
||||
set(OPENGL_ES 0)
|
||||
|
||||
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
|
||||
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
|
||||
# set the target framework and platforms
|
||||
set(CMAKE_OSX_SYSROOT "iphoneos")
|
||||
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386")
|
||||
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
|
||||
|
||||
# help the compiler detection script below
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
|
||||
# use the OpenGL ES implementation on iOS
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
set(SFML_OS_MACOSX 1)
|
||||
|
||||
# don't use the OpenGL ES implementation on Mac OS X
|
||||
set(OPENGL_ES 0)
|
||||
|
||||
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
|
||||
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
|
||||
STRING(REGEX REPLACE "10\\.([0-9]+).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}")
|
||||
if(${MACOSX_VERSION} LESS 7)
|
||||
message(FATAL_ERROR "Unsupported version of OS X: ${MACOSX_VERSION_RAW}")
|
||||
if(${MACOSX_VERSION} LESS 7)
|
||||
message(FATAL_ERROR "Unsupported version of OS X: ${MACOSX_VERSION_RAW}")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||
set(SFML_OS_ANDROID 1)
|
||||
|
||||
# use the OpenGL ES implementation on Android
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# detect the compiler and its version
|
||||
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
|
||||
# even when CLANG is used, therefore the Clang test is done first
|
||||
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
||||
# but there is no other way to detect CLang at the moment
|
||||
set(SFML_COMPILER_CLANG 1)
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
||||
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(SFML_COMPILER_GCC 1)
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
||||
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
|
||||
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
|
||||
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
|
||||
if(${GCC_MACHINE} MATCHES ".*w64.*")
|
||||
set(SFML_COMPILER_GCC_W64 1)
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
set(SFML_COMPILER_MSVC 1)
|
||||
if(MSVC_VERSION EQUAL 1400)
|
||||
set(SFML_MSVC_VERSION 8)
|
||||
elseif(MSVC_VERSION EQUAL 1500)
|
||||
set(SFML_MSVC_VERSION 9)
|
||||
elseif(MSVC_VERSION EQUAL 1600)
|
||||
set(SFML_MSVC_VERSION 10)
|
||||
elseif(MSVC_VERSION EQUAL 1700)
|
||||
set(SFML_MSVC_VERSION 11)
|
||||
elseif(MSVC_VERSION EQUAL 1800)
|
||||
set(SFML_MSVC_VERSION 12)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||
set(SFML_OS_ANDROID 1)
|
||||
|
||||
# define the install directory for miscellaneous files
|
||||
# use the OpenGL ES implementation on Android
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# detect the compiler and its version
|
||||
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
|
||||
# even when CLANG is used, therefore the Clang test is done first
|
||||
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
||||
# but there is no other way to detect CLang at the moment
|
||||
set(SFML_COMPILER_CLANG 1)
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
||||
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(SFML_COMPILER_GCC 1)
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
||||
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
|
||||
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
|
||||
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
|
||||
if(${GCC_MACHINE} MATCHES ".*w64.*")
|
||||
set(SFML_COMPILER_GCC_W64 1)
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
set(SFML_COMPILER_MSVC 1)
|
||||
if(MSVC_VERSION EQUAL 1400)
|
||||
set(SFML_MSVC_VERSION 8)
|
||||
elseif(MSVC_VERSION EQUAL 1500)
|
||||
set(SFML_MSVC_VERSION 9)
|
||||
elseif(MSVC_VERSION EQUAL 1600)
|
||||
set(SFML_MSVC_VERSION 10)
|
||||
elseif(MSVC_VERSION EQUAL 1700)
|
||||
set(SFML_MSVC_VERSION 11)
|
||||
elseif(MSVC_VERSION EQUAL 1800)
|
||||
set(SFML_MSVC_VERSION 12)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# define the install directory for miscellaneous files
|
||||
if(SFML_OS_WINDOWS OR SFML_OS_IOS)
|
||||
set(INSTALL_MISC_DIR .)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
||||
set(INSTALL_MISC_DIR share/SFML)
|
||||
elseif(SFML_OS_ANDROID)
|
||||
set(INSTALL_MISC_DIR ${ANDROID_NDK}/sources/sfml)
|
||||
endif()
|
||||
set(INSTALL_MISC_DIR .)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
||||
set(INSTALL_MISC_DIR share/SFML)
|
||||
elseif(SFML_OS_ANDROID)
|
||||
set(INSTALL_MISC_DIR ${ANDROID_NDK}/sources/sfml)
|
||||
endif()
|
||||
|
|
|
@ -1,178 +1,178 @@
|
|||
include(CMakeParseArguments)
|
||||
|
||||
# add a new target which is a SFML library
|
||||
# ex: sfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
# DEPENDS sfml-window sfml-system
|
||||
# EXTERNAL_LIBS opengl freetype ...)
|
||||
macro(sfml_add_library target)
|
||||
|
||||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN})
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# add a new target which is a SFML library
|
||||
# ex: sfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
# DEPENDS sfml-window sfml-system
|
||||
# EXTERNAL_LIBS opengl freetype ...)
|
||||
macro(sfml_add_library target)
|
||||
|
||||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN})
|
||||
|
||||
# create the target
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
|
||||
# define the export symbol of the module
|
||||
string(REPLACE "-" "_" NAME_UPPER "${target}")
|
||||
string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
|
||||
set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
|
||||
|
||||
# adjust the output file prefix/suffix to match our conventions
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if(SFML_OS_WINDOWS)
|
||||
# include the major version number in Windows shared library names (but not import library names)
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
endif()
|
||||
if (SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
|
||||
# on Windows/gcc get rid of "lib" prefix for shared libraries,
|
||||
# and transform the ".dll.a" suffix into ".a" for import libraries
|
||||
set_target_properties(${target} PROPERTIES PREFIX "")
|
||||
set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a")
|
||||
endif()
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -s-d)
|
||||
set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s)
|
||||
set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s)
|
||||
endif()
|
||||
|
||||
# set the version and soversion of the target (for compatible systems -- mostly Linuxes)
|
||||
# except for Android which strips soversion suffixes
|
||||
if(NOT SFML_OS_ANDROID)
|
||||
set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR})
|
||||
set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
||||
endif()
|
||||
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "SFML")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
|
||||
# (exported ones are explicitely marked)
|
||||
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
endif()
|
||||
|
||||
# build frameworks or dylibs
|
||||
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS)
|
||||
if(SFML_BUILD_FRAMEWORKS)
|
||||
# adapt target to build frameworks instead of dylibs
|
||||
set_target_properties(${target} PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
# adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
|
||||
set_target_properties(${target} PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
INSTALL_NAME_DIR "@executable_path/../Frameworks")
|
||||
endif()
|
||||
|
||||
# enable automatic reference counting on iOS
|
||||
if (SFML_OS_IOS)
|
||||
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
endif()
|
||||
|
||||
# sfml-activity library is our bootstrap activity and must not depend on stlport_shared
|
||||
# (otherwise Android will fail to load it)
|
||||
if (SFML_OS_ANDROID)
|
||||
if (${target} MATCHES "sfml-activity")
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fpermissive)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-landroid -llog")
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY_WITHOUT_STLPORT})
|
||||
else()
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY_WITH_STLPORT})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link the target to its external dependencies
|
||||
if(THIS_EXTERNAL_LIBS)
|
||||
target_link_libraries(${target} ${THIS_EXTERNAL_LIBS})
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
|
||||
endmacro()
|
||||
|
||||
# add a new target which is a SFML example
|
||||
# ex: sfml_add_example(ftp
|
||||
# SOURCES ftp.cpp ...
|
||||
# DEPENDS sfml-network sfml-system)
|
||||
macro(sfml_add_example target)
|
||||
|
||||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "GUI_APP" "" "SOURCES;DEPENDS" ${ARGN})
|
||||
|
||||
# set a source group for the source files
|
||||
source_group("" FILES ${THIS_SOURCES})
|
||||
|
||||
# create the target
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
|
||||
# define the export symbol of the module
|
||||
string(REPLACE "-" "_" NAME_UPPER "${target}")
|
||||
string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
|
||||
set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
|
||||
|
||||
# adjust the output file prefix/suffix to match our conventions
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if(SFML_OS_WINDOWS)
|
||||
# include the major version number in Windows shared library names (but not import library names)
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
endif()
|
||||
if (SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
|
||||
# on Windows/gcc get rid of "lib" prefix for shared libraries,
|
||||
# and transform the ".dll.a" suffix into ".a" for import libraries
|
||||
set_target_properties(${target} PROPERTIES PREFIX "")
|
||||
set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a")
|
||||
endif()
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -s-d)
|
||||
set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s)
|
||||
set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s)
|
||||
endif()
|
||||
|
||||
# set the version and soversion of the target (for compatible systems -- mostly Linuxes)
|
||||
# except for Android which strips soversion suffixes
|
||||
if(NOT SFML_OS_ANDROID)
|
||||
set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR})
|
||||
set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
||||
endif()
|
||||
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "SFML")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
|
||||
# (exported ones are explicitely marked)
|
||||
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
endif()
|
||||
|
||||
# build frameworks or dylibs
|
||||
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS)
|
||||
if(SFML_BUILD_FRAMEWORKS)
|
||||
# adapt target to build frameworks instead of dylibs
|
||||
set_target_properties(${target} PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
# adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
|
||||
set_target_properties(${target} PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
INSTALL_NAME_DIR "@executable_path/../Frameworks")
|
||||
endif()
|
||||
|
||||
# enable automatic reference counting on iOS
|
||||
if (SFML_OS_IOS)
|
||||
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
endif()
|
||||
|
||||
# sfml-activity library is our bootstrap activity and must not depend on stlport_shared
|
||||
# (otherwise Android will fail to load it)
|
||||
if (SFML_OS_ANDROID)
|
||||
if (${target} MATCHES "sfml-activity")
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fpermissive)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-landroid -llog")
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY_WITHOUT_STLPORT})
|
||||
else()
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY_WITH_STLPORT})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link the target to its external dependencies
|
||||
if(THIS_EXTERNAL_LIBS)
|
||||
target_link_libraries(${target} ${THIS_EXTERNAL_LIBS})
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
|
||||
endmacro()
|
||||
|
||||
# add a new target which is a SFML example
|
||||
# ex: sfml_add_example(ftp
|
||||
# SOURCES ftp.cpp ...
|
||||
# DEPENDS sfml-network sfml-system)
|
||||
macro(sfml_add_example target)
|
||||
|
||||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "GUI_APP" "" "SOURCES;DEPENDS" ${ARGN})
|
||||
|
||||
# set a source group for the source files
|
||||
source_group("" FILES ${THIS_SOURCES})
|
||||
|
||||
# create the target
|
||||
if(THIS_GUI_APP AND SFML_OS_WINDOWS)
|
||||
add_executable(${target} WIN32 ${THIS_SOURCES})
|
||||
target_link_libraries(${target} sfml-main)
|
||||
else()
|
||||
add_executable(${target} ${THIS_SOURCES})
|
||||
endif()
|
||||
|
||||
# set the debug suffix
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "Examples")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples
|
||||
BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples)
|
||||
|
||||
# install the example's source code
|
||||
install(FILES ${THIS_SOURCES}
|
||||
DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
|
||||
COMPONENT examples)
|
||||
|
||||
# install the example's resources as well
|
||||
set(EXAMPLE_RESOURCES "${CMAKE_SOURCE_DIR}/examples/${target}/resources")
|
||||
if(EXISTS ${EXAMPLE_RESOURCES})
|
||||
install(DIRECTORY ${EXAMPLE_RESOURCES}
|
||||
DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
|
||||
COMPONENT examples)
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
add_executable(${target} WIN32 ${THIS_SOURCES})
|
||||
target_link_libraries(${target} sfml-main)
|
||||
else()
|
||||
add_executable(${target} ${THIS_SOURCES})
|
||||
endif()
|
||||
|
||||
# set the debug suffix
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "Examples")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples
|
||||
BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples)
|
||||
|
||||
# install the example's source code
|
||||
install(FILES ${THIS_SOURCES}
|
||||
DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
|
||||
COMPONENT examples)
|
||||
|
||||
# install the example's resources as well
|
||||
set(EXAMPLE_RESOURCES "${CMAKE_SOURCE_DIR}/examples/${target}/resources")
|
||||
if(EXISTS ${EXAMPLE_RESOURCES})
|
||||
install(DIRECTORY ${EXAMPLE_RESOURCES}
|
||||
DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
|
||||
COMPONENT examples)
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#
|
||||
# Try to find EGL library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# EGL_FOUND
|
||||
# EGL_INCLUDE_PATH
|
||||
# EGL_LIBRARY
|
||||
#
|
||||
|
||||
find_path(EGL_INCLUDE_DIR EGL/egl.h)
|
||||
find_library(EGL_LIBRARY NAMES EGL)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
|
||||
#
|
||||
# Try to find EGL library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# EGL_FOUND
|
||||
# EGL_INCLUDE_PATH
|
||||
# EGL_LIBRARY
|
||||
#
|
||||
|
||||
find_path(EGL_INCLUDE_DIR EGL/egl.h)
|
||||
find_library(EGL_LIBRARY NAMES EGL)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#
|
||||
# Try to find GLES library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLES_FOUND
|
||||
# GLES_INCLUDE_PATH
|
||||
# GLES_LIBRARY
|
||||
#
|
||||
|
||||
find_path(GLES_INCLUDE_DIR GLES/gl.h)
|
||||
find_library(GLES_LIBRARY NAMES GLESv1_CM)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLES DEFAULT_MSG GLES_LIBRARY GLES_INCLUDE_DIR)
|
||||
#
|
||||
# Try to find GLES library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLES_FOUND
|
||||
# GLES_INCLUDE_PATH
|
||||
# GLES_LIBRARY
|
||||
#
|
||||
|
||||
find_path(GLES_INCLUDE_DIR GLES/gl.h)
|
||||
find_library(GLES_LIBRARY NAMES GLESv1_CM)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLES DEFAULT_MSG GLES_LIBRARY GLES_INCLUDE_DIR)
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
#
|
||||
# Try to find GLEW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_PATH
|
||||
# GLEW_LIBRARY
|
||||
#
|
||||
|
||||
IF (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
$ENV{PROGRAMFILES}/GLEW/include
|
||||
${GLEW_ROOT_DIR}/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
|
||||
IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew64 glew64s
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library (64-bit)"
|
||||
)
|
||||
ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew GLEW glew32 glew32s
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library"
|
||||
)
|
||||
ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
ELSE (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
${GLEW_ROOT_DIR}/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES GLEW glew
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
${GLEW_ROOT_DIR}/lib
|
||||
DOC "The GLEW library")
|
||||
ENDIF (WIN32)
|
||||
|
||||
SET(GLEW_FOUND "NO")
|
||||
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
|
||||
SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
|
||||
SET(GLEW_FOUND "YES")
|
||||
ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH)
|
||||
#
|
||||
# Try to find GLEW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_PATH
|
||||
# GLEW_LIBRARY
|
||||
#
|
||||
|
||||
IF (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
$ENV{PROGRAMFILES}/GLEW/include
|
||||
${GLEW_ROOT_DIR}/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
|
||||
IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew64 glew64s
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library (64-bit)"
|
||||
)
|
||||
ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew GLEW glew32 glew32s
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library"
|
||||
)
|
||||
ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
ELSE (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
${GLEW_ROOT_DIR}/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES GLEW glew
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
${GLEW_ROOT_DIR}/lib
|
||||
DOC "The GLEW library")
|
||||
ENDIF (WIN32)
|
||||
|
||||
SET(GLEW_FOUND "NO")
|
||||
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
|
||||
SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
|
||||
SET(GLEW_FOUND "YES")
|
||||
ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH)
|
||||
|
|
|
@ -1,354 +1,354 @@
|
|||
# This script locates the SFML library
|
||||
# ------------------------------------
|
||||
#
|
||||
# Usage
|
||||
# -----
|
||||
#
|
||||
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
|
||||
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
|
||||
#
|
||||
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
|
||||
# If nothing is specified, the version won't be checked (ie. any version will be accepted).
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS ...) // no specific version required
|
||||
# find_package(SFML 2 COMPONENTS ...) // any 2.x version
|
||||
# find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
|
||||
#
|
||||
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
|
||||
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
|
||||
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
|
||||
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
|
||||
# description below).
|
||||
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
|
||||
# example:
|
||||
# set(SFML_STATIC_LIBRARIES TRUE)
|
||||
# find_package(SFML 2 COMPONENTS network system)
|
||||
#
|
||||
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
|
||||
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
|
||||
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
|
||||
# are available for both release and debug modes.
|
||||
#
|
||||
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
|
||||
# to tell CMake where SFML is.
|
||||
#
|
||||
# Output
|
||||
# ------
|
||||
#
|
||||
# This script defines the following variables:
|
||||
# - For each specified module XXX (system, window, graphics, network, audio, main):
|
||||
# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
|
||||
# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
|
||||
# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
|
||||
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
|
||||
# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
|
||||
# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
|
||||
# - SFML_FOUND: true if all the required modules are found
|
||||
# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
|
||||
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
|
||||
#
|
||||
# example:
|
||||
# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
|
||||
# include_directories(${SFML_INCLUDE_DIR})
|
||||
# add_executable(myapp ...)
|
||||
# target_link_libraries(myapp ${SFML_LIBRARIES})
|
||||
|
||||
# define the SFML_STATIC macro if static build was chosen
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
add_definitions(-DSFML_STATIC)
|
||||
endif()
|
||||
|
||||
# define the list of search paths for headers and libraries
|
||||
set(FIND_SFML_PATHS
|
||||
${SFML_ROOT}
|
||||
$ENV{SFML_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt)
|
||||
|
||||
# find the SFML include directory
|
||||
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# check the version number
|
||||
set(SFML_VERSION_OK TRUE)
|
||||
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
|
||||
# extract the major and minor version numbers from SFML/Config.hpp
|
||||
# we have to handle framework a little bit differently :
|
||||
if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
|
||||
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
|
||||
else()
|
||||
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
|
||||
endif()
|
||||
FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
|
||||
STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10 + ${SFML_FIND_VERSION_MINOR}")
|
||||
|
||||
# if we could extract them, compare with the requested version number
|
||||
if (SFML_VERSION_MAJOR)
|
||||
# transform version numbers to an integer
|
||||
math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10 + ${SFML_VERSION_MINOR}")
|
||||
|
||||
# compare them
|
||||
if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
|
||||
set(SFML_VERSION_OK FALSE)
|
||||
endif()
|
||||
else()
|
||||
# SFML version is < 2.0
|
||||
if (SFML_REQUESTED_VERSION GREATER 19)
|
||||
set(SFML_VERSION_OK FALSE)
|
||||
set(SFML_VERSION_MAJOR 1)
|
||||
set(SFML_VERSION_MINOR x)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# find the requested modules
|
||||
set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
|
||||
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
|
||||
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
|
||||
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
|
||||
set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
|
||||
|
||||
# no suffix for sfml-main, it is always a static library
|
||||
if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
|
||||
# release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
else()
|
||||
# static release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-s
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# static debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# dynamic release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# dynamic debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# choose the entries that fit the requested link type
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
|
||||
endif()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
|
||||
endif()
|
||||
else()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
|
||||
endif()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
# library found
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
|
||||
|
||||
# if both are found, set SFML_XXX_LIBRARY to contain both
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
|
||||
optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
endif()
|
||||
|
||||
# if only one debug/release variant is found, set the other to be equal to the found one
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
# debug and not release
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
|
||||
endif()
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
|
||||
# release and not debug
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
endif()
|
||||
else()
|
||||
# library not found
|
||||
set(SFML_FOUND FALSE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
|
||||
set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
|
||||
endif()
|
||||
|
||||
# mark as advanced
|
||||
MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
|
||||
|
||||
# add to the global list of libraries
|
||||
set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
|
||||
endforeach()
|
||||
|
||||
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(FIND_SFML_OS_WINDOWS 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(FIND_SFML_OS_LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(FIND_SFML_OS_FREEBSD 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(FIND_SFML_OS_MACOSX 1)
|
||||
endif()
|
||||
|
||||
# start with an empty list
|
||||
set(SFML_DEPENDENCIES)
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
|
||||
# macro that searches for a 3rd-party library
|
||||
macro(find_sfml_dependency output friendlyname)
|
||||
find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib)
|
||||
if(${${output}} STREQUAL "${output}-NOTFOUND")
|
||||
unset(output)
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# sfml-system
|
||||
list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
|
||||
if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
|
||||
|
||||
# update the list -- these are only system libraries, no need to find them
|
||||
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "pthread")
|
||||
endif()
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "rt")
|
||||
endif()
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "winmm")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-network
|
||||
list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
|
||||
if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
|
||||
|
||||
# update the list -- these are only system libraries, no need to find them
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_NETWORK_DEPENDENCIES "ws2_32")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-window
|
||||
list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
|
||||
if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
find_sfml_dependency(X11_LIBRARY "X11" X11)
|
||||
find_sfml_dependency(XRANDR_LIBRARY "Xrandr" Xrandr)
|
||||
endif()
|
||||
|
||||
# update the list
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
|
||||
elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY})
|
||||
if(FIND_SFML_OS_FREEBSD)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "usbhid")
|
||||
endif()
|
||||
elseif(FIND_SFML_OS_MACOSX)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-graphics
|
||||
list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
|
||||
if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
|
||||
find_sfml_dependency(GLEW_LIBRARY "GLEW" glew GLEW glew32 glew32s glew64 glew64s)
|
||||
find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)
|
||||
|
||||
# update the list
|
||||
set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
|
||||
set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-audio
|
||||
list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
|
||||
if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
|
||||
find_sfml_dependency(SNDFILE_LIBRARY "libsndfile" sndfile)
|
||||
|
||||
# update the list
|
||||
set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})
|
||||
set(SFML_DEPENDENCIES ${SFML_AUDIO_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# handle errors
|
||||
if(NOT SFML_VERSION_OK)
|
||||
# SFML version not ok
|
||||
set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR})")
|
||||
set(SFML_FOUND FALSE)
|
||||
elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
|
||||
set(SFML_FOUND FALSE)
|
||||
elseif(NOT SFML_FOUND)
|
||||
# include directory or library not found
|
||||
set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
|
||||
endif()
|
||||
if (NOT SFML_FOUND)
|
||||
if(SFML_FIND_REQUIRED)
|
||||
# fatal error
|
||||
message(FATAL_ERROR ${FIND_SFML_ERROR})
|
||||
elseif(NOT SFML_FIND_QUIETLY)
|
||||
# error but continue
|
||||
message("${FIND_SFML_ERROR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# handle success
|
||||
if(SFML_FOUND)
|
||||
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
|
||||
endif()
|
||||
# This script locates the SFML library
|
||||
# ------------------------------------
|
||||
#
|
||||
# Usage
|
||||
# -----
|
||||
#
|
||||
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
|
||||
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
|
||||
#
|
||||
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
|
||||
# If nothing is specified, the version won't be checked (ie. any version will be accepted).
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS ...) // no specific version required
|
||||
# find_package(SFML 2 COMPONENTS ...) // any 2.x version
|
||||
# find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
|
||||
#
|
||||
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
|
||||
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
|
||||
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
|
||||
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
|
||||
# description below).
|
||||
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
|
||||
# example:
|
||||
# set(SFML_STATIC_LIBRARIES TRUE)
|
||||
# find_package(SFML 2 COMPONENTS network system)
|
||||
#
|
||||
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
|
||||
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
|
||||
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
|
||||
# are available for both release and debug modes.
|
||||
#
|
||||
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
|
||||
# to tell CMake where SFML is.
|
||||
#
|
||||
# Output
|
||||
# ------
|
||||
#
|
||||
# This script defines the following variables:
|
||||
# - For each specified module XXX (system, window, graphics, network, audio, main):
|
||||
# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
|
||||
# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
|
||||
# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
|
||||
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
|
||||
# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
|
||||
# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
|
||||
# - SFML_FOUND: true if all the required modules are found
|
||||
# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
|
||||
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
|
||||
#
|
||||
# example:
|
||||
# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
|
||||
# include_directories(${SFML_INCLUDE_DIR})
|
||||
# add_executable(myapp ...)
|
||||
# target_link_libraries(myapp ${SFML_LIBRARIES})
|
||||
|
||||
# define the SFML_STATIC macro if static build was chosen
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
add_definitions(-DSFML_STATIC)
|
||||
endif()
|
||||
|
||||
# define the list of search paths for headers and libraries
|
||||
set(FIND_SFML_PATHS
|
||||
${SFML_ROOT}
|
||||
$ENV{SFML_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt)
|
||||
|
||||
# find the SFML include directory
|
||||
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# check the version number
|
||||
set(SFML_VERSION_OK TRUE)
|
||||
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
|
||||
# extract the major and minor version numbers from SFML/Config.hpp
|
||||
# we have to handle framework a little bit differently:
|
||||
if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
|
||||
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
|
||||
else()
|
||||
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
|
||||
endif()
|
||||
FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
|
||||
STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10 + ${SFML_FIND_VERSION_MINOR}")
|
||||
|
||||
# if we could extract them, compare with the requested version number
|
||||
if (SFML_VERSION_MAJOR)
|
||||
# transform version numbers to an integer
|
||||
math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10 + ${SFML_VERSION_MINOR}")
|
||||
|
||||
# compare them
|
||||
if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
|
||||
set(SFML_VERSION_OK FALSE)
|
||||
endif()
|
||||
else()
|
||||
# SFML version is < 2.0
|
||||
if (SFML_REQUESTED_VERSION GREATER 19)
|
||||
set(SFML_VERSION_OK FALSE)
|
||||
set(SFML_VERSION_MAJOR 1)
|
||||
set(SFML_VERSION_MINOR x)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# find the requested modules
|
||||
set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
|
||||
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
|
||||
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
|
||||
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
|
||||
set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
|
||||
|
||||
# no suffix for sfml-main, it is always a static library
|
||||
if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
|
||||
# release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
else()
|
||||
# static release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-s
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# static debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# dynamic release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# dynamic debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# choose the entries that fit the requested link type
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
|
||||
endif()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
|
||||
endif()
|
||||
else()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
|
||||
endif()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
# library found
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
|
||||
|
||||
# if both are found, set SFML_XXX_LIBRARY to contain both
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
|
||||
optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
endif()
|
||||
|
||||
# if only one debug/release variant is found, set the other to be equal to the found one
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
# debug and not release
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
|
||||
endif()
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
|
||||
# release and not debug
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
endif()
|
||||
else()
|
||||
# library not found
|
||||
set(SFML_FOUND FALSE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
|
||||
set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
|
||||
endif()
|
||||
|
||||
# mark as advanced
|
||||
MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
|
||||
|
||||
# add to the global list of libraries
|
||||
set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
|
||||
endforeach()
|
||||
|
||||
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(FIND_SFML_OS_WINDOWS 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(FIND_SFML_OS_LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(FIND_SFML_OS_FREEBSD 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(FIND_SFML_OS_MACOSX 1)
|
||||
endif()
|
||||
|
||||
# start with an empty list
|
||||
set(SFML_DEPENDENCIES)
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
|
||||
# macro that searches for a 3rd-party library
|
||||
macro(find_sfml_dependency output friendlyname)
|
||||
find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib)
|
||||
if(${${output}} STREQUAL "${output}-NOTFOUND")
|
||||
unset(output)
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# sfml-system
|
||||
list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
|
||||
if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
|
||||
|
||||
# update the list -- these are only system libraries, no need to find them
|
||||
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "pthread")
|
||||
endif()
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "rt")
|
||||
endif()
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "winmm")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-network
|
||||
list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
|
||||
if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
|
||||
|
||||
# update the list -- these are only system libraries, no need to find them
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_NETWORK_DEPENDENCIES "ws2_32")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-window
|
||||
list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
|
||||
if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
find_sfml_dependency(X11_LIBRARY "X11" X11)
|
||||
find_sfml_dependency(XRANDR_LIBRARY "Xrandr" Xrandr)
|
||||
endif()
|
||||
|
||||
# update the list
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
|
||||
elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY})
|
||||
if(FIND_SFML_OS_FREEBSD)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "usbhid")
|
||||
endif()
|
||||
elseif(FIND_SFML_OS_MACOSX)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-graphics
|
||||
list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
|
||||
if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
|
||||
find_sfml_dependency(GLEW_LIBRARY "GLEW" glew GLEW glew32 glew32s glew64 glew64s)
|
||||
find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)
|
||||
|
||||
# update the list
|
||||
set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
|
||||
set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-audio
|
||||
list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
|
||||
if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
|
||||
find_sfml_dependency(SNDFILE_LIBRARY "libsndfile" sndfile)
|
||||
|
||||
# update the list
|
||||
set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})
|
||||
set(SFML_DEPENDENCIES ${SFML_AUDIO_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# handle errors
|
||||
if(NOT SFML_VERSION_OK)
|
||||
# SFML version not ok
|
||||
set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR})")
|
||||
set(SFML_FOUND FALSE)
|
||||
elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
|
||||
set(SFML_FOUND FALSE)
|
||||
elseif(NOT SFML_FOUND)
|
||||
# include directory or library not found
|
||||
set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
|
||||
endif()
|
||||
if (NOT SFML_FOUND)
|
||||
if(SFML_FIND_REQUIRED)
|
||||
# fatal error
|
||||
message(FATAL_ERROR ${FIND_SFML_ERROR})
|
||||
elseif(NOT SFML_FIND_QUIETLY)
|
||||
# error but continue
|
||||
message("${FIND_SFML_ERROR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# handle success
|
||||
if(SFML_FOUND)
|
||||
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
# - Find sndfile
|
||||
# Find the native sndfile includes and libraries
|
||||
#
|
||||
# SNDFILE_INCLUDE_DIR - where to find sndfile.h, etc.
|
||||
# SNDFILE_LIBRARIES - List of libraries when using libsndfile.
|
||||
# SNDFILE_FOUND - True if libsndfile found.
|
||||
|
||||
if(SNDFILE_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(SNDFILE_FIND_QUIETLY TRUE)
|
||||
endif(SNDFILE_INCLUDE_DIR)
|
||||
|
||||
find_path(SNDFILE_INCLUDE_DIR sndfile.h)
|
||||
|
||||
find_library(SNDFILE_LIBRARY NAMES sndfile sndfile-1)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
|
||||
# all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SNDFILE DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
|
||||
|
||||
if(SNDFILE_FOUND)
|
||||
set(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
|
||||
else(SNDFILE_FOUND)
|
||||
set(SNDFILE_LIBRARIES)
|
||||
endif(SNDFILE_FOUND)
|
||||
|
||||
mark_as_advanced(SNDFILE_INCLUDE_DIR SNDFILE_LIBRARY)
|
||||
# - Find sndfile
|
||||
# Find the native sndfile includes and libraries
|
||||
#
|
||||
# SNDFILE_INCLUDE_DIR - where to find sndfile.h, etc.
|
||||
# SNDFILE_LIBRARIES - List of libraries when using libsndfile.
|
||||
# SNDFILE_FOUND - True if libsndfile found.
|
||||
|
||||
if(SNDFILE_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(SNDFILE_FIND_QUIETLY TRUE)
|
||||
endif(SNDFILE_INCLUDE_DIR)
|
||||
|
||||
find_path(SNDFILE_INCLUDE_DIR sndfile.h)
|
||||
|
||||
find_library(SNDFILE_LIBRARY NAMES sndfile sndfile-1)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
|
||||
# all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SNDFILE DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
|
||||
|
||||
if(SNDFILE_FOUND)
|
||||
set(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
|
||||
else(SNDFILE_FOUND)
|
||||
set(SNDFILE_LIBRARIES)
|
||||
endif(SNDFILE_FOUND)
|
||||
|
||||
mark_as_advanced(SNDFILE_INCLUDE_DIR SNDFILE_LIBRARY)
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue