From e2f387fabbf6af84444665b88b8933ef5ed5cb59 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Mon, 14 Mar 2016 13:49:39 +0000 Subject: [PATCH 1/9] FindBoost: Tolerate missing indirect dependencies (#16013) Depending upon the configuration, certain components may or may not be installed, for example Boost.Regex, but other components may still have header dependencies upon these components which will obviously fail to work. Since we can't make a sensible determination with the hardcoded dependency information, we choose to interpret these dependencies less strictly. --- Modules/FindBoost.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index c3058eaec..728dcdfdf 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -745,9 +745,10 @@ endfunction() # defined; FALSE if dependency information is unavailable). # # componentvar - the component list variable name +# extravar - the indirect dependency list variable name # # -function(_Boost_MISSING_DEPENDENCIES componentvar) +function(_Boost_MISSING_DEPENDENCIES componentvar extravar) # _boost_unprocessed_components - list of components requiring processing # _boost_processed_components - components already processed (or currently being processed) # _boost_new_components - new components discovered for future processing @@ -773,7 +774,12 @@ function(_Boost_MISSING_DEPENDENCIES componentvar) set(_boost_unprocessed_components ${_boost_new_components}) unset(_boost_new_components) endwhile() + set(_boost_extra_components ${_boost_processed_components}) + if(_boost_extra_components AND ${componentvar}) + list(REMOVE_ITEM _boost_extra_components ${${componentvar}}) + endif() set(${componentvar} ${_boost_processed_components} PARENT_SCOPE) + set(${extravar} ${_boost_extra_components} PARENT_SCOPE) endfunction() # @@ -1306,7 +1312,7 @@ endif() # Additional components may be required via component dependencies. # Add any missing components to the list. -_Boost_MISSING_DEPENDENCIES(Boost_FIND_COMPONENTS) +_Boost_MISSING_DEPENDENCIES(Boost_FIND_COMPONENTS _Boost_EXTRA_FIND_COMPONENTS) # If thread is required, get the thread libs as a dependency list(FIND Boost_FIND_COMPONENTS thread _Boost_THREAD_DEPENDENCY_LIBS) @@ -1484,6 +1490,10 @@ if(Boost_FOUND) list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) endif() endforeach() + if(_Boost_MISSING_COMPONENTS AND _Boost_EXTRA_FIND_COMPONENTS) + # Optional indirect dependencies are not counted as missing. + list(REMOVE_ITEM _Boost_MISSING_COMPONENTS ${_Boost_EXTRA_FIND_COMPONENTS}) + endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}") From e3fc2899c89fb075a695d6140eaadf11db85d96c Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 14 Mar 2016 17:27:53 +0700 Subject: [PATCH 2/9] Fix iOS combined feature for single architecture targets If list of valid target architectures is empty for given SDK then there will be no VALID_ARCHS build setting returned by Xcode. Return "" (empty string) explicitly in this case. This may happens if CMAKE_IOS_INSTALL_COMBINED is ON but only one architecture used in target. --- Modules/CMakeIOSInstallCombined.cmake | 12 ++++++++- .../RunCMake/XcodeProject/RunCMakeTest.cmake | 20 +++++++++++++++ ...tallCombinedSingleArch-install-check.cmake | 25 +++++++++++++++++++ .../XcodeIOSInstallCombinedSingleArch.cmake | 19 ++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-install-check.cmake create mode 100644 Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index f052a3bf1..1256f563e 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -52,7 +52,14 @@ function(_ios_install_combined_get_build_setting sdk variable resultvar) endif() if(NOT output MATCHES " ${variable} = ([^\n]*)") - message(FATAL_ERROR "${variable} not found.") + if("${variable}" STREQUAL "VALID_ARCHS") + # VALID_ARCHS may be unset by user for given SDK + # (e.g. for build without simulator). + set("${resultvar}" "" PARENT_SCOPE) + return() + else() + message(FATAL_ERROR "${variable} not found.") + endif() endif() set("${resultvar}" "${CMAKE_MATCH_1}" PARENT_SCOPE) @@ -72,6 +79,9 @@ function(_ios_install_combined_get_valid_archs sdk resultvar) list(REMOVE_ITEM valid_archs "") # remove empty elements list(REMOVE_DUPLICATES valid_archs) + string(REPLACE ";" " " printable "${valid_archs}") + _ios_install_combined_message("Architectures (${sdk}): ${printable}") + set("${resultvar}" "${valid_archs}" PARENT_SCOPE) endfunction() diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 395c74b30..b77d5d40e 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -97,6 +97,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7) endif() if(NOT XCODE_VERSION VERSION_LESS 6) + # XcodeIOSInstallCombined set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS @@ -114,6 +115,7 @@ if(NOT XCODE_VERSION VERSION_LESS 6) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) + # XcodeIOSInstallCombinedPrune set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS @@ -130,4 +132,22 @@ if(NOT XCODE_VERSION VERSION_LESS 6) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) + + # XcodeIOSInstallCombinedSingleArch + 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_IOS_INSTALL_COMBINED=YES") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeIOSInstallCombinedSingleArch) + run_cmake_command(XcodeIOSInstallCombinedSingleArch-build ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeIOSInstallCombinedSingleArch-install ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-install-check.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-install-check.cmake new file mode 100644 index 000000000..3c11ae0ee --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch-install-check.cmake @@ -0,0 +1,25 @@ +function(verify_architecture file) + execute_process( + COMMAND xcrun lipo -info ${RunCMake_TEST_BINARY_DIR}/_install/${file} + OUTPUT_VARIABLE lipo_out + ERROR_VARIABLE lipo_err + RESULT_VARIABLE lipo_result) + if(NOT lipo_result EQUAL "0") + message(SEND_ERROR "lipo -info failed: ${lipo_err}") + return() + endif() + + string(REGEX MATCHALL "is architecture: [^ \n\t]+" architecture "${lipo_out}") + string(REGEX REPLACE "is architecture: " "" actual "${architecture}") + + set(expected armv7) + + if(NOT actual STREQUAL expected) + message(SEND_ERROR + "The actual library architecture:\n ${actual} \n" + "which do not match expected ones:\n ${expected} \n" + "lipo output:\n${lipo_out}") + endif() +endfunction() + +verify_architecture(lib/libfoo.dylib) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake new file mode 100644 index 000000000..4b5e7ce36 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.3) + +project(XcodeIOSInstallCombinedSingleArch CXX) + +set(CMAKE_OSX_SYSROOT iphoneos) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") + +add_library(foo SHARED foo.cpp) +install(TARGETS foo DESTINATION lib) + +set_target_properties( + foo + PROPERTIES + XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] armv7 + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] armv7 + XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "" + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "" +) From c718070c0887e1c429d6ae4b717c006236c32736 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 17 Mar 2016 10:47:44 -0400 Subject: [PATCH 3/9] CPack: Avoid requiring Carbon framework on OS X (#16021) In commit v3.5.0-rc1~232^2 (CPackDMG: Add support for multilingual SLAs, 2015-10-19) we added use of the Carbon framework in order to get access to its APIs to convert Script Manager RegionCode values. This is not necessary. Instead we can use CoreServices. While at it, replace individual CoreFoundation includes with including the entire framework, which is the correct way. --- Source/CMakeLists.txt | 2 +- Source/CPack/cmCPackDragNDropGenerator.cxx | 19 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ab70568d3..5b67a2dd9 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -728,7 +728,7 @@ endif() add_library(CPackLib ${CPACK_SRCS}) target_link_libraries(CPackLib CMakeLib) if(APPLE) - target_link_libraries(CPackLib "-framework Carbon") + target_link_libraries(CPackLib "-framework CoreServices") endif() if(APPLE) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 7b94ca3c0..521b3952f 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -20,21 +20,12 @@ #include -#include -#include -#include +#include -// The carbon framework is deprecated, but the Region codes it supplies are -// needed for the LPic data structure used for generating multi-lingual SLAs. -// There does not seem to be a replacement API for these region codes. -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-declarations" -#endif -#include -#if defined(__clang__) -# pragma clang diagnostic pop -#endif +// For the old LocaleStringToLangAndRegionCodes() function, to convert +// to the old Script Manager RegionCode values needed for the 'LPic' data +// structure used for generating multi-lingual SLAs. +#include static const char* SLAHeader = "data 'LPic' (5000) {\n" From 7b990e82c523772e8e40911812e6f896c0529e84 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Mar 2016 16:06:54 -0400 Subject: [PATCH 4/9] cmake-gui: Populate CFBundleIdentifier in our Info.plist file (#16023) --- Source/QtDialog/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index f17de5d50..a906f4a6f 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -173,6 +173,7 @@ if(APPLE) MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_BUNDLE_VERSION}" # TBD: MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_BUNDLE_VERSION}" MACOSX_BUNDLE_COPYRIGHT "${copyright_line}" + MACOSX_BUNDLE_GUI_IDENTIFIER "org.cmake.cmake" ) # Create a symlink in the build tree to provide a "cmake-gui" next From d84ba668d7dd77ac38b3795f92e4ef0f894c696e Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Mar 2016 08:49:02 -0400 Subject: [PATCH 5/9] CPack: Avoid using OS X CoreServices if compiler fails on header (#16021) Some compilers on OS X report errors in the CoreServices framework headers. Check for support of the header ahead of time and compile the relevant code only when the header is available. --- Source/CMakeLists.txt | 15 ++++++++++++++- Source/CPack/cmCPackDragNDropGenerator.cxx | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 5b67a2dd9..4ef0e8047 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -728,7 +728,20 @@ endif() add_library(CPackLib ${CPACK_SRCS}) target_link_libraries(CPackLib CMakeLib) if(APPLE) - target_link_libraries(CPackLib "-framework CoreServices") + # Some compilers produce errors in the CoreServices framework headers. + # Ideally such errors should be fixed by either the compiler vendor + # or the framework source, but we try to workaround it and build anyway. + # If it does not work, build with reduced functionality and warn. + check_include_file("CoreServices/CoreServices.h" HAVE_CoreServices) + if(HAVE_CoreServices) + set_property(SOURCE CPack/cmCPackDragNDropGenerator.cxx PROPERTY COMPILE_DEFINITIONS HAVE_CoreServices) + target_link_libraries(CPackLib "-framework CoreServices") + else() + message(WARNING "This compiler does not appear to support\n" + " #include \n" + "Some CPack functionality may be limited.\n" + "See CMakeFiles/CMakeError.log for details of the failure.") + endif() endif() if(APPLE) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 521b3952f..d6de77df9 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -22,10 +22,12 @@ #include +#ifdef HAVE_CoreServices // For the old LocaleStringToLangAndRegionCodes() function, to convert // to the old Script Manager RegionCode values needed for the 'LPic' data // structure used for generating multi-lingual SLAs. #include +#endif static const char* SLAHeader = "data 'LPic' (5000) {\n" @@ -643,9 +645,11 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, kCFStringEncodingMacRoman); LangCode lang = 0; RegionCode region = 0; +#ifdef HAVE_CoreServices OSStatus err = LocaleStringToLangAndRegionCodes(iso_language_cstr, &lang, ®ion); if (err != noErr) +#endif { cmCPackLogger(cmCPackLog::LOG_ERROR, "No language/region code available for " << iso_language_cstr @@ -653,10 +657,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, free(iso_language_cstr); return 0; } +#ifdef HAVE_CoreServices free(iso_language_cstr); header_data.push_back(region); header_data.push_back(i); header_data.push_back(0); +#endif } ofs << "data 'LPic' (5000) {\n"; ofs << std::hex << std::uppercase << std::setfill('0'); From 6f4f90548353d9e329bd4ddb2f7492788f28f0e1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 18 Mar 2016 15:48:56 -0400 Subject: [PATCH 6/9] FindPkgConfig: set correctly named variables in cache (#15903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fix in commit v3.5.0-rc1~27^2 (FindPkgConfig: set standard variables in the cache, 2016-01-20) added the wrong variable name to the cache. The test was only testing that the cache variable existed, not that it also had the correct value. Update the test to ensure that the cache value matches the local variable value. Reported-by: Bernd Lörwald --- Modules/FindPkgConfig.cmake | 2 +- .../FindPkgConfig/FindPkgConfig_cache_variables.cmake | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 4f50e3819..447c52622 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -383,7 +383,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma pkg_get_variable("${_pkg_check_prefix}_INCLUDEDIR" ${_pkg_check_modules_pkg} "includedir") pkg_get_variable("${_pkg_check_prefix}_LIBDIR" ${_pkg_check_modules_pkg} "libdir") foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR) - _pkgconfig_set("${_pkg_check_modules_pkg}_${variable}" "${${_pkg_check_modules_pkg}_${variable}}") + _pkgconfig_set("${_pkg_check_prefix}_${variable}" "${${_pkg_check_prefix}_${variable}}") endforeach () if (NOT ${_is_silent}) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake index 8d8d00099..d0046caa1 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake @@ -1,14 +1,15 @@ +cmake_minimum_required(VERSION 3.3) + find_package(PkgConfig REQUIRED) pkg_check_modules(NCURSES QUIET ncurses) if (NCURSES_FOUND) foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR) - get_property("${variable}" + get_property(value CACHE "NCURSES_${variable}" - PROPERTY TYPE - SET) - if (NOT ${variable}) - message(FATAL_ERROR "Failed to set cache entry for NCURSES_${variable}") + PROPERTY VALUE) + if (NOT value STREQUAL NCURSES_${variable}) + message(FATAL_ERROR "Failed to set cache entry for NCURSES_${variable}:\nexpected -->${value}<--\nreceived -->${NCURSES_${variable}}<--") endif () endforeach () else () From 72a97b7a761b46fd1668e3ae81dd9322972f4cb3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 22 Mar 2016 11:04:14 -0400 Subject: [PATCH 7/9] FindCUDA: Fix regression in separate compilation (#16027) Since commit v3.5.0-rc1~47^2 (FindCUDA: Support special characters in path, 2016-01-15) our add_custom_command calls use VERBATIM so that CMake will automatically quote special characters correctly. Fix the separate compilation code path to not add its own quoting when the VERBATIM option will be used. --- Modules/FindCUDA.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 47c03f32a..fe8b18ee3 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1551,7 +1551,12 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options list( FIND nvcc_flags "-ccbin" ccbin_found0 ) list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) - list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() endif() # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* From c61040282557ba268e144ffa5e2d1935b5991d8d Mon Sep 17 00:00:00 2001 From: Yves Frederix Date: Wed, 23 Mar 2016 10:37:51 +0100 Subject: [PATCH 8/9] Avoid occasional use-after-free when a variable watch is executed Re-lookup a variable value when an associated VariableWatch is executed in cmMakefile::GetDefinition. This fixes a problem with 'def' sometimes becoming invalid due to memory reallocation inside an std::vector. In this case, the problem was that if the call to VariableAccessed actually executed a callback function, the internal state of the makefile has changed due to the associated function scope being pushed. This in turn implies that a new cmDefinitions instance was pushed in cmMakefile::VarTree. As cmLinkedTree is based on an std::vector, this push can have triggered reallocation of its internal memory buffer. However, as the value of 'def', which was computed on method entry, actually points to a property of one of the cmDefinitions instances in cmMakefile::VarTree, reallocation can invalidate the value of 'def' so that it cannot simply be returned at the end of the function. The solution implemented here is to simply lookup the value of 'def' again. --- Source/cmMakefile.cxx | 23 +++++++++++++++-------- Source/cmVariableWatch.cxx | 4 +++- Source/cmVariableWatch.h | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 950b24735..600c985f0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2531,15 +2531,22 @@ const char* cmMakefile::GetDefinition(const std::string& name) const cmVariableWatch* vv = this->GetVariableWatch(); if ( vv && !this->SuppressWatches ) { - if ( def ) - { - vv->VariableAccessed(name, cmVariableWatch::VARIABLE_READ_ACCESS, - def, this); - } - else - { + bool const watch_function_executed = vv->VariableAccessed(name, - cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, def, this); + def ? cmVariableWatch::VARIABLE_READ_ACCESS + : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, + def, this); + + if (watch_function_executed) + { + // A callback was executed and may have caused re-allocation of the + // variable storage. Look it up again for now. + // FIXME: Refactor variable storage to avoid this problem. + def = this->StateSnapshot.GetDefinition(name); + if(!def) + { + def = this->GetState()->GetInitializedCacheValue(name); + } } } #endif diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index 57dde3139..a20071859 100644 --- a/Source/cmVariableWatch.cxx +++ b/Source/cmVariableWatch.cxx @@ -96,7 +96,7 @@ void cmVariableWatch::RemoveWatch(const std::string& variable, } } -void cmVariableWatch::VariableAccessed(const std::string& variable, +bool cmVariableWatch::VariableAccessed(const std::string& variable, int access_type, const char* newValue, const cmMakefile* mf) const @@ -112,5 +112,7 @@ void cmVariableWatch::VariableAccessed(const std::string& variable, (*it)->Method(variable, access_type, (*it)->ClientData, newValue, mf); } + return true; } + return false; } diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 0ca4a5580..2f082afe2 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -42,7 +42,7 @@ public: /** * This method is called when variable is accessed */ - void VariableAccessed(const std::string& variable, int access_type, + bool VariableAccessed(const std::string& variable, int access_type, const char* newValue, const cmMakefile* mf) const; /** From 64130a7e793483e24c1d68bdd234f81d5edb2d51 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Mar 2016 09:56:42 -0400 Subject: [PATCH 9/9] CMake 3.5.1 --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 129a882b3..683da4376 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 5) -set(CMake_VERSION_PATCH 0) +set(CMake_VERSION_PATCH 1) #set(CMake_VERSION_RC 0)