diff options
35 files changed, 330 insertions, 218 deletions
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 8554e87..d214e4a 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -522,3 +522,74 @@ See also target properties: * :prop_tgt:`ANDROID_SECURE_PROPS_PATH` * :prop_tgt:`ANDROID_SKIP_ANT_STEP` * :prop_tgt:`ANDROID_STL_TYPE` + +.. _`Cross Compiling for iOS, tvOS, or watchOS`: + +Cross Compiling for iOS, tvOS, or watchOS +----------------------------------------- + +For cross-compiling to iOS, tvOS, or watchOS, the :generator:`Xcode` +generator is recommended. The :generator:`Unix Makefiles` or +:generator:`Ninja` generators can also be used, but they require the +project to handle more areas like target CPU selection and code signing. + +Any of the three systems can be targetted by setting the +:variable:`CMAKE_SYSTEM_NAME` variable to a value from the table below. +By default, the latest Device SDK is chosen. As for all Apple platforms, +a different SDK (e.g. a simulator) can be selected by setting the +:variable:`CMAKE_OSX_SYSROOT` variable, although this should rarely be +necessary (see :ref:`Switching Between Device and Simulator` below). +A list of available SDKs can be obtained by running ``xcodebuild -showsdks``. + +======= ================= ==================== ================ +OS CMAKE_SYSTEM_NAME Device SDK (default) Simulator SDK +======= ================= ==================== ================ +iOS iOS iphoneos iphonesimulator +tvOS tvOS appletvos appletvsimulator +watchOS watchOS watchos watchsimulator +======= ================= ==================== ================ + +For example, to create a CMake configuration for iOS, the following +command is sufficient: + +.. code-block:: console + + cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS + +Code Signing +^^^^^^^^^^^^ + +Some build artifacts for the embedded Apple platforms require mandatory +code signing. If the :generator:`Xcode` generator is being used and +code signing is required or desired, the developmemt team ID can be +specified via the ``CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM`` CMake variable. +This team ID will then be included in the generated Xcode project. +By default, CMake avoids the need for code signing during the internal +configuration phase (i.e compiler ID and feature detection). + +.. _`Switching Between Device and Simulator`: + +Switching Between Device and Simulator +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When configuring for any of the embedded platforms, one can target either +real devices or the simulator. Both have their own separate SDK, but CMake +only supports specifying a single SDK for the configuration phase. This +means the developer must select one or the other at configuration time. +When using the :generator:`Xcode` generator, this is less of a limitation +because Xcode still allows you to build for either a device or a simulator, +even though configuration was only performed for one of the two. From +within the Xcode IDE, builds are performed for the selected "destination" +platform. When building from the command line, the desired sdk can be +specified directly by passing a ``-sdk`` option to the underlying build +tool (``xcodebuild``). For example: + +.. code-block:: console + + $ cmake --build ... -- -sdk iphonesimulator + +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. diff --git a/Help/release/dev/iphone-friendly-cmake.rst b/Help/release/dev/iphone-friendly-cmake.rst new file mode 100644 index 0000000..f32f0d1 --- /dev/null +++ b/Help/release/dev/iphone-friendly-cmake.rst @@ -0,0 +1,5 @@ +iphone-friendly-cmake +--------------------- + +* CMake now supports :ref:`Cross Compiling for iOS, tvOS, or watchOS` + using simple toolchain files. diff --git a/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst b/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst index 50121e2..b4a74eb 100644 --- a/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst +++ b/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst @@ -1,5 +1,9 @@ CMAKE_Swift_LANGUAGE_VERSION ---------------------------- -Set to the Swift language version number. If not set, the legacy "2.3" -version is assumed. +Set to the Swift language version number. If not set, the oldest legacy +version known to be available in the host Xcode version is assumed: + +* Swift ``4.0`` for Xcode 10.2 and above. +* Swift ``3.0`` for Xcode 8.3 and above. +* Swift ``2.3`` for Xcode 8.2 and below. diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 4f355f3..d7f6f97 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -106,7 +106,7 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) # ... # /path/to/cc ...CompilerIdC/... # to extract the compiler front-end for the language. - set(CMAKE_C_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdC/(\\./)?(CompilerIdC.xctest/)?CompilerIdC[ \t\n\\\"]") + set(CMAKE_C_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdC/(\\./)?(CompilerIdC.(framework|xctest)/)?CompilerIdC[ \t\n\\\"]") set(CMAKE_C_COMPILER_ID_TOOL_MATCH_INDEX 2) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 96b4209..bd878b2 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -101,7 +101,7 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) # ... # /path/to/cc ...CompilerIdCXX/... # to extract the compiler front-end for the language. - set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.xctest/)?CompilerIdCXX[ \t\n\\\"]") + set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.(framework|xctest)/)?CompilerIdCXX[ \t\n\\\"]") set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 2a0dbd3..2f84c8e 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -332,6 +332,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if("${lang}" STREQUAL "Swift") if(CMAKE_Swift_LANGUAGE_VERSION) set(id_lang_version "SWIFT_VERSION = ${CMAKE_Swift_LANGUAGE_VERSION};") + elseif(XCODE_VERSION VERSION_GREATER_EQUAL 10.2) + set(id_lang_version "SWIFT_VERSION = 4.0;") elseif(XCODE_VERSION VERSION_GREATER_EQUAL 8.3) set(id_lang_version "SWIFT_VERSION = 3.0;") else() @@ -352,22 +354,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]" OR CMAKE_OSX_SYSROOT MATCHES "(^|/)[Aa][Pp][Pp][Ll][Ee][Tt][Vv]") set(id_product_type "com.apple.product-type.bundle.unit-test") + elseif(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ww][Aa][Tt][Cc][Hh]") + set(id_product_type "com.apple.product-type.framework") endif() else() set(id_sdkroot "") endif() - if(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM) - set(id_development_team - "DEVELOPMENT_TEAM = \"${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}\";") - else() - set(id_development_team "") - endif() - if(DEFINED CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY) - set(id_code_sign_identity - "CODE_SIGN_IDENTITY = \"${CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}\";") - else() - set(id_code_sign_identity "") - endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in ${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY) unset(_ENV_MACOSX_DEPLOYMENT_TARGET) @@ -491,6 +483,9 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT} # com.apple.package-type.bundle.unit-test ${_glob_id_dir}/*.xctest/* + + # com.apple.product-type.framework + ${_glob_id_dir}/*.framework/* ) list(REMOVE_ITEM files "${src}") set(COMPILER_${lang}_PRODUCED_FILES "") diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index f74a1c6..7bf6fde 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -11,6 +11,12 @@ endif() include(CMakeTestCompilerCommon) +# work around enforced code signing and / or missing exectuable target type +set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) + set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) +endif() + # Remove any cached result from an older CMake version. # We now store this in CMakeCCompiler.cmake. unset(CMAKE_C_COMPILER_WORKS CACHE) @@ -86,4 +92,6 @@ else() endif() endif() +set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) +unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE) unset(__CMAKE_C_COMPILER_OUTPUT) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index fe6bd25..7e595b7 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -11,6 +11,12 @@ endif() include(CMakeTestCompilerCommon) +# work around enforced code signing and / or missing exectuable target type +set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) + set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) +endif() + # Remove any cached result from an older CMake version. # We now store this in CMakeCXXCompiler.cmake. unset(CMAKE_CXX_COMPILER_WORKS CACHE) @@ -79,4 +85,6 @@ else() endif() endif() +set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) +unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE) unset(__CMAKE_CXX_COMPILER_OUTPUT) diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 4686b64..813c074 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -72,8 +72,7 @@ 1DEB928608733DD80010E9CD = { isa = XCBuildConfiguration; buildSettings = { - @id_development_team@ - @id_code_sign_identity@ + CODE_SIGN_IDENTITY = ""; PRODUCT_NAME = CompilerId@id_lang@; }; name = Debug; diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index 3db77aa..2d797f6 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -34,7 +34,7 @@ string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1" # CMAKE_OSX_DEPLOYMENT_TARGET # Set cache variable - end user may change this during ccmake or cmake-gui configure. -if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND _CURRENT_OSX_VERSION VERSION_GREATER 10.3) set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.") endif() @@ -49,6 +49,12 @@ elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND (NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}")) # Use the value of SDKROOT from the environment. set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}") +elseif(CMAKE_SYSTEM_NAME STREQUAL iOS) + set(_CMAKE_OSX_SYSROOT_DEFAULT "iphoneos") +elseif(CMAKE_SYSTEM_NAME STREQUAL tvOS) + set(_CMAKE_OSX_SYSROOT_DEFAULT "appletvos") +elseif(CMAKE_SYSTEM_NAME STREQUAL watchOS) + set(_CMAKE_OSX_SYSROOT_DEFAULT "watchos") elseif("${CMAKE_GENERATOR}" MATCHES Xcode OR CMAKE_OSX_DEPLOYMENT_TARGET OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]" diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 727baa6..a73ffba 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -1,5 +1,13 @@ set(APPLE 1) +if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") + set(CMAKE_MACOSX_BUNDLE ON) + + set(CMAKE_FIND_ROOT_PATH "${_CMAKE_OSX_SYSROOT_PATH}") + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + # Darwin versions: # 6.x == Mac OSX 10.2 (Jaguar) # 7.x == Mac OSX 10.3 (Panther) diff --git a/Modules/Platform/iOS-Determine-CXX.cmake b/Modules/Platform/iOS-Determine-CXX.cmake new file mode 100644 index 0000000..ac80fa6 --- /dev/null +++ b/Modules/Platform/iOS-Determine-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Darwin-Determine-CXX) diff --git a/Modules/Platform/iOS-Initialize.cmake b/Modules/Platform/iOS-Initialize.cmake new file mode 100644 index 0000000..41399a3 --- /dev/null +++ b/Modules/Platform/iOS-Initialize.cmake @@ -0,0 +1,7 @@ +include(Platform/Darwin-Initialize) + +if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhone(OS|Simulator)") + message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an iOS SDK") +endif() + +set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY) diff --git a/Modules/Platform/iOS.cmake b/Modules/Platform/iOS.cmake new file mode 100644 index 0000000..850ddc2 --- /dev/null +++ b/Modules/Platform/iOS.cmake @@ -0,0 +1 @@ +include(Platform/Darwin) diff --git a/Modules/Platform/tvOS-Determine-CXX.cmake b/Modules/Platform/tvOS-Determine-CXX.cmake new file mode 100644 index 0000000..ac80fa6 --- /dev/null +++ b/Modules/Platform/tvOS-Determine-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Darwin-Determine-CXX) diff --git a/Modules/Platform/tvOS-Initialize.cmake b/Modules/Platform/tvOS-Initialize.cmake new file mode 100644 index 0000000..6834c80 --- /dev/null +++ b/Modules/Platform/tvOS-Initialize.cmake @@ -0,0 +1,7 @@ +include(Platform/Darwin-Initialize) + +if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTV(OS|Simulator)") + message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an tvOS SDK") +endif() + +set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY) diff --git a/Modules/Platform/tvOS.cmake b/Modules/Platform/tvOS.cmake new file mode 100644 index 0000000..850ddc2 --- /dev/null +++ b/Modules/Platform/tvOS.cmake @@ -0,0 +1 @@ +include(Platform/Darwin) diff --git a/Modules/Platform/watchOS-Determine-CXX.cmake b/Modules/Platform/watchOS-Determine-CXX.cmake new file mode 100644 index 0000000..ac80fa6 --- /dev/null +++ b/Modules/Platform/watchOS-Determine-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Darwin-Determine-CXX) diff --git a/Modules/Platform/watchOS-Initialize.cmake b/Modules/Platform/watchOS-Initialize.cmake new file mode 100644 index 0000000..2f396d3 --- /dev/null +++ b/Modules/Platform/watchOS-Initialize.cmake @@ -0,0 +1,7 @@ +include(Platform/Darwin-Initialize) + +if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/Watch(OS|Simulator)") + message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an watchOS SDK") +endif() + +set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY) diff --git a/Modules/Platform/watchOS.cmake b/Modules/Platform/watchOS.cmake new file mode 100644 index 0000000..850ddc2 --- /dev/null +++ b/Modules/Platform/watchOS.cmake @@ -0,0 +1 @@ +include(Platform/Darwin) diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 2fa593c..0773edc 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -223,7 +223,7 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles( for (cmSourceFile* s : sources) { // check whether it is a source or a include file // then put it accordingly into one of the two containers - switch (cmSystemTools::GetFileFormat(s->GetExtension().c_str())) { + switch (cmSystemTools::GetFileFormat(s->GetExtension())) { case cmSystemTools::C_FILE_FORMAT: case cmSystemTools::CXX_FILE_FORMAT: case cmSystemTools::CUDA_FILE_FORMAT: diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 77be592..1922906 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -813,7 +813,6 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( cmGeneratorTarget const* gt) { // check to see if this is a fortran build - std::set<std::string> languages; { // Issue diagnostic if the source files depend on the config. std::vector<cmSourceFile*> sources; @@ -821,27 +820,21 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( return false; } } + // If there's only one source language, Fortran has to be used // in order for the sources to compile. - // Note: Via linker propagation, LINKER_LANGUAGE could become CXX in - // this situation and mismatch from the actual language of the linker. + std::set<std::string> languages; gt->GetLanguages(languages, ""); - if (languages.size() == 1) { - if (*languages.begin() == "Fortran") { - return true; - } - } - - // In the case of mixed object files or sources mixed with objects, - // decide the language based on the value of LINKER_LANGUAGE. - // This will not make it possible to mix source files of different - // languages, but object libraries will be linked together in the - // same fashion as other generators do. - if (gt->GetLinkerLanguage("") == "Fortran") { - return true; - } - - return false; + // Consider an explicit linker language property, but *not* the + // computed linker language that may depend on linked targets. + // This allows the project to control the language choice in + // a target with none of its own sources, e.g. when also using + // object libraries. + const char* linkLang = gt->GetProperty("LINKER_LANGUAGE"); + if (linkLang && *linkLang) { + languages.insert(linkLang); + } + return languages.size() == 1 && *languages.begin() == "Fortran"; } bool cmGlobalVisualStudioGenerator::TargetCompare::operator()( diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b428ae1..16f8a0e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3142,6 +3142,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( if (const char* vers = this->CurrentMakefile->GetDefinition( "CMAKE_Swift_LANGUAGE_VERSION")) { swiftVersion = vers; + } else if (this->XcodeVersion >= 102) { + swiftVersion = "4.0"; } else if (this->XcodeVersion >= 83) { swiftVersion = "3.0"; } else { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 41d29e8..a96d574 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -616,40 +616,6 @@ bool cmQtAutoGenInitializer::InitUic() } } } - // .ui files skip and options - { - std::string const uiExt = "ui"; - std::string pathError; - for (cmSourceFile* sf : makefile->GetSourceFiles()) { - // sf->GetExtension() is only valid after sf->GetFullPath() ... - // Since we're iterating over source files that might be not in the - // target we need to check for path errors (not existing files). - std::string const& fPath = sf->GetFullPath(&pathError); - if (!pathError.empty()) { - pathError.clear(); - continue; - } - if (sf->GetExtension() == uiExt) { - std::string const absFile = cmSystemTools::GetRealPath(fPath); - // Check if the .ui file should be skipped - if (sf->GetPropertyAsBool("SKIP_AUTOUIC") || - sf->GetPropertyAsBool("SKIP_AUTOGEN")) { - this->Uic.Skip.insert(absFile); - } - // Check if the .ui file has uic options - std::string const uicOpts = sf->GetSafeProperty("AUTOUIC_OPTIONS"); - if (!uicOpts.empty()) { - // Check if file isn't skipped - if (this->Uic.Skip.count(absFile) == 0) { - this->Uic.FileFiles.push_back(absFile); - std::vector<std::string> optsVec; - cmSystemTools::ExpandListArgument(uicOpts, optsVec); - this->Uic.FileOptions.push_back(std::move(optsVec)); - } - } - } - } - } // Uic executable return GetUicExecutable(); @@ -664,27 +630,41 @@ bool cmQtAutoGenInitializer::InitScanFiles() { cmMakefile* makefile = this->Target->Target->GetMakefile(); + // String constants + std::string const SKIP_AUTOGEN_str = "SKIP_AUTOGEN"; + std::string const SKIP_AUTOMOC_str = "SKIP_AUTOMOC"; + std::string const SKIP_AUTOUIC_str = "SKIP_AUTOUIC"; + // Scan through target files { - std::string const qrcExt = "qrc"; + // String constants + std::string const qrc_str = "qrc"; + std::string const SKIP_AUTORCC_str = "SKIP_AUTORCC"; + std::string const AUTORCC_OPTIONS_str = "AUTORCC_OPTIONS"; + + // Scan through target files std::vector<cmSourceFile*> srcFiles; this->Target->GetConfigCommonSourceFiles(srcFiles); for (cmSourceFile* sf : srcFiles) { - if (sf->GetPropertyAsBool("SKIP_AUTOGEN")) { + if (sf->GetPropertyAsBool(SKIP_AUTOGEN_str)) { continue; } + // sf->GetExtension() is only valid after sf->GetFullPath() ... std::string const& fPath = sf->GetFullPath(); std::string const& ext = sf->GetExtension(); + // Register generated files that will be scanned by moc or uic if (this->Moc.Enabled || this->Uic.Enabled) { cmSystemTools::FileFormat const fileType = - cmSystemTools::GetFileFormat(ext.c_str()); + cmSystemTools::GetFileFormat(ext); if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || (fileType == cmSystemTools::HEADER_FILE_FORMAT)) { std::string const absPath = cmSystemTools::GetRealPath(fPath); - if ((this->Moc.Enabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) || - (this->Uic.Enabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) { + if ((this->Moc.Enabled && + !sf->GetPropertyAsBool(SKIP_AUTOMOC_str)) || + (this->Uic.Enabled && + !sf->GetPropertyAsBool(SKIP_AUTOUIC_str))) { // Register source const bool generated = sf->GetIsGenerated(); if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { @@ -704,10 +684,9 @@ bool cmQtAutoGenInitializer::InitScanFiles() } } // Register rcc enabled files - if (this->Rcc.Enabled && (ext == qrcExt) && - !sf->GetPropertyAsBool("SKIP_AUTORCC")) { - // Register qrc file - { + if (this->Rcc.Enabled) { + if ((ext == qrc_str) && !sf->GetPropertyAsBool(SKIP_AUTORCC_str)) { + // Register qrc file Qrc qrc; qrc.QrcFile = cmSystemTools::GetRealPath(fPath); qrc.QrcName = @@ -715,7 +694,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() qrc.Generated = sf->GetIsGenerated(); // RCC options { - std::string const opts = sf->GetSafeProperty("AUTORCC_OPTIONS"); + std::string const opts = sf->GetSafeProperty(AUTORCC_OPTIONS_str); if (!opts.empty()) { cmSystemTools::ExpandListArgument(opts, qrc.Options); } @@ -731,43 +710,65 @@ bool cmQtAutoGenInitializer::InitScanFiles() // mocs_compilation.cpp source acknowledged by this target. this->Target->ClearSourcesCache(); + // Scan through all source files in the makefile to extract moc and uic + // parameters. Historically we support non target source file parameters. + // The reason is that their file names might be discovered from source files + // at generation time. if (this->Moc.Enabled || this->Uic.Enabled) { - // Read skip files from makefile sources - { + // String constants + std::string const ui_str = "ui"; + std::string const AUTOUIC_OPTIONS_str = "AUTOUIC_OPTIONS"; + + for (cmSourceFile* sf : makefile->GetSourceFiles()) { + // sf->GetExtension() is only valid after sf->GetFullPath() ... + // Since we're iterating over source files that might be not in the + // target we need to check for path errors (not existing files). std::string pathError; - for (cmSourceFile* sf : makefile->GetSourceFiles()) { - // sf->GetExtension() is only valid after sf->GetFullPath() ... - // Since we're iterating over source files that might be not in the - // target we need to check for path errors (not existing files). - std::string const& fPath = sf->GetFullPath(&pathError); - if (!pathError.empty()) { - pathError.clear(); - continue; + std::string const& fullPath = sf->GetFullPath(&pathError); + if (!pathError.empty() || fullPath.empty()) { + continue; + } + + // Check file type + auto const fileType = cmSystemTools::GetFileFormat(sf->GetExtension()); + bool const isSource = (fileType == cmSystemTools::CXX_FILE_FORMAT) || + (fileType == cmSystemTools::HEADER_FILE_FORMAT); + bool const isUi = (this->Moc.Enabled && sf->GetExtension() == ui_str); + + // Process only certain file types + if (isSource || isUi) { + std::string const absFile = cmSystemTools::GetRealPath(fullPath); + // Acquire file properties + bool const skipAUTOGEN = sf->GetPropertyAsBool(SKIP_AUTOGEN_str); + bool const skipMoc = (this->Moc.Enabled && isSource) && + (skipAUTOGEN || sf->GetPropertyAsBool(SKIP_AUTOMOC_str)); + bool const skipUic = this->Uic.Enabled && + (skipAUTOGEN || sf->GetPropertyAsBool(SKIP_AUTOUIC_str)); + + // Register moc and uic skipped file + if (skipMoc) { + this->Moc.Skip.insert(absFile); } - cmSystemTools::FileFormat const fileType = - cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); - if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && - !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { - continue; + if (skipUic) { + this->Uic.Skip.insert(absFile); } - const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN"); - const bool mocSkip = this->Moc.Enabled && - (skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC")); - const bool uicSkip = this->Uic.Enabled && - (skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC")); - if (mocSkip || uicSkip) { - std::string const absFile = cmSystemTools::GetRealPath(fPath); - if (mocSkip) { - this->Moc.Skip.insert(absFile); - } - if (uicSkip) { - this->Uic.Skip.insert(absFile); + + // Check if the .ui file has uic options + if (isUi && !skipUic) { + std::string const uicOpts = sf->GetSafeProperty(AUTOUIC_OPTIONS_str); + if (!uicOpts.empty()) { + this->Uic.FileFiles.push_back(absFile); + std::vector<std::string> optsVec; + cmSystemTools::ExpandListArgument(uicOpts, optsVec); + this->Uic.FileOptions.push_back(std::move(optsVec)); } } } } + } - // Process GENERATED sources and headers + // Process GENERATED sources and headers + if (this->Moc.Enabled || this->Uic.Enabled) { if (!this->AutogenTarget.SourcesGenerated.empty() || !this->AutogenTarget.HeadersGenerated.empty()) { // Check status of policy CMP0071 @@ -843,13 +844,14 @@ bool cmQtAutoGenInitializer::InitScanFiles() } } } - // Sort headers and sources - if (this->Moc.Enabled || this->Uic.Enabled) { - std::sort(this->AutogenTarget.Headers.begin(), - this->AutogenTarget.Headers.end()); - std::sort(this->AutogenTarget.Sources.begin(), - this->AutogenTarget.Sources.end()); - } + } + + // Sort headers and sources + if (this->Moc.Enabled || this->Uic.Enabled) { + std::sort(this->AutogenTarget.Headers.begin(), + this->AutogenTarget.Headers.end()); + std::sort(this->AutogenTarget.Sources.begin(), + this->AutogenTarget.Sources.end()); } // Process qrc files diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5d8c079..1d20e2f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1330,13 +1330,11 @@ bool cmSystemTools::SimpleGlob(const std::string& glob, return res; } -cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) +cmSystemTools::FileFormat cmSystemTools::GetFileFormat(std::string const& ext) { - if (!cext || *cext == 0) { + if (ext.empty()) { return cmSystemTools::NO_FILE_FORMAT; } - // std::string ext = cmSystemTools::LowerCase(cext); - std::string ext = cext; if (ext == "c" || ext == ".c" || ext == "m" || ext == ".m") { return cmSystemTools::C_FILE_FORMAT; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index fcb2cce..0f92fe2 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -334,7 +334,7 @@ public: /** * Determine the file type based on the extension */ - static FileFormat GetFileFormat(const char* ext); + static FileFormat GetFileFormat(std::string const& ext); /** Windows if this is true, the CreateProcess in RunCommand will * not show new console windows when running programs. diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 52623d0..7023615 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -99,6 +99,11 @@ function(test_fortran_c_interface_module) target_link_libraries(myc myfort) set_property(TARGET myc PROPERTY COMPILE_DEFINITIONS ${MYC_DEFS}) + add_library(myfort_obj OBJECT mysub.f) + add_library(myc_use_obj myc.c $<TARGET_OBJECTS:myfort_obj>) + add_executable(mainc_use_obj mainc.c) + target_link_libraries(mainc_use_obj myc_use_obj) + add_library(mycxx mycxx.cxx) target_link_libraries(mycxx myc) diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake index 6281352..288735e 100644 --- a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake +++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake @@ -3,28 +3,21 @@ project(DeploymentTarget C) # using Xcode 7.1 SDK versions for deployment targets -if(SDK MATCHES iphone) - set(CMAKE_OSX_SYSROOT ${SDK}) - set(CMAKE_OSX_ARCHITECTURES "armv7;x86_64") +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "9.1") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -elseif(SDK MATCHES watch) - set(CMAKE_OSX_SYSROOT ${SDK}) - set(CMAKE_OSX_ARCHITECTURES "armv7k;i386") +elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") -elseif(SDK MATCHES appletv) - set(CMAKE_OSX_SYSROOT ${SDK}) +elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "9.0") - set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") else() - set(CMAKE_OSX_SYSROOT ${SDK}) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11") endif() diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index fb04005..4918f7c 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -1,9 +1,5 @@ include(RunCMake) -if(XCODE_VERSION VERSION_GREATER_EQUAL 9) - set(IOS_DEPLOYMENT_TARGET "-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=10") -endif() - run_cmake(ExplicitCMakeLists) run_cmake(XcodeFileType) @@ -25,14 +21,48 @@ run_cmake(PerConfigPerSourceOptions) run_cmake(PerConfigPerSourceDefinitions) run_cmake(PerConfigPerSourceIncludeDirs) +function(XcodeSchemaGeneration) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeSchemaGeneration) + run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build) +endfunction() + +if(NOT XCODE_VERSION VERSION_LESS 7) + XcodeSchemaGeneration() + run_cmake(XcodeSchemaProperty) +endif() + +function(XcodeDependOnZeroCheck) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeDependOnZeroCheck) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib) +endfunction() + +XcodeDependOnZeroCheck() + +# Isolate device tests from host architecture selection. +unset(ENV{CMAKE_OSX_ARCHITECTURES}) + # Use a single build tree for a few tests without cleaning. if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -47,7 +77,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_IOS=OFF" + "-DCMAKE_SYSTEM_NAME=Darwin" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -64,9 +94,8 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_IOS=ON" - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -84,7 +113,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesWatchOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_WATCHOS=ON" + "-DCMAKE_SYSTEM_NAME=watchOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -103,7 +132,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesTvOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_TVOS=ON" + "-DCMAKE_SYSTEM_NAME=tvOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -129,9 +158,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_IOS_INSTALL_COMBINED=YES" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -148,9 +177,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_IOS_INSTALL_COMBINED=YES" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -167,9 +196,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedSingleArch-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_IOS_INSTALL_COMBINED=YES" - "${IOS_DEPLOYMENT_TARGET}") + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -205,28 +234,11 @@ if(NOT XCODE_VERSION VERSION_LESS 5) unset(RunCMake_TEST_OPTIONS) endif() -function(XcodeSchemaGeneration) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON") - - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - - run_cmake(XcodeSchemaGeneration) - run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build) -endfunction() - -if(NOT XCODE_VERSION VERSION_LESS 7) - XcodeSchemaGeneration() - run_cmake(XcodeSchemaProperty) -endif() - if(XCODE_VERSION VERSION_GREATER_EQUAL 8) - function(deploymeny_target_test SDK) + function(deployment_target_test SystemName SDK) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DeploymentTarget-${SDK}-build) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DSDK=${SDK}") + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -235,21 +247,13 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) run_cmake_command(DeploymentTarget-${SDK} ${CMAKE_COMMAND} --build .) endfunction() - foreach(SDK macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator) - deploymeny_target_test(${SDK}) - endforeach() + deployment_target_test(Darwin macosx) + deployment_target_test(iOS iphoneos) + deployment_target_test(iOS iphonesimulator) + deployment_target_test(tvOS appletvos) + deployment_target_test(tvOS appletvsimulator) + deployment_target_test(watchOS watchos) + deployment_target_test(watchOS watchsimulator) endif() -function(XcodeDependOnZeroCheck) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build) - set(RunCMake_TEST_NO_CLEAN 1) - - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - - run_cmake(XcodeDependOnZeroCheck) - run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib) - run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib) -endfunction() - -XcodeDependOnZeroCheck() +# Please add macOS-only tests above before the device-specific tests. diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index 5d19ee8..ef772ea 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -3,27 +3,12 @@ cmake_minimum_required(VERSION 3.3) enable_language(C) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) - -if(TEST_IOS) - set(CMAKE_OSX_SYSROOT iphoneos) - set(CMAKE_OSX_ARCHITECTURES "armv7") +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -endif(TEST_IOS) - -if(TEST_WATCHOS) - set(CMAKE_OSX_SYSROOT watchos) - set(CMAKE_OSX_ARCHITECTURES "armv7k") - set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") - set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") - set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") endif() -if(TEST_TVOS) - set(CMAKE_OSX_SYSROOT appletvos) - set(CMAKE_OSX_ARCHITECTURES "arm64") +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") @@ -41,7 +26,7 @@ add_dependencies(AppBundleTest AppBundle) # with custom extension -if (NOT TEST_IOS AND NOT TEST_WATCHOS AND NOT TEST_TVOS) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_executable(AppBundleExt MACOSX_BUNDLE main.m) set_target_properties(AppBundleExt PROPERTIES BUNDLE_EXTENSION "foo") install(TARGETS AppBundleExt BUNDLE DESTINATION FooExtension) @@ -55,7 +40,7 @@ endif() # Shared Framework (not supported for iOS on Xcode < 6) -if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" OR NOT XCODE_VERSION VERSION_LESS 6) add_library(SharedFramework SHARED main.c) set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake index d7f3920..7f31d94 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(IOSInstallCombined CXX) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() -set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake index 28ab883..ec11dbb 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(XcodeIOSInstallCombinedPrune CXX) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() -set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake index 5e7961a..58e96b4 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(XcodeIOSInstallCombinedSingleArch CXX) -# due to lack of toolchain file it might point to running macOS version -unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() -set(CMAKE_OSX_SYSROOT iphoneos) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake index a797410..ab31387 100644 --- a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake @@ -2,11 +2,8 @@ cmake_minimum_required(VERSION 2.8.5) project(XcodeInstallIOS) -set(CMAKE_OSX_SYSROOT iphoneos) set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -set(CMAKE_OSX_ARCHITECTURES "armv7;i386") - add_library(foo STATIC foo.cpp) install(TARGETS foo ARCHIVE DESTINATION lib) diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt index cf4463c..e5f8588 100644 --- a/Tests/SwiftOnly/CMakeLists.txt +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.3) project(SwiftOnly Swift) -if(NOT XCODE_VERSION VERSION_LESS 8.0) +if(NOT XCODE_VERSION VERSION_LESS 10.2) + set(CMAKE_Swift_LANGUAGE_VERSION 5.0) +elseif(NOT XCODE_VERSION VERSION_LESS 8.0) set(CMAKE_Swift_LANGUAGE_VERSION 3.0) endif() |