diff options
-rw-r--r-- | Modules/CMakeIOSInstallCombined.cmake | 31 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalXCodeGenerator.cxx | 60 | ||||
-rw-r--r-- | Source/cmLocalXCodeGenerator.h | 2 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 29 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-cmakeinstall-check.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake | 2 |
8 files changed, 109 insertions, 21 deletions
diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index 44bb622..b022217 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -3,10 +3,11 @@ cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST +cmake_policy(SET CMP0054 NEW) # Function to print messages of this module function(_ios_install_combined_message) - message("[iOS combined] " ${ARGN}) + message(STATUS "[iOS combined] " ${ARGN}) endfunction() # Get build settings for the current target/config/SDK by running @@ -176,29 +177,33 @@ function(_ios_install_combined_keep_archs lib archs) endforeach() endfunction() -function(_ios_install_combined_detect_sdks this_sdk_var corr_sdk_var) - set(this_sdk "$ENV{PLATFORM_NAME}") - if("${this_sdk}" STREQUAL "") - message(FATAL_ERROR "Environment variable PLATFORM_NAME is empty") +function(_ios_install_combined_detect_associated_sdk corr_sdk_var) + if("${PLATFORM_NAME}" STREQUAL "") + message(FATAL_ERROR "PLATFORM_NAME should not be empty") endif() set(all_platforms "$ENV{SUPPORTED_PLATFORMS}") - if("${all_platforms}" STREQUAL "") - message(FATAL_ERROR "Environment variable SUPPORTED_PLATFORMS is empty") + if("${SUPPORTED_PLATFORMS}" STREQUAL "") + _ios_install_combined_get_build_setting( + ${PLATFORM_NAME} SUPPORTED_PLATFORMS all_platforms) + if("${all_platforms}" STREQUAL "") + message(FATAL_ERROR + "SUPPORTED_PLATFORMS not set as an environment variable nor " + "able to be determined from project") + endif() endif() separate_arguments(all_platforms) - if(NOT this_sdk IN_LIST all_platforms) - message(FATAL_ERROR "`${this_sdk}` not found in `${all_platforms}`") + if(NOT PLATFORM_NAME IN_LIST all_platforms) + message(FATAL_ERROR "`${PLATFORM_NAME}` not found in `${all_platforms}`") endif() - list(REMOVE_ITEM all_platforms "" "${this_sdk}") + list(REMOVE_ITEM all_platforms "" "${PLATFORM_NAME}") list(LENGTH all_platforms all_platforms_length) if(NOT all_platforms_length EQUAL 1) message(FATAL_ERROR "Expected one element: ${all_platforms}") endif() - set(${this_sdk_var} "${this_sdk}" PARENT_SCOPE) set(${corr_sdk_var} "${all_platforms}" PARENT_SCOPE) endfunction() @@ -274,10 +279,10 @@ function(ios_install_combined target destination) _ios_install_combined_message("Destination: ${destination}") # Get SDKs - _ios_install_combined_detect_sdks(this_sdk corr_sdk) + _ios_install_combined_detect_associated_sdk(corr_sdk) # Get architectures of the target - _ios_install_combined_get_valid_archs("${this_sdk}" this_valid_archs) + _ios_install_combined_get_valid_archs("${PLATFORM_NAME}" this_valid_archs) _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs) _ios_install_combined_prune_common_archs("${corr_sdk}" corr_valid_archs this_valid_archs) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2239192..b5580e7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -644,6 +644,8 @@ void cmLocalGenerator::GenerateInstallRules() /* clang-format on */ } + this->AddGeneratorSpecificInstallSetup(fout); + // Ask each install generator to write its code. cmPolicies::PolicyStatus status = this->GetPolicyStatus(cmPolicies::CMP0082); auto const& installers = this->Makefile->GetInstallGenerators(); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 22d3599..0fa8759 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -493,6 +493,8 @@ protected: std::ostream& os, const std::string& config, std::vector<std::string> const& configurationTypes); + virtual void AddGeneratorSpecificInstallSetup(std::ostream&) {} + std::string& CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max); diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index ac0d35e..3b4e3a8 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -4,6 +4,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalXCodeGenerator.h" +#include "cmMakefile.h" #include "cmSourceFile.h" class cmGeneratorTarget; @@ -45,13 +46,66 @@ void cmLocalXCodeGenerator::Generate() } } -void cmLocalXCodeGenerator::GenerateInstallRules() +void cmLocalXCodeGenerator::AddGeneratorSpecificInstallSetup(std::ostream& os) { - cmLocalGenerator::GenerateInstallRules(); - + // First check if we need to warn about incompatible settings for (const auto& target : this->GetGeneratorTargets()) { target->HasMacOSXRpathInstallNameDir(""); } + + // CMakeIOSInstallCombined.cmake needs to know the location of the top of + // the build directory + os << "set(CMAKE_BINARY_DIR \"" << this->GetBinaryDirectory() << "\")\n\n"; + + if (this->Makefile->PlatformIsAppleEmbedded()) { + std::string platformName; + switch (this->Makefile->GetAppleSDKType()) { + case cmMakefile::AppleSDK::IPhoneOS: + platformName = "iphoneos"; + break; + case cmMakefile::AppleSDK::IPhoneSimulator: + platformName = "iphonesimulator"; + break; + case cmMakefile::AppleSDK::AppleTVOS: + platformName = "appletvos"; + break; + case cmMakefile::AppleSDK::AppleTVSimulator: + platformName = "appletvsimulator"; + break; + case cmMakefile::AppleSDK::WatchOS: + platformName = "watchos"; + break; + case cmMakefile::AppleSDK::WatchSimulator: + platformName = "watchsimulator"; + break; + case cmMakefile::AppleSDK::MacOS: + break; + } + if (!platformName.empty()) { + // The effective platform name is just the platform name with a hyphen + // prepended. We can get the SUPPORTED_PLATFORMS from the project file + // at runtime, so we don't need to compute that here. + /* clang-format off */ + os << + "if(NOT PLATFORM_NAME)\n" + " if(NOT \"$ENV{PLATFORM_NAME}\" STREQUAL \"\")\n" + " set(PLATFORM_NAME \"$ENV{PLATFORM_NAME}\")\n" + " endif()\n" + " if(NOT PLATFORM_NAME)\n" + " set(PLATFORM_NAME " << platformName << ")\n" + " endif()\n" + "endif()\n\n" + "if(NOT EFFECTIVE_PLATFORM_NAME)\n" + " if(NOT \"$ENV{EFFECTIVE_PLATFORM_NAME}\" STREQUAL \"\")\n" + " set(EFFECTIVE_PLATFORM_NAME \"$ENV{EFFECTIVE_PLATFORM_NAME}\")\n" + " endif()\n" + " if(NOT EFFECTIVE_PLATFORM_NAME)\n" + " set(EFFECTIVE_PLATFORM_NAME -" << platformName << ")\n" + " endif()\n" + "endif()\n\n"; + /* clang-format off */ + } + } } void cmLocalXCodeGenerator::ComputeObjectFilenames( diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index dd038b4..5f72f6d 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -32,7 +32,7 @@ public: void AppendFlagEscape(std::string& flags, const std::string& rawFlag) const override; void Generate() override; - virtual void GenerateInstallRules(); + void AddGeneratorSpecificInstallSetup(std::ostream& os) override; void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt = nullptr) override; diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 62163ac..794274c 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -206,7 +206,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7) unset(RunCMake_TEST_OPTIONS) endif() -if(XCODE_VERSION VERSION_GREATER_EQUAL 6 AND XCODE_VERSION VERSION_LESS 12) +if(XCODE_VERSION VERSION_GREATER_EQUAL 6) # XcodeIOSInstallCombined set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) set(RunCMake_TEST_NO_CLEAN 1) @@ -220,7 +220,14 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 6 AND XCODE_VERSION VERSION_LESS 12) run_cmake(XcodeIOSInstallCombined) run_cmake_command(XcodeIOSInstallCombined-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeIOSInstallCombined-install ${CMAKE_COMMAND} --build . --target install) + if(XCODE_VERSION VERSION_LESS 12) + run_cmake_command(XcodeIOSInstallCombined-install ${CMAKE_COMMAND} --build . --target install) + endif() + # --build defaults to Debug, --install defaults to Release, so we have to + # specify the configuration explicitly + run_cmake_command(XcodeIOSInstallCombined-cmakeinstall + ${CMAKE_COMMAND} --install . --config Debug + ) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) @@ -239,7 +246,14 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 6 AND XCODE_VERSION VERSION_LESS 12) run_cmake(XcodeIOSInstallCombinedPrune) run_cmake_command(XcodeIOSInstallCombinedPrune-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeIOSInstallCombinedPrune-install ${CMAKE_COMMAND} --build . --target install) + if(XCODE_VERSION VERSION_LESS 12) + run_cmake_command(XcodeIOSInstallCombinedPrune-install ${CMAKE_COMMAND} --build . --target install) + endif() + # --build defaults to Debug, --install defaults to Release, so we have to + # specify the configuration explicitly + run_cmake_command(XcodeIOSInstallCombinedPrune-cmakeinstall + ${CMAKE_COMMAND} --install . --config Debug + ) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) @@ -258,7 +272,14 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 6 AND XCODE_VERSION VERSION_LESS 12) run_cmake(XcodeIOSInstallCombinedSingleArch) run_cmake_command(XcodeIOSInstallCombinedSingleArch-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeIOSInstallCombinedSingleArch-install ${CMAKE_COMMAND} --build . --target install) + if(XCODE_VERSION VERSION_LESS 12) + run_cmake_command(XcodeIOSInstallCombinedSingleArch-install ${CMAKE_COMMAND} --build . --target install) + endif() + # --build defaults to Debug, --install defaults to Release, so we have to + # specify the configuration explicitly + run_cmake_command(XcodeIOSInstallCombinedSingleArch-cmakeinstall + ${CMAKE_COMMAND} --install . --config Debug + ) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-cmakeinstall-check.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-cmakeinstall-check.cmake new file mode 100644 index 0000000..a1ceb13 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-cmakeinstall-check.cmake @@ -0,0 +1,2 @@ +# Expect the same results whether installing directly or via cmake --install +include(${CMAKE_CURRENT_LIST_DIR}/XcodeIOSInstallCombined-install-check.cmake) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake new file mode 100644 index 0000000..3f7c379 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake @@ -0,0 +1,2 @@ +# Expect the same results whether installing directly or via cmake --install +include(${CMAKE_CURRENT_LIST_DIR}/XcodeIOSInstallCombinedSingleArch-install-check.cmake) |