diff options
19 files changed, 212 insertions, 26 deletions
diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst index 4ed10e1..8b3fb57 100644 --- a/Help/command/add_executable.rst +++ b/Help/command/add_executable.rst @@ -14,7 +14,7 @@ files listed in the command invocation. The ``<name>`` corresponds to the logical target name and must be globally unique within a project. The actual file name of the executable built is constructed based on conventions of the native platform (such as ``<name>.exe`` or just -``<name>``. +``<name>``). By default the executable file will be created in the build tree directory corresponding to the source tree directory in which the diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d1132d2..a5f01d3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 4) -set(CMake_VERSION_PATCH 20151021) +set(CMake_VERSION_PATCH 20151026) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 93c94e2..04efb71 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -570,7 +570,7 @@ int cmCPackDebGenerator::createDeb() return 0; } cmArchiveWrite control_tar(fileStream_control_tar, - tar_compression_type, + cmArchiveWrite::CompressGZip, "paxr"); // sets permissions and uid/gid for the files diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 4832186..7c7f5df 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -198,6 +198,10 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) { this->LockedResources.erase(*i); } + if (this->Properties[index]->RunSerial) + { + this->SerialTestRunning = false; + } } //--------------------------------------------------------- @@ -451,11 +455,6 @@ bool cmCTestMultiProcessHandler::CheckOutput() this->WriteCheckpoint(test); this->UnlockResources(test); this->RunningCount -= GetProcessorsUsed(test); - if (this->Properties[test]->RunSerial) - { - this->SerialTestRunning = false; - } - delete p; } return true; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 9111a3f..eecc82b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1619,6 +1619,39 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, } //---------------------------------------------------------------------------- +// This function removes each matching occurrence of the expression and +// returns the last one (i.e., the dominant flag in GCC) +std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp, + int matchIndex, + std::string& flags) +{ + std::string retFlag; + + cmsys::RegularExpression regex(exp); + assert(regex.is_valid()); + if(!regex.is_valid()) + { + return retFlag; + } + + std::string::size_type offset = 0; + + while(regex.find(flags.c_str() + offset)) + { + const std::string::size_type startPos = offset + regex.start(matchIndex); + const std::string::size_type endPos = offset + regex.end(matchIndex); + const std::string::size_type size = endPos - startPos; + + offset = startPos + 1; + + retFlag.assign(flags, startPos, size); + flags.replace(startPos, size, size, ' '); + } + + return retFlag; +} + +//---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmGeneratorTarget* target, @@ -2233,9 +2266,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, bool same_gflags = true; std::map<std::string, std::string> gflags; std::string const* last_gflag = 0; - char optLevel[2]; - optLevel[0] = '0'; - optLevel[1] = 0; + std::string optLevel = "0"; // Minimal map of flags to build settings. for (std::set<std::string>::iterator li = languages.begin(); @@ -2243,14 +2274,15 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { std::string& flags = cflags[*li]; std::string& gflag = gflags[*li]; - std::string oflag = this->ExtractFlag("-O", flags); - if(oflag.size() == 3) + std::string oflag = + this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags); + if(oflag.size() == 2) { - optLevel[0] = oflag[2]; + optLevel = "1"; } - if(oflag.size() == 2) + else if(oflag.size() > 2) { - optLevel[0] = '1'; + optLevel = oflag.substr(2); } gflag = this->ExtractFlag("-g", flags); // put back gdwarf-2 if used since there is no way diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 510d46e..c8a39df 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -151,6 +151,8 @@ private: cmXCodeObject* buildSettings, const std::string& buildType); std::string ExtractFlag(const char* flag, std::string& flags); + std::string ExtractFlagRegex(const char* exp, int matchIndex, + std::string& flags); void SortXCodeObjects(); // delete all objects in the this->XCodeObjects vector. void ClearXCodeObjects(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 264b169..40e2892 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2407,10 +2407,23 @@ bool cmMakefile::PlatformIsAppleIos() const sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT"); sdkRoot = cmSystemTools::LowerCase(sdkRoot); - return sdkRoot.find("iphoneos") == 0 || - sdkRoot.find("/iphoneos") != std::string::npos || - sdkRoot.find("iphonesimulator") == 0 || - sdkRoot.find("/iphonesimulator") != std::string::npos; + const std::string embedded[] = + { + "appletvos", "appletvsimulator", + "iphoneos", "iphonesimulator", + "watchos", "watchsimulator", + }; + + for(size_t i = 0; i < sizeof(embedded) / sizeof(embedded[0]); ++i) + { + if(sdkRoot.find(embedded[i]) == 0 || + sdkRoot.find(std::string("/") + embedded[i]) != std::string::npos) + { + return true; + } + } + + return false; } const char* cmMakefile::GetSONameFlag(const std::string& language) const diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 00895cc..2bc3693 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -78,6 +78,21 @@ endfunction() run_LabelCount() +function(run_SerialFailed) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SerialFailed) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " +add_test(NoSuchCommand no_such_command) +set_tests_properties(NoSuchCommand PROPERTIES RUN_SERIAL ON) +add_test(Echo \"${CMAKE_COMMAND}\" -E echo \"EchoTest\") +") + + run_cmake_command(SerialFailed ${CMAKE_CTEST_COMMAND} -V) +endfunction() +run_SerialFailed() + function(run_TestLoad name load) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestLoad) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/CTestCommandLine/SerialFailed-result.txt b/Tests/RunCMake/CTestCommandLine/SerialFailed-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/SerialFailed-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CTestCommandLine/SerialFailed-stderr.txt b/Tests/RunCMake/CTestCommandLine/SerialFailed-stderr.txt new file mode 100644 index 0000000..cafe565 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/SerialFailed-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: no_such_command diff --git a/Tests/RunCMake/CTestCommandLine/SerialFailed-stdout.txt b/Tests/RunCMake/CTestCommandLine/SerialFailed-stdout.txt new file mode 100644 index 0000000..d7144f7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/SerialFailed-stdout.txt @@ -0,0 +1,10 @@ +Could not find executable no_such_command +.* +2/2 Test #2: Echo ............................. Passed +[0-9.]+ sec ++ +50% tests passed, 1 tests failed out of 2 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+1 - NoSuchCommand \(Not Run\)$ diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 8ab618b..f89d620 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -4,6 +4,9 @@ run_cmake(XcodeFileType) run_cmake(XcodeAttributeGenex) run_cmake(XcodeAttributeGenexError) run_cmake(XcodeObjectNeedsQuote) +run_cmake(XcodeOptimizationFlags) +run_cmake(XcodePreserveNonOptimizationFlags) +run_cmake(XcodePreserveObjcFlag) if (NOT XCODE_VERSION VERSION_LESS 6) run_cmake(XcodePlatformFrameworks) endif() @@ -55,6 +58,38 @@ if(NOT XCODE_VERSION VERSION_LESS 5) endif() 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") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +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") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(NOT XCODE_VERSION VERSION_LESS 7) set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") run_cmake(XcodeTbdStub) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index 2cbccfa..0fdc6af 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -10,6 +10,22 @@ if(TEST_IOS) 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") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +endif() + # App Bundle add_executable(AppBundle MACOSX_BUNDLE main.m) @@ -35,11 +51,13 @@ endif() # Bundle -add_library(Bundle MODULE main.c) -set_target_properties(Bundle PROPERTIES BUNDLE TRUE) +if(NOT CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE) + add_library(Bundle MODULE main.c) + set_target_properties(Bundle PROPERTIES BUNDLE TRUE) -add_custom_target(BundleTest ALL - COMMAND ${CMAKE_COMMAND} -E copy - "$<TARGET_FILE:Bundle>" "$<TARGET_FILE:Bundle>.old") + add_custom_target(BundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:Bundle>" "$<TARGET_FILE:Bundle>.old") -add_dependencies(BundleTest Bundle) + add_dependencies(BundleTest Bundle) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake new file mode 100644 index 0000000..f5595b3 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake @@ -0,0 +1,7 @@ +foreach(level 1 2 3 s fast) + file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeOptimizationFlags.xcodeproj/project.pbxproj actual-${level} + REGEX "GCC_OPTIMIZATION_LEVEL = ${level};" LIMIT_COUNT 1) + if(NOT actual-${level}) + message(SEND_ERROR "Optimization level '${level}' not found in Xcode project.") + endif() +endforeach() diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake new file mode 100644 index 0000000..e14bf80 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake @@ -0,0 +1,20 @@ +set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types") + +set(CMAKE_CXX_FLAGS_RELEASE "") + +project(XcodeOptimizationFlags CXX) + +add_library(fooO1 STATIC foo.cpp) +set_target_properties(fooO1 PROPERTIES COMPILE_OPTIONS -O1) + +add_library(fooO2 STATIC foo.cpp) +set_target_properties(fooO2 PROPERTIES COMPILE_OPTIONS -O2) + +add_library(fooO3 STATIC foo.cpp) +set_target_properties(fooO3 PROPERTIES COMPILE_OPTIONS -O3) + +add_library(fooOs STATIC foo.cpp) +set_target_properties(fooOs PROPERTIES COMPILE_OPTIONS -Os) + +add_library(fooOfast STATIC foo.cpp) +set_target_properties(fooOfast PROPERTIES COMPILE_OPTIONS -Ofast) diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake new file mode 100644 index 0000000..2f6c03d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags-check.cmake @@ -0,0 +1,8 @@ +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodePreserveNonOptimizationFlags.xcodeproj/project.pbxproj actual + REGEX "OTHER_CPLUSPLUSFLAGS = [^;]*;") +foreach(expect "-DA" "-DB +-DC" "-DD") + if(NOT "${actual}" MATCHES "${expect}") + message(SEND_ERROR "The actual project contains the lines:\n ${actual}\n" + "which do not match expected regex:\n ${expect}\n") + endif() +endforeach() diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake new file mode 100644 index 0000000..16f0381 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodePreserveNonOptimizationFlags.cmake @@ -0,0 +1,12 @@ +set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types") + +project(XcodePreserveNonOptimizationFlags CXX) + +add_library(preserveStart STATIC foo.cpp) +set_property(TARGET preserveStart PROPERTY COMPILE_OPTIONS -DA -O1) + +add_library(preserveBoth STATIC foo.cpp) +set_property(TARGET preserveBoth PROPERTY COMPILE_OPTIONS -DB -O1 -DC) + +add_library(preserveEnd STATIC foo.cpp) +set_property(TARGET preserveEnd PROPERTY COMPILE_OPTIONS -O1 -DD) diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake new file mode 100644 index 0000000..332906f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake @@ -0,0 +1,7 @@ +set(expect "-ObjC") +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodePreserveObjcFlag.xcodeproj/project.pbxproj actual + REGEX "OTHER_CPLUSPLUSFLAGS = [^;]*;" LIMIT_COUNT 1) +if(NOT "${actual}" MATCHES "${expect}") + message(SEND_ERROR "The actual project contains the line:\n ${actual}\n" + "which does not match expected regex:\n ${expect}\n") +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake new file mode 100644 index 0000000..64db633 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake @@ -0,0 +1,6 @@ +set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types") + +project(XcodePreserveObjcFlag CXX) + +add_library(foo STATIC foo.cpp) +set_target_properties(foo PROPERTIES COMPILE_OPTIONS -ObjC) |