diff options
-rw-r--r-- | Help/manual/cmake-toolchains.7.rst | 60 | ||||
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 1 | ||||
-rw-r--r-- | Help/variable/CMAKE_MACOSX_BUNDLE.rst | 3 | ||||
-rw-r--r-- | Help/variable/IOS.rst | 4 | ||||
-rw-r--r-- | Modules/FindPython/Support.cmake | 3 | ||||
-rw-r--r-- | Modules/Platform/iOS-Initialize.cmake | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 4 | ||||
-rw-r--r-- | Tests/FindPython/NumPy/arraytest.c | 2 | ||||
-rw-r--r-- | Tests/FortranOnly/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/FortranOnly/testRC.rc | 0 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake | 4 |
11 files changed, 86 insertions, 5 deletions
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index d214e4a..ba44b7f 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -556,6 +556,54 @@ command is sufficient: cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS +Variable :variable:`CMAKE_OSX_ARCHITECTURES` can be used to set architectures +for both device and simulator. Variable :variable:`CMAKE_OSX_DEPLOYMENT_TARGET` +can be used to set an iOS/tvOS/watchOS deployment target. + +Next configuration will install fat 5 architectures iOS library +and add the ``-miphoneos-version-min=9.3``/``-mios-simulator-version-min=9.3`` +flags to the compiler: + +.. code-block:: console + + $ cmake -S. -B_builds -GXcode \ + -DCMAKE_SYSTEM_NAME=iOS \ + "-DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64;i386;x86_64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=9.3 \ + -DCMAKE_INSTALL_PREFIX=`pwd`/_install \ + -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO \ + -DCMAKE_IOS_INSTALL_COMBINED=YES + +Example: + +.. code-block:: cmake + + # CMakeLists.txt + cmake_minimum_required(VERSION 3.14) + project(foo) + add_library(foo foo.cpp) + install(TARGETS foo DESTINATION lib) + +Install: + +.. code-block:: console + + $ cmake --build _builds --config Release --target install + +Check library: + +.. code-block:: console + + $ lipo -info _install/lib/libfoo.a + Architectures in the fat file: _install/lib/libfoo.a are: i386 armv7 armv7s x86_64 arm64 + +.. code-block:: console + + $ otool -l _install/lib/libfoo.a | grep -A2 LC_VERSION_MIN_IPHONEOS + cmd LC_VERSION_MIN_IPHONEOS + cmdsize 16 + version 9.3 + Code Signing ^^^^^^^^^^^^ @@ -592,4 +640,14 @@ Please note that checks made during configuration were performed against the configure-time SDK and might not hold true for other SDKs. Commands like :command:`find_package`, :command:`find_library`, etc. store and use details only for the configured SDK/platform, so they can be problematic -if wanting to switch between device and simulator builds. +if wanting to switch between device and simulator builds. You can follow +the next rules to make device + simulator configuration work: + +- Use explicit ``-l`` linker flag, + e.g. ``target_link_libraries(foo PUBLIC "-lz")`` + +- Use explicit ``-framework`` linker flag, + e.g. ``target_link_libraries(foo PUBLIC "-framework CoreFoundation")`` + +- Use :command:`find_package` only for libraries installed with + :variable:`CMAKE_IOS_INSTALL_COMBINED` feature diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 83c88a5..7609597 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -259,6 +259,7 @@ Variables that Describe the System /variable/CMAKE_SYSTEM_VERSION /variable/CYGWIN /variable/GHS-MULTI + /variable/IOS /variable/MINGW /variable/MSVC /variable/MSVC10 diff --git a/Help/variable/CMAKE_MACOSX_BUNDLE.rst b/Help/variable/CMAKE_MACOSX_BUNDLE.rst index 0badaf0..43ddff5 100644 --- a/Help/variable/CMAKE_MACOSX_BUNDLE.rst +++ b/Help/variable/CMAKE_MACOSX_BUNDLE.rst @@ -5,3 +5,6 @@ Default value for :prop_tgt:`MACOSX_BUNDLE` of targets. This variable is used to initialize the :prop_tgt:`MACOSX_BUNDLE` property on all the targets. See that target property for additional information. + +This variable is set to ``ON`` by default if :variable:`CMAKE_SYSTEM_NAME` +equals to :ref:`iOS, tvOS or watchOS <Cross Compiling for iOS, tvOS, or watchOS>`. diff --git a/Help/variable/IOS.rst b/Help/variable/IOS.rst new file mode 100644 index 0000000..e5cc3f6 --- /dev/null +++ b/Help/variable/IOS.rst @@ -0,0 +1,4 @@ +IOS +--- + +Set to ``1`` when the target system (:variable:`CMAKE_SYSTEM_NAME`) is ``iOS``. diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 0138b04..ef8272c 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -1140,9 +1140,8 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT _${_PYTHON_PREFIX}_RESULT) find_path(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR - NAMES arrayobject.h numpyconfig.h + NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h" HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}" - PATH_SUFFIXES numpy NO_DEFAULT_PATH) endif() if(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) diff --git a/Modules/Platform/iOS-Initialize.cmake b/Modules/Platform/iOS-Initialize.cmake index 41399a3..301ca4c 100644 --- a/Modules/Platform/iOS-Initialize.cmake +++ b/Modules/Platform/iOS-Initialize.cmake @@ -4,4 +4,6 @@ if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhone(OS|Simulator)") message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an iOS SDK") endif() +set(IOS 1) + set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 1922906..639dc22 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -834,6 +834,10 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( if (linkLang && *linkLang) { languages.insert(linkLang); } + + // Intel Fortran .vfproj files do support the resource compiler. + languages.erase("RC"); + return languages.size() == 1 && *languages.begin() == "Fortran"; } diff --git a/Tests/FindPython/NumPy/arraytest.c b/Tests/FindPython/NumPy/arraytest.c index 135877d..db259e5 100644 --- a/Tests/FindPython/NumPy/arraytest.c +++ b/Tests/FindPython/NumPy/arraytest.c @@ -1,7 +1,7 @@ #include "Python.h" #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION -#include "arrayobject.h" +#include "numpy/arrayobject.h" #include <math.h> diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index 77f6041..45372dd 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -12,6 +12,12 @@ add_executable(FortranOnly1 testf.f) set_property(TARGET FortranOnly1 PROPERTY OUTPUT_NAME FortranOnly) target_link_libraries(FortranOnly1 FortranOnlylib) +# Test that Fortran+RC work together. +# FIXME: Add .rc in more cases. +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(test_rc testRC.rc) +endif() + # create a custom command that runs FortranOnly1 and puts # the output into the file testfhello.txt add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt @@ -20,7 +26,7 @@ add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt # create a second executable FortranOnly2 that has # testfhello.txt has an source file so that it will # run the above custom command. -add_executable(FortranOnly2 testfhello.txt testf.f) +add_executable(FortranOnly2 testfhello.txt testf.f ${test_rc}) target_link_libraries(FortranOnly2 FortranOnlylib) # create a custom target to check the content of testfhello.txt # by running the cmake script checktestf2.cmake diff --git a/Tests/FortranOnly/testRC.rc b/Tests/FortranOnly/testRC.rc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/FortranOnly/testRC.rc diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake index 7f31d94..f6c00b1 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake @@ -6,6 +6,10 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 9) set(CMAKE_OSX_DEPLOYMENT_TARGET 10) endif() +if(NOT IOS) + message(FATAL_ERROR "IOS variable is not set") +endif() + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") |