diff --git a/CMakeLists.txt b/CMakeLists.txt index f9b1a68cd..91ea434f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ endif() # Android options if(SFML_OS_ANDROID) sfml_set_option(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK FALSE BOOL "TRUE to use an sf::Clock implementation which takes system sleep time into account (keeps advancing during suspension), FALSE to default to another available monotonic clock") - if (SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK) + if(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK) add_definitions(-DSFML_ANDROID_USE_SUSPEND_AWARE_CLOCK) endif() @@ -108,7 +108,7 @@ if(SFML_OS_ANDROID) list(PREPEND CMAKE_FIND_ROOT_PATH "${PROJECT_SOURCE_DIR}") # make sure there's the android library available - if (CMAKE_ANDROID_API LESS 26) + if(CMAKE_ANDROID_API LESS 26) message(FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 26.") endif() @@ -123,7 +123,7 @@ if(SFML_OS_ANDROID) # we install libs in a subdirectory named after the ABI set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CMAKE_ANDROID_ARCH_ABI}") # pass shared STL configuration (if any) - if (CMAKE_ANDROID_STL_TYPE MATCHES "_shared") + if(CMAKE_ANDROID_STL_TYPE MATCHES "_shared") add_definitions("-DSTL_LIBRARY=${CMAKE_ANDROID_STL_TYPE}") endif() @@ -230,8 +230,8 @@ if(SFML_OS_MACOSX) endif() # 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")) + 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() @@ -256,7 +256,7 @@ if(SFML_BUILD_DOC) add_subdirectory(doc) endif() if(SFML_BUILD_TEST_SUITE) - if (SFML_OS_IOS) + if(SFML_OS_IOS) message( WARNING "Unit testing not supported on iOS") elseif(SFML_BUILD_WINDOW AND SFML_BUILD_GRAPHICS AND SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO) enable_testing() diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 3629aee0d..6bd930002 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -4,9 +4,9 @@ include(CMakeParseArguments) include(${CMAKE_CURRENT_LIST_DIR}/CompilerWarnings.cmake) # This little macro lets you set any Xcode specific property -macro (sfml_set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) +macro(sfml_set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) -endmacro () +endmacro() # set the appropriate standard library on each platform for the given target # example: sfml_set_stdlib(sfml-system) @@ -20,8 +20,8 @@ function(sfml_set_stdlib target) endif() endif() - if (SFML_OS_MACOSX) - if (${CMAKE_GENERATOR} MATCHES "Xcode") + if(SFML_OS_MACOSX) + if(${CMAKE_GENERATOR} MATCHES "Xcode") sfml_set_xcode_property(${target} CLANG_CXX_LIBRARY "libc++") elseif(SFML_COMPILER_CLANG) target_compile_options(${target} PRIVATE "-stdlib=libc++") @@ -39,7 +39,7 @@ function(sfml_set_common_ios_properties target) sfml_set_xcode_property(${target} CODE_SIGN_IDENTITY "${SFML_CODE_SIGN_IDENTITY}") get_target_property(target_type ${target} TYPE) - if (target_type STREQUAL "EXECUTABLE") + if(target_type STREQUAL "EXECUTABLE") set_target_properties(${target} PROPERTIES MACOSX_BUNDLE TRUE # Bare executables are not usable on iOS, only bundle applications MACOSX_BUNDLE_GUI_IDENTIFIER "org.sfml-dev.${target}" # If missing, trying to launch an example in simulator will make Xcode < 9.3 crash @@ -57,13 +57,13 @@ macro(sfml_add_library module) # parse the arguments cmake_parse_arguments(THIS "STATIC" "" "SOURCES" ${ARGN}) - if (NOT "${THIS_UNPARSED_ARGUMENTS}" STREQUAL "") + if(NOT "${THIS_UNPARSED_ARGUMENTS}" STREQUAL "") message(FATAL_ERROR "Extra unparsed arguments when calling sfml_add_library: ${THIS_UNPARSED_ARGUMENTS}") endif() # create the target string(TOLOWER sfml-${module} target) - if (THIS_STATIC) + if(THIS_STATIC) add_library(${target} STATIC ${THIS_SOURCES}) else() add_library(${target} ${THIS_SOURCES}) @@ -74,7 +74,7 @@ macro(sfml_add_library module) target_compile_features(${target} PUBLIC cxx_std_17) # Add required flags for GCC if coverage reporting is enabled - if (SFML_ENABLE_COVERAGE AND (SFML_COMPILER_GCC OR SFML_COMPILER_CLANG)) + if(SFML_ENABLE_COVERAGE AND (SFML_COMPILER_GCC OR SFML_COMPILER_CLANG)) target_compile_options(${target} PUBLIC $<$:-O0> $<$:-g> $<$:-fprofile-arcs> $<$:-ftest-coverage>) target_link_options(${target} PUBLIC $<$:--coverage>) endif() @@ -116,7 +116,7 @@ macro(sfml_add_library module) target_sources(${target} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${target}.rc") source_group("" FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.rc") - if (SFML_COMPILER_GCC OR SFML_COMPILER_CLANG) + if(SFML_COMPILER_GCC OR SFML_COMPILER_CLANG) # on Windows + gcc/clang 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 "") @@ -131,7 +131,7 @@ macro(sfml_add_library module) set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s) set_target_properties(${target} PROPERTIES RELWITHDEBINFO_POSTFIX -s) - if (SFML_USE_STATIC_STD_LIBS) + if(SFML_USE_STATIC_STD_LIBS) set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() endif() @@ -198,14 +198,14 @@ macro(sfml_add_library module) endif() endif() - if (SFML_OS_IOS) + if(SFML_OS_IOS) sfml_set_common_ios_properties(${target}) 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") + 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_STL}) @@ -226,7 +226,7 @@ macro(sfml_add_library module) PUBLIC $ PRIVATE ${PROJECT_SOURCE_DIR}/src) - if (SFML_BUILD_FRAMEWORKS) + if(SFML_BUILD_FRAMEWORKS) target_include_directories(${target} INTERFACE $) else() target_include_directories(${target} INTERFACE $) @@ -281,7 +281,7 @@ macro(sfml_add_example target) add_executable(${target} ${target_input}) endif() - if (SFML_USE_STATIC_STD_LIBS) + if(SFML_USE_STATIC_STD_LIBS) set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() @@ -304,7 +304,7 @@ macro(sfml_add_example target) target_link_libraries(${target} PRIVATE ${THIS_DEPENDS}) endif() - if (SFML_OS_IOS) + if(SFML_OS_IOS) sfml_set_common_ios_properties(${target}) endif() @@ -332,8 +332,8 @@ function(sfml_add_test target SOURCES DEPENDS) # If coverage is enabled for MSVC and we are linking statically, use /WHOLEARCHIVE # to make sure the linker doesn't discard unused code sections before coverage can be measured - if (SFML_ENABLE_COVERAGE AND SFML_COMPILER_MSVC AND NOT BUILD_SHARED_LIBS) - foreach (DEPENDENCY ${DEPENDS}) + if(SFML_ENABLE_COVERAGE AND SFML_COMPILER_MSVC AND NOT BUILD_SHARED_LIBS) + foreach(DEPENDENCY ${DEPENDS}) target_link_options(${target} PRIVATE $<$:/WHOLEARCHIVE:$>) endforeach() endif() @@ -352,29 +352,29 @@ function(sfml_add_external) list(GET ARGN 0 target) list(REMOVE_AT ARGN 0) - if (TARGET ${target}) + if(TARGET ${target}) message(FATAL_ERROR "Target '${target}' is already defined") endif() cmake_parse_arguments(THIS "" "" "INCLUDE;LINK" ${ARGN}) - if (THIS_UNPARSED_ARGUMENTS) + if(THIS_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown arguments when calling sfml_add_external: ${THIS_UNPARSED_ARGUMENTS}") endif() add_library(${target} INTERFACE) - if (THIS_INCLUDE) + if(THIS_INCLUDE) foreach(include_dir IN LISTS THIS_INCLUDE) - if (NOT include_dir) + if(NOT include_dir) message(FATAL_ERROR "No path given for include dir ${THIS_INCLUDE}") endif() target_include_directories(${target} SYSTEM INTERFACE "$") endforeach() endif() - if (THIS_LINK) + if(THIS_LINK) foreach(link_item IN LISTS THIS_LINK) - if (NOT link_item) + if(NOT link_item) message(FATAL_ERROR "Missing item in ${THIS_LINK}") endif() target_link_libraries(${target} INTERFACE "$") @@ -393,16 +393,16 @@ function(sfml_find_package) list(GET ARGN 0 target) list(REMOVE_AT ARGN 0) - if (TARGET ${target}) + if(TARGET ${target}) message(FATAL_ERROR "Target '${target}' is already defined") endif() cmake_parse_arguments(THIS "" "" "INCLUDE;LINK" ${ARGN}) - if (THIS_UNPARSED_ARGUMENTS) + if(THIS_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown arguments when calling sfml_find_package: ${THIS_UNPARSED_ARGUMENTS}") endif() - if (SFML_OS_IOS) + if(SFML_OS_IOS) find_host_package(${target} REQUIRED) else() find_package(${target} REQUIRED) @@ -411,14 +411,14 @@ function(sfml_find_package) # Make sure to interpret the items in INCLUDE and LINK parameters. sfml_add_external() # does not interpret given items in order to also accept parameters that must not be interpreted set(LINK_LIST "") - if (THIS_LINK) + if(THIS_LINK) foreach(link_item IN LISTS THIS_LINK) list(APPEND LINK_LIST "${${link_item}}") endforeach() endif() set(INCLUDE_LIST "") - if (THIS_INCLUDE) + if(THIS_INCLUDE) foreach(include_dir IN LISTS THIS_INCLUDE) list(APPEND INCLUDE_LIST "${${include_dir}}") endforeach() @@ -438,7 +438,7 @@ function(sfml_export_targets) VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) - if (BUILD_SHARED_LIBS) + if(BUILD_SHARED_LIBS) set(config_name "Shared") else() set(config_name "Static") @@ -448,7 +448,7 @@ function(sfml_export_targets) export(EXPORT SFMLConfigExport FILE "${CMAKE_CURRENT_BINARY_DIR}/${targets_config_filename}") - if (SFML_BUILD_FRAMEWORKS) + if(SFML_BUILD_FRAMEWORKS) set(config_package_location "SFML.framework/Resources/CMake") else() set(config_package_location ${CMAKE_INSTALL_LIBDIR}/cmake/SFML) diff --git a/cmake/Modules/FindVORBIS.cmake b/cmake/Modules/FindVORBIS.cmake index e285411a4..c9b1a7991 100644 --- a/cmake/Modules/FindVORBIS.cmake +++ b/cmake/Modules/FindVORBIS.cmake @@ -12,7 +12,7 @@ find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) find_library(OGG_LIBRARY NAMES ogg) find_library(VORBIS_LIBRARY NAMES vorbis) -if (NOT SFML_OS_IOS) +if(NOT SFML_OS_IOS) find_library(VORBISFILE_LIBRARY NAMES vorbisfile) find_library(VORBISENC_LIBRARY NAMES vorbisenc) set(VORBIS_LIBRARIES ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) diff --git a/cmake/SFMLConfig.cmake.in b/cmake/SFMLConfig.cmake.in index 741161cc2..f3bf72ae9 100644 --- a/cmake/SFMLConfig.cmake.in +++ b/cmake/SFMLConfig.cmake.in @@ -68,7 +68,7 @@ # add_executable(myapp ...) # target_link_libraries(myapp PRIVATE SFML::Graphics SFML::Audio) -if (NOT SFML_FIND_COMPONENTS) +if(NOT SFML_FIND_COMPONENTS) message(FATAL_ERROR "find_package(SFML) called with no component") endif() @@ -106,9 +106,9 @@ list(APPEND SFML_FIND_COMPONENTS ${FIND_SFML_ADDITIONAL_COMPONENTS}) list(REMOVE_DUPLICATES SFML_FIND_COMPONENTS) # Choose which target definitions must be imported -if (SFML_STATIC_LIBRARIES) +if(SFML_STATIC_LIBRARIES) set(SFML_IS_FRAMEWORK_INSTALL "@SFML_BUILD_FRAMEWORKS@") - if (SFML_IS_FRAMEWORK_INSTALL) + if(SFML_IS_FRAMEWORK_INSTALL) message(WARNING "Static frameworks are not supported by SFML. Clear SFML_DIR cache entry, \ and either change SFML_STATIC_LIBRARIES or CMAKE_FIND_FRAMEWORK before calling find_package(SFML)") endif() @@ -119,19 +119,19 @@ endif() set(targets_config_file "${CMAKE_CURRENT_LIST_DIR}/SFML${config_name}Targets.cmake") # Generate imported targets for SFML and its dependencies -if (EXISTS "${targets_config_file}") +if(EXISTS "${targets_config_file}") # Set SFML_FOUND to TRUE by default, may be overwritten by one of the includes below set(SFML_FOUND TRUE) include("${targets_config_file}") include("${CMAKE_CURRENT_LIST_DIR}/SFMLConfigDependencies.cmake") - if (SFML_FOUND) + if(SFML_FOUND) set(SFML_VERSION_IS_RELEASE @VERSION_IS_RELEASE@) - foreach (component ${SFML_FIND_COMPONENTS}) + foreach(component ${SFML_FIND_COMPONENTS}) string(TOUPPER "${component}" UPPER_COMPONENT) set(SFML_${UPPER_COMPONENT}_FOUND FALSE) - if (TARGET SFML::${component}) + if(TARGET SFML::${component}) set(SFML_${UPPER_COMPONENT}_FOUND TRUE) elseif(SFML_FIND_REQUIRED_${component}) set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the config defined in ${SFML_DIR}.") @@ -144,7 +144,7 @@ else() set(SFML_FOUND FALSE) endif() -if (NOT SFML_FOUND) +if(NOT SFML_FOUND) if(SFML_FIND_REQUIRED) # fatal error message(FATAL_ERROR "${FIND_SFML_ERROR}") @@ -154,6 +154,6 @@ if (NOT SFML_FOUND) endif() endif() -if (SFML_FOUND AND NOT SFML_FIND_QUIETLY) +if(SFML_FOUND AND NOT SFML_FIND_QUIETLY) message(STATUS "Found SFML @PROJECT_VERSION@ in ${CMAKE_CURRENT_LIST_DIR}") endif() diff --git a/cmake/SFMLConfigDependencies.cmake.in b/cmake/SFMLConfigDependencies.cmake.in index f17617d94..8028c8779 100644 --- a/cmake/SFMLConfigDependencies.cmake.in +++ b/cmake/SFMLConfigDependencies.cmake.in @@ -8,7 +8,7 @@ if(SFML_STATIC_LIBRARIES) elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(FIND_SFML_OS_FREEBSD 1) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if (DEFINED IOS) + if(DEFINED IOS) set(FIND_SFML_OS_IOS 1) else() set(FIND_SFML_OS_MACOSX 1) @@ -21,7 +21,7 @@ if(SFML_STATIC_LIBRARIES) # macro that searches for a 3rd-party library function(sfml_bind_dependency) cmake_parse_arguments(THIS "" "TARGET;FRIENDLY_NAME" "SEARCH_NAMES" ${ARGN}) - if (THIS_UNPARSED_ARGUMENTS) + if(THIS_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown arguments when calling sfml_bind_dependency: ${THIS_UNPARSED_ARGUMENTS}") endif() @@ -49,7 +49,7 @@ if(SFML_STATIC_LIBRARIES) sfml_bind_dependency(TARGET UDev FRIENDLY_NAME "UDev" SEARCH_NAMES "udev" "libudev") endif() - if (FIND_SFML_OS_WINDOWS) + if(FIND_SFML_OS_WINDOWS) set_property(TARGET OpenGL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "OpenGL32") elseif(NOT FIND_SFML_OS_IOS) sfml_bind_dependency(TARGET OpenGL FRIENDLY_NAME "OpenGL" SEARCH_NAMES "OpenGL" "GL") @@ -66,7 +66,7 @@ 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") - if (NOT FIND_SFML_OS_IOS) + 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() @@ -75,7 +75,7 @@ if(SFML_STATIC_LIBRARIES) sfml_bind_dependency(TARGET FLAC FRIENDLY_NAME "FLAC" SEARCH_NAMES "FLAC") endif() - if (FIND_SFML_DEPENDENCIES_NOTFOUND) + if(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) endif() diff --git a/cmake/toolchains/iOS.toolchain.cmake b/cmake/toolchains/iOS.toolchain.cmake index f078f5c09..d6b6a3662 100644 --- a/cmake/toolchains/iOS.toolchain.cmake +++ b/cmake/toolchains/iOS.toolchain.cmake @@ -33,156 +33,156 @@ # Macros: # -# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE) +# set_xcode_property(TARGET XCODE_PROPERTY XCODE_VALUE) # A convenience macro for setting xcode specific properties on targets -# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1") +# example: set_xcode_property(myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1") # -# find_host_package (PROGRAM ARGS) +# find_host_package(PROGRAM ARGS) # A macro used to find executable programs on the host system, not within the iOS environment. # Thanks to the android-cmake project for providing the command # Standard settings -set (CMAKE_SYSTEM_NAME Darwin) -set (CMAKE_SYSTEM_VERSION 1) -set (UNIX True) -set (APPLE True) -set (IOS True) +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_VERSION 1) +set(UNIX True) +set(APPLE True) +set(IOS True) # Required as of cmake 2.8.10 -set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE) +set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE) # Determine the cmake host system version so we know where to find the iOS SDKs -find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) -if (CMAKE_UNAME) - exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) - string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") -endif (CMAKE_UNAME) +find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) +if(CMAKE_UNAME) + exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") +endif() 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 -set (CMAKE_CXX_COMPILER_WORKS TRUE) -set (CMAKE_C_COMPILER_WORKS TRUE) +set(CMAKE_CXX_COMPILER_WORKS TRUE) +set(CMAKE_C_COMPILER_WORKS TRUE) # All iOS/Darwin specific settings - some may be redundant -set (CMAKE_SHARED_LIBRARY_PREFIX "lib") -set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") -set (CMAKE_SHARED_MODULE_PREFIX "lib") -set (CMAKE_SHARED_MODULE_SUFFIX ".so") -set (CMAKE_MODULE_EXISTS 1) -set (CMAKE_DL_LIBS "") +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set(CMAKE_SHARED_MODULE_PREFIX "lib") +set(CMAKE_SHARED_MODULE_SUFFIX ".so") +set(CMAKE_MODULE_EXISTS 1) +set(CMAKE_DL_LIBS "") -set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") -set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") -set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") -set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") +set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") # Hidden visibilty is required for cxx on iOS -set (CMAKE_C_FLAGS_INIT "") -set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden") +set(CMAKE_C_FLAGS_INIT "") +set(CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden") -set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") -set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") +set(CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") +set(CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") -set (CMAKE_PLATFORM_HAS_INSTALLNAME 1) -set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names") -set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names") -set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") -set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") -set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") +set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") # hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree # (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache # and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun) # hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex -if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) - find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool) -endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) +if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool) +endif() # Setup iOS platform unless specified manually with IOS_PLATFORM -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: OS or SIMULATOR") +if(NOT DEFINED IOS_PLATFORM) + set(IOS_PLATFORM "OS") +endif() +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) - set (IOS_PLATFORM_LOCATION "iPhoneOS.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) - set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform") + # This causes the installers to properly locate the output libraries + set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") +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 () - message (FATAL_ERROR "Unsupported IOS_PLATFORM value '${IOS_PLATFORM}' selected. Please choose OS or SIMULATOR") -endif () + # This causes the installers to properly locate the output libraries + set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") +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") +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") +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() + 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() + message(STATUS "Toolchain using default iOS SDK: ${IOS_SDK_ROOT}") +endif() +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 ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") +set(CMAKE_OSX_SYSROOT ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") # set the architecture for iOS -if (${IOS_PLATFORM} STREQUAL OS) - set (OSX_UNIVERSAL true) - set (IOS_ARCH arm64) -elseif (${IOS_PLATFORM} STREQUAL SIMULATOR) - set (IOS_ARCH x86_64) -endif (${IOS_PLATFORM} STREQUAL OS) +if(${IOS_PLATFORM} STREQUAL OS) + set(OSX_UNIVERSAL true) + set(IOS_ARCH arm64) +elseif(${IOS_PLATFORM} STREQUAL SIMULATOR) + set(IOS_ARCH x86_64) +endif() -set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS" FORCE) +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 ${IOS_DEVELOPER_ROOT} ${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(CMAKE_FIND_FRAMEWORK FIRST) # set up the default search directories for frameworks -set (CMAKE_SYSTEM_FRAMEWORK_PATH +set(CMAKE_SYSTEM_FRAMEWORK_PATH ${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 -set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # This macro lets you find executable programs on the host system -macro (find_host_package) - set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) - set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) - set (IOS FALSE) +macro(find_host_package) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set(IOS FALSE) - find_package(${ARGN}) + find_package(${ARGN}) - set (IOS TRUE) - set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) - set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -endmacro (find_host_package) + set(IOS TRUE) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endmacro(find_host_package) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e5374384b..67b4a7f32 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,5 @@ # CLI based examples -if (NOT SFML_OS_IOS) +if(NOT SFML_OS_IOS) if(SFML_BUILD_NETWORK) add_subdirectory(ftp) add_subdirectory(sockets) @@ -21,7 +21,7 @@ endif() if(SFML_BUILD_GRAPHICS) add_subdirectory(opengl) - if (NOT SFML_OS_IOS) + if(NOT SFML_OS_IOS) add_subdirectory(joystick) add_subdirectory(shader) add_subdirectory(island) diff --git a/examples/cocoa/CMakeLists.txt b/examples/cocoa/CMakeLists.txt index 646e93ed8..27221eee6 100644 --- a/examples/cocoa/CMakeLists.txt +++ b/examples/cocoa/CMakeLists.txt @@ -3,15 +3,15 @@ enable_language(OBJC OBJCXX) # Usage: compile_xib(INPUT path/to/file.xib OUTPUT path/to/file.nib) function(compile_xib) cmake_parse_arguments(THIS "" "INPUT;OUTPUT" "" ${ARGN}) - if (NOT THIS_INPUT) + if(NOT THIS_INPUT) message(FATAL_ERROR "Missing required argument INPUT in call to compile_xib()") endif() - if (NOT THIS_OUTPUT) + if(NOT THIS_OUTPUT) message(FATAL_ERROR "Missing required argument OUTPUT in call to compile_xib()") endif() - if (NOT DEFINED IBTOOL) + if(NOT DEFINED IBTOOL) find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") endif() if(NOT IBTOOL) diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt index 7c54293b3..4a323fc10 100644 --- a/examples/opengl/CMakeLists.txt +++ b/examples/opengl/CMakeLists.txt @@ -1,7 +1,7 @@ # all source files set(SRC OpenGL.cpp) -if (SFML_OS_IOS) +if(SFML_OS_IOS) set(RESOURCES resources/background.jpg resources/tuffy.ttf) diff --git a/examples/tennis/CMakeLists.txt b/examples/tennis/CMakeLists.txt index ebd8bb226..8095fd9c1 100644 --- a/examples/tennis/CMakeLists.txt +++ b/examples/tennis/CMakeLists.txt @@ -1,6 +1,6 @@ # all source files set(SRC Tennis.cpp) -if (SFML_OS_IOS) +if(SFML_OS_IOS) set(RESOURCES resources/ball.wav resources/tuffy.ttf) diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 452cd216b..1e76f2b4d 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -3,7 +3,7 @@ include(${PROJECT_SOURCE_DIR}/cmake/Macros.cmake) # let CMake know about our additional libraries paths -if (SFML_OS_WINDOWS) +if(SFML_OS_WINDOWS) list(APPEND CMAKE_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/extlibs/headers") if(SFML_COMPILER_GCC OR (SFML_COMPILER_CLANG AND MINGW)) if(ARCH_32BITS) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index c9595b3e3..4c1ce93a7 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -280,7 +280,7 @@ target_include_directories(sfml-window SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/ext # CMake 3.11 and later prefer to choose GLVND, but we choose legacy OpenGL for backward compability # (unless the OpenGL_GL_PREFERENCE was explicitly set) # See CMP0072 for more details (cmake --help-policy CMP0072) -if (NOT OpenGL_GL_PREFERENCE) +if(NOT OpenGL_GL_PREFERENCE) set(OpenGL_GL_PREFERENCE "LEGACY") endif()