diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Config.cmake | 15 | ||||
-rw-r--r-- | cmake/Macros.cmake | 27 | ||||
-rw-r--r-- | cmake/SFMLConfigDependencies.cmake.in | 16 | ||||
-rw-r--r-- | cmake/toolchains/iOS.toolchain.cmake | 101 |
4 files changed, 68 insertions, 91 deletions
diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 82a094c..0a28660 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -69,17 +69,12 @@ else() return() endif() -# check if OS or package system supports pkg-config +# set pkgconfig install directory # this could be e.g. macports on mac or msys2 on windows etc. -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE) - if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig") - set(SFML_OS_SUPPORTS_PKGCONFIG ON) - set(SFML_OS_PKGCONFIG_DIR "/lib${LIB_SUFFIX}/pkgconfig") - elseif(EXISTS "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig") - set(SFML_OS_SUPPORTS_PKGCONFIG ON) - set(SFML_OS_PKGCONFIG_DIR "/libdata/pkgconfig") - endif() +set(SFML_PKGCONFIG_DIR "/lib${LIB_SUFFIX}/pkgconfig") + +if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD) + set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig") endif() # detect the compiler and its version diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index be52345..ecb37c8 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -1,7 +1,12 @@ include(CMakeParseArguments) +# This little macro lets you set any Xcode specific property +macro (sfml_set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) + set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) +endmacro () + # set the appropriate standard library on each platform for the given target -# ex: sfml_set_stdlib(sfml-system) +# example: sfml_set_stdlib(sfml-system) function(sfml_set_stdlib target) # 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") @@ -14,7 +19,7 @@ function(sfml_set_stdlib target) if (SFML_OS_MACOSX) if (${CMAKE_GENERATOR} MATCHES "Xcode") - set_property(TARGET ${target} PROPERTY XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + sfml_set_xcode_property(${target} CLANG_CXX_LIBRARY "libc++") else() target_compile_options(${target} PRIVATE "-stdlib=libc++") target_link_libraries(${target} PRIVATE "-stdlib=libc++") @@ -23,9 +28,9 @@ function(sfml_set_stdlib target) endfunction() # add a new target which is a SFML library -# ex: sfml_add_library(sfml-graphics -# SOURCES sprite.cpp image.cpp ... -# [STATIC]) # Always create a static library and ignore BUILD_SHARED_LIBS +# example: sfml_add_library(sfml-graphics +# SOURCES sprite.cpp image.cpp ... +# [STATIC]) # Always create a static library and ignore BUILD_SHARED_LIBS macro(sfml_add_library target) # parse the arguments @@ -178,11 +183,11 @@ macro(sfml_add_library target) endmacro() # add a new target which is a SFML example -# ex: sfml_add_example(ftp -# SOURCES ftp.cpp ... -# BUNDLE_RESOURCES MainMenu.nib ... # Files to be added in target but not installed next to the executable -# DEPENDS sfml-network -# RESOURCES_DIR resources) # A directory to install next to the executable and sources +# example: sfml_add_example(ftp +# SOURCES ftp.cpp ... +# BUNDLE_RESOURCES MainMenu.nib ... # Files to be added in target but not installed next to the executable +# DEPENDS sfml-network +# RESOURCES_DIR resources) # A directory to install next to the executable and sources macro(sfml_add_example target) # parse the arguments @@ -320,7 +325,7 @@ function(sfml_export_targets) if (SFML_BUILD_FRAMEWORKS) set(config_package_location "SFML.framework/Resources/CMake") else() - set(config_package_location lib/cmake/SFML) + set(config_package_location lib${LIB_SUFFIX}/cmake/SFML) endif() configure_package_config_file("${CURRENT_DIR}/SFMLConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/SFMLConfig.cmake" INSTALL_DESTINATION "${config_package_location}") diff --git a/cmake/SFMLConfigDependencies.cmake.in b/cmake/SFMLConfigDependencies.cmake.in index 2f85b38..1028110 100644 --- a/cmake/SFMLConfigDependencies.cmake.in +++ b/cmake/SFMLConfigDependencies.cmake.in @@ -13,7 +13,11 @@ if(SFML_STATIC_LIBRARIES) elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(FIND_SFML_OS_FREEBSD 1) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(FIND_SFML_OS_MACOSX 1) + if (DEFINED IOS) + set(FIND_SFML_OS_IOS 1) + else() + set(FIND_SFML_OS_MACOSX 1) + endif() endif() # start with an empty list @@ -51,7 +55,7 @@ if(SFML_STATIC_LIBRARIES) if (FIND_SFML_OS_WINDOWS) set_property(TARGET OpenGL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "OpenGL32") - else() + elseif(NOT FIND_SFML_OS_IOS) sfml_bind_dependency(TARGET OpenGL FRIENDLY_NAME "OpenGL" SEARCH_NAMES "OpenGL" "GL") endif() endif() @@ -66,10 +70,12 @@ if(SFML_STATIC_LIBRARIES) list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT_INDEX) if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1) sfml_bind_dependency(TARGET OpenAL FRIENDLY_NAME "OpenAL" SEARCH_NAMES "OpenAL" "openal" "openal32") - sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg") + if (NOT FIND_SFML_OS_IOS) + sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "VorbisFile" SEARCH_NAMES "vorbisfile") + sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "VorbisEnc" SEARCH_NAMES "vorbisenc") + endif() sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "Vorbis" SEARCH_NAMES "vorbis") - sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "VorbisFile" SEARCH_NAMES "vorbisfile") - sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "VorbisEnc" SEARCH_NAMES "vorbisenc") + sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg") sfml_bind_dependency(TARGET FLAC FRIENDLY_NAME "FLAC" SEARCH_NAMES "FLAC") endif() diff --git a/cmake/toolchains/iOS.toolchain.cmake b/cmake/toolchains/iOS.toolchain.cmake index abbff03..c697857 100644 --- a/cmake/toolchains/iOS.toolchain.cmake +++ b/cmake/toolchains/iOS.toolchain.cmake @@ -22,13 +22,13 @@ # OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch. # SIMULATOR - used to build for the Simulator platforms, which have an x86_64 arch. # -# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder +# IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder # By default this location is automatcially chosen based on the IOS_PLATFORM value above. # If set manually, it will override the default location and force the user of a particular Developer Platform # -# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder -# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. -# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. +# IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder +# By default this location is automatcially chosen based on the IOS_DEVELOPER_ROOT value. +# In this case it will always be the most up-to-date SDK found in the IOS_DEVELOPER_ROOT path. # If set manually, this will force the use of a specific SDK version # Macros: @@ -58,8 +58,8 @@ if (CMAKE_UNAME) string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") endif (CMAKE_UNAME) -set(CMAKE_C_COMPILER /usr/bin/gcc CACHE FILEPATH "" FORCE) -set(CMAKE_CXX_COMPILER /usr/bin/g++ CACHE FILEPATH "" FORCE) +set(CMAKE_C_COMPILER /usr/bin/clang CACHE FILEPATH "" FORCE) +set(CMAKE_CXX_COMPILER /usr/bin/clang++ CACHE FILEPATH "" FORCE) set(CMAKE_AR ar CACHE FILEPATH "" FORCE) # Skip the platform compiler checks for cross compiling @@ -105,64 +105,43 @@ endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) if (NOT DEFINED IOS_PLATFORM) set (IOS_PLATFORM "OS") endif (NOT DEFINED IOS_PLATFORM) -set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") - -# Setup building for arm64 or not -if (NOT DEFINED BUILD_ARM64) - set (BUILD_ARM64 true) -endif (NOT DEFINED BUILD_ARM64) -set (BUILD_ARM64 ${BUILD_ARM64} CACHE STRING "Build arm64 arch or not") +set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform: OS or SIMULATOR") # Check the platform selection and setup for developer root -if (${IOS_PLATFORM} STREQUAL OS) - message (STATUS "Targeting iPhone platform") +if (IOS_PLATFORM STREQUAL OS) set (IOS_PLATFORM_LOCATION "iPhoneOS.platform") # This causes the installers to properly locate the output libraries set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") -elseif (${IOS_PLATFORM} STREQUAL SIMULATOR) - message (STATUS "Targeting iPhoneSimulator platform") - set (SIMULATOR true) +elseif (IOS_PLATFORM STREQUAL SIMULATOR) set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform") # This causes the installers to properly locate the output libraries set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") - -else (${IOS_PLATFORM} STREQUAL OS) - message (FATAL_ERROR "Unsupported IOS_PLATFORM value '${IOS_PLATFORM}' selected. Please choose OS or SIMULATOR") -endif (${IOS_PLATFORM} STREQUAL OS) - -# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT -# Note Xcode 4.3 changed the installation location, choose the most recent one available -exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR) -set (XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer") -set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") -if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) - if (EXISTS ${XCODE_POST_43_ROOT}) - set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT}) - elseif(EXISTS ${XCODE_PRE_43_ROOT}) - set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT}) - endif (EXISTS ${XCODE_POST_43_ROOT}) -endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) -set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform") - -# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT -if (NOT DEFINED CMAKE_IOS_SDK_ROOT) - file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*") - if (_CMAKE_IOS_SDKS) - list (SORT _CMAKE_IOS_SDKS) - list (REVERSE _CMAKE_IOS_SDKS) - list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT) - else (_CMAKE_IOS_SDKS) - message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.") - endif (_CMAKE_IOS_SDKS) - message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}") -endif (NOT DEFINED CMAKE_IOS_SDK_ROOT) -set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK") +else () + message (FATAL_ERROR "Unsupported IOS_PLATFORM value '${IOS_PLATFORM}' selected. Please choose OS or SIMULATOR") +endif () + +# Setup iOS developer location unless specified manually with IOS_DEVELOPER_ROOT +exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE XCODE_DEVELOPER_DIR) +set (IOS_DEVELOPER_ROOT "${XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer" CACHE PATH "Location of iOS Platform") + +# Find and use the most recent iOS sdk unless specified manually with IOS_SDK_ROOT +if (NOT DEFINED IOS_SDK_ROOT) + file (GLOB _IOS_SDKS "${IOS_DEVELOPER_ROOT}/SDKs/*") + if (_IOS_SDKS) + list (SORT _IOS_SDKS) + list (REVERSE _IOS_SDKS) + list (GET _IOS_SDKS 0 IOS_SDK_ROOT) + else (_IOS_SDKS) + message (FATAL_ERROR "No iOS SDK's found in default search path ${IOS_DEVELOPER_ROOT}. Manually set IOS_SDK_ROOT or install the iOS SDK.") + endif (_IOS_SDKS) + message (STATUS "Toolchain using default iOS SDK: ${IOS_SDK_ROOT}") +endif (NOT DEFINED IOS_SDK_ROOT) +set (IOS_SDK_ROOT ${IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK") # Set the sysroot default to the most recent SDK -set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") -message (STATUS "iOS sysroot=${CMAKE_OSX_SYSROOT}") +set (CMAKE_OSX_SYSROOT ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") # set the architecture for iOS if (${IOS_PLATFORM} STREQUAL OS) @@ -172,21 +151,19 @@ elseif (${IOS_PLATFORM} STREQUAL SIMULATOR) set (IOS_ARCH x86_64) endif (${IOS_PLATFORM} STREQUAL OS) -set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS" FORCE) -set (CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS ${IOS_ARCH}) -message (STATUS "iOS architecture=${IOS_ARCH}") +set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS" FORCE) # Set the find root to the iOS developer roots and to user defined paths -set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root") +set (CMAKE_FIND_ROOT_PATH ${IOS_DEVELOPER_ROOT} ${IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE STRING "iOS find search path root") # default to searching for frameworks first set (CMAKE_FIND_FRAMEWORK FIRST) # set up the default search directories for frameworks set (CMAKE_SYSTEM_FRAMEWORK_PATH - ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks - ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks - ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks + ${IOS_SDK_ROOT}/System/Library/Frameworks + ${IOS_SDK_ROOT}/System/Library/PrivateFrameworks + ${IOS_SDK_ROOT}/Developer/Library/Frameworks ) # only search the iOS sdks, not the remainder of the host filesystem @@ -195,12 +172,6 @@ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -# This little macro lets you set any XCode specific property -macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) - set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) -endmacro (set_xcode_property) - - # This macro lets you find executable programs on the host system macro (find_host_package) set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |