diff options
-rw-r--r-- | Modules/BundleUtilities.cmake | 152 | ||||
-rw-r--r-- | Modules/CTestCoverageCollectGCOV.cmake | 8 | ||||
-rw-r--r-- | Modules/FindBoost.cmake | 4 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 107 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 21 | ||||
-rw-r--r-- | Tests/CFBundleTest/Localized.rsrc | bin | 496 -> 472 bytes | |||
-rw-r--r-- | Tests/FindBoost/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/FindBoost/TestHeaders/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindBoost/TestHeaders/main.cxx | 9 |
11 files changed, 219 insertions, 107 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 4b52afa..cfb6450 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -52,6 +52,9 @@ # Then clear all the keys and call verify_app on the final bundle to # ensure that it is truly standalone. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>) @@ -67,6 +70,9 @@ # analysis tools on it. Calls "message(FATAL_ERROR" if the application # is not verified. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>) @@ -140,6 +146,9 @@ # all of them and copy prerequisite libs into the bundle and then do # appropriate install_name_tool fixups. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>) @@ -196,6 +205,9 @@ # bundle are contained within the bundle or are "system" libraries, # presumed to exist everywhere. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>) @@ -525,6 +537,11 @@ endfunction() function(get_bundle_keys app libs dirs keys_var) set(${keys_var} PARENT_SCOPE) + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + get_bundle_and_executable("${app}" bundle executable valid) if(valid) # Always use the exepath of the main bundle executable for @executable_path @@ -554,10 +571,24 @@ function(get_bundle_keys app libs dirs keys_var) set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}") set(prereqs "") - get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}") - foreach(pr ${prereqs}) - set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}") - endforeach() + set(ignoreFile FALSE) + get_filename_component(prereq_filename ${lib} NAME) + if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + foreach(item ${CFG_IGNORE_ITEM}) + if("${item}" STREQUAL "${prereq_filename}") + set(ignoreFile TRUE) + endif() + endforeach() + endif() + + if(NOT ignoreFile) + get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}") + foreach(pr ${prereqs}) + set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}") + endforeach() + else() + message(STATUS "Ignoring file: ${prereq_filename}") + endif() endforeach() # For each executable found in the bundle, accumulate keys as we go. @@ -583,10 +614,24 @@ function(get_bundle_keys app libs dirs keys_var) # Add each prerequisite to the keys: # set(prereqs "") - get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}") - foreach(pr ${prereqs}) - set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}") - endforeach() + set(ignoreFile FALSE) + get_filename_component(prereq_filename ${exe} NAME) + if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + foreach(item ${CFG_IGNORE_ITEM}) + if("${item}" STREQUAL "${prereq_filename}") + set(ignoreFile TRUE) + endif() + endforeach() + endif() + + if(NOT ignoreFile) + get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}") + foreach(pr ${prereqs}) + set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}") + endforeach() + else() + message(STATUS "Ignoring file: ${prereq_filename}") + endif() endforeach() # Propagate values to caller's scope: @@ -798,12 +843,19 @@ function(fixup_bundle app libs dirs) message(STATUS " libs='${libs}'") message(STATUS " dirs='${dirs}'") + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + message(STATUS " ignoreItems='${CFG_IGNORE_ITEM}'") + get_bundle_and_executable("${app}" bundle executable valid) if(valid) get_filename_component(exepath "${executable}" PATH) message(STATUS "fixup_bundle: preparing...") - get_bundle_keys("${app}" "${libs}" "${dirs}" keys) + get_bundle_keys("${app}" "${libs}" "${dirs}" keys IGNORE_ITEM "${CFG_IGNORE_ITEM}") message(STATUS "fixup_bundle: copying...") list(LENGTH keys n) @@ -857,7 +909,7 @@ function(fixup_bundle app libs dirs) clear_bundle_keys(keys) message(STATUS "fixup_bundle: verifying...") - verify_app("${app}") + verify_app("${app}" IGNORE_ITEM "${CFG_IGNORE_ITEM}") else() message(SEND_ERROR "error: fixup_bundle: not a valid bundle") endif() @@ -877,6 +929,11 @@ function(verify_bundle_prerequisites bundle result_var info_var) set(info "") set(count 0) + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + get_bundle_main_executable("${bundle}" main_bundle_exe) get_bundle_all_executables("${bundle}" file_list) @@ -887,37 +944,53 @@ function(verify_bundle_prerequisites bundle result_var info_var) message(STATUS "executable file ${count}: ${f}") set(prereqs "") - get_prerequisites("${f}" prereqs 1 1 "${exepath}" "") + set(ignoreFile FALSE) + get_filename_component(prereq_filename ${f} NAME) + + if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + foreach(item ${CFG_IGNORE_ITEM}) + if("${item}" STREQUAL "${prereq_filename}") + set(ignoreFile TRUE) + endif() + endforeach() + endif() - # On the Mac, - # "embedded" and "system" prerequisites are fine... anything else means - # the bundle's prerequisites are not verified (i.e., the bundle is not - # really "standalone") - # - # On Windows (and others? Linux/Unix/...?) - # "local" and "system" prereqs are fine... - # - set(external_prereqs "") + if(NOT ignoreFile) + get_prerequisites("${f}" prereqs 1 1 "${exepath}" "") - foreach(p ${prereqs}) - set(p_type "") - gp_file_type("${f}" "${p}" p_type) + # On the Mac, + # "embedded" and "system" prerequisites are fine... anything else means + # the bundle's prerequisites are not verified (i.e., the bundle is not + # really "standalone") + # + # On Windows (and others? Linux/Unix/...?) + # "local" and "system" prereqs are fine... + # - if(APPLE) - if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system") - set(external_prereqs ${external_prereqs} "${p}") - endif() - else() - if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system") - set(external_prereqs ${external_prereqs} "${p}") + set(external_prereqs "") + + foreach(p ${prereqs}) + set(p_type "") + gp_file_type("${f}" "${p}" p_type) + + if(APPLE) + if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system") + set(external_prereqs ${external_prereqs} "${p}") + endif() + else() + if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system") + set(external_prereqs ${external_prereqs} "${p}") + endif() endif() - endif() - endforeach() + endforeach() - if(external_prereqs) - # Found non-system/somehow-unacceptable prerequisites: - set(result 0) - set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n") + if(external_prereqs) + # Found non-system/somehow-unacceptable prerequisites: + set(result 0) + set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n") + endif() + else() + message(STATUS "Ignoring file: ${prereq_filename}") endif() endforeach() @@ -947,6 +1020,11 @@ function(verify_app app) set(verified 0) set(info "") + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + get_bundle_and_executable("${app}" bundle executable valid) message(STATUS "===========================================================================") @@ -957,7 +1035,7 @@ function(verify_app app) # Verify that the bundle does not have any "external" prerequisites: # - verify_bundle_prerequisites("${bundle}" verified info) + verify_bundle_prerequisites("${bundle}" verified info IGNORE_ITEM "${CFG_IGNORE_ITEM}") message(STATUS "verified='${verified}'") message(STATUS "info='${info}'") message(STATUS "") diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index 31c4fef..a04d340 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -287,10 +287,14 @@ ${uncovered_files_for_tar} WORKING_DIRECTORY ${binary_dir}) if (GCOV_DELETE) - string(REPLACE "\n" ";" gcov_files "${gcov_files}") - foreach(gcov_file ${gcov_files}) + foreach(gcov_file ${unfiltered_gcov_files}) file(REMOVE ${binary_dir}/${gcov_file}) endforeach() + file(REMOVE ${coverage_dir}/coverage_file_list.txt) + file(REMOVE ${coverage_dir}/data.json) + if (EXISTS ${binary_dir}/uncovered) + file(REMOVE ${binary_dir}/uncovered) + endif() endif() endfunction() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 9e6083db..38ccf78 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1573,7 +1573,7 @@ endif() # Add imported targets # ------------------------------------------------------------------------ -if(Boost_FOUND AND _Boost_IMPORTED_TARGETS) +if(Boost_FOUND) # For header-only libraries if(NOT TARGET Boost::boost) add_library(Boost::boost INTERFACE IMPORTED) @@ -1584,7 +1584,7 @@ if(Boost_FOUND AND _Boost_IMPORTED_TARGETS) endif() foreach(COMPONENT ${Boost_FIND_COMPONENTS}) - if(NOT TARGET Boost::${COMPONENT}) + if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) if(Boost_${UPPERCOMPONENT}_FOUND) if(Boost_USE_STATIC_LIBS) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index af88d2c..d066f87 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 20160418) +set(CMake_VERSION_PATCH 20160422) #set(CMake_VERSION_RC 1) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7c85281..755c8a6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -84,7 +84,7 @@ public: bool IsEmpty() const { return this->Empty; } - void Add(const char *newString) + void Add(const std::string& newString) { this->Empty = false; @@ -109,7 +109,7 @@ public: } else { - return this->Generator->CreateString(this->String.c_str()); + return this->Generator->CreateString(this->String); } } }; @@ -804,7 +804,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str())); + settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags)); // Is this a resource file in this target? Add it to the resources group... // @@ -1011,8 +1011,8 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( std::string name = cmSystemTools::GetFilenameName(path.c_str()); const char* sourceTree = (cmSystemTools::FileIsFullPath(path.c_str())? "<absolute>" : "SOURCE_ROOT"); - fileRef->AddAttribute("name", this->CreateString(name.c_str())); - fileRef->AddAttribute("path", this->CreateString(path.c_str())); + fileRef->AddAttribute("name", this->CreateString(name)); + fileRef->AddAttribute("path", this->CreateString(path)); fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree)); if(this->XcodeVersion == 15) { @@ -1326,7 +1326,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, ostr << "../" << mit->first.c_str(); } copyFilesBuildPhase->AddAttribute("dstPath", - this->CreateString(ostr.str().c_str())); + this->CreateString(ostr.str())); copyFilesBuildPhase->AddAttribute( "runOnlyForDeploymentPostprocessing", this->CreateString("0")); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -1752,7 +1752,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, (makefile+"$CONFIGURATION").c_str()); makecmd += " all"; buildphase->AddAttribute("shellScript", - this->CreateString(makecmd.c_str())); + this->CreateString(makecmd)); buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0")); } @@ -2021,7 +2021,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if(archs.size() == 1) { buildSettings->AddAttribute("ARCHS", - this->CreateString(archs[0].c_str())); + this->CreateString(archs[0])); } else { @@ -2030,7 +2030,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, for(std::vector<std::string>::iterator i = archs.begin(); i != archs.end(); i++) { - archObjects->AddObject(this->CreateString((*i).c_str())); + archObjects->AddObject(this->CreateString(*i)); } buildSettings->AddAttribute("ARCHS", archObjects); } @@ -2081,13 +2081,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { std::string pncdir = gtgt->GetDirectory(configName); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", - this->CreateString(pncdir.c_str())); + this->CreateString(pncdir)); } } else { buildSettings->AddAttribute("OBJROOT", - this->CreateString(pndir.c_str())); + this->CreateString(pndir)); pndir = gtgt->GetDirectory(configName); } @@ -2097,9 +2097,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } buildSettings->AddAttribute("EXECUTABLE_PREFIX", - this->CreateString(pnprefix.c_str())); + this->CreateString(pnprefix)); buildSettings->AddAttribute("EXECUTABLE_SUFFIX", - this->CreateString(pnsuffix.c_str())); + this->CreateString(pnsuffix)); } else if(gtgt->GetType() == cmState::OBJECT_LIBRARY) { @@ -2112,12 +2112,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string pncdir = this->GetObjectsNormalDirectory( this->CurrentProject, configName, gtgt); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", - this->CreateString(pncdir.c_str())); + this->CreateString(pncdir)); } else { buildSettings->AddAttribute("OBJROOT", - this->CreateString(pndir.c_str())); + this->CreateString(pndir)); pndir = this->GetObjectsNormalDirectory( this->CurrentProject, configName, gtgt); } @@ -2125,9 +2125,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Store the product name for all target types. buildSettings->AddAttribute("PRODUCT_NAME", - this->CreateString(realName.c_str())); + this->CreateString(realName)); buildSettings->AddAttribute("SYMROOT", - this->CreateString(pndir.c_str())); + this->CreateString(pndir)); // Handle settings for each target type. switch(gtgt->GetType()) @@ -2203,7 +2203,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { std::string fw_version = gtgt->GetFrameworkVersion(); buildSettings->AddAttribute("FRAMEWORK_VERSION", - this->CreateString(fw_version.c_str())); + this->CreateString(fw_version)); std::string plist = this->ComputeInfoPListLocation(gtgt); // Xcode will create the final version of Info.plist at build time, @@ -2282,17 +2282,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { std::string frameworkDir = *i; frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if(emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir.c_str()).c_str()); + fdirs.Add(this->XCodeEscapePath(frameworkDir)); } } else { std::string incpath = - this->XCodeEscapePath(i->c_str()); - dirs.Add(incpath.c_str()); + this->XCodeEscapePath(*i); + dirs.Add(incpath); } } // Add framework search paths needed for linking. @@ -2304,7 +2304,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { if(emitted.insert(*fdi).second) { - fdirs.Add(this->XCodeEscapePath(fdi->c_str()).c_str()); + fdirs.Add(this->XCodeEscapePath(*fdi)); } } } @@ -2390,17 +2390,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (*li == "CXX") { buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", - this->CreateString(flags.c_str())); + this->CreateString(flags)); } else if (*li == "Fortran") { buildSettings->AddAttribute("IFORT_OTHER_FLAGS", - this->CreateString(flags.c_str())); + this->CreateString(flags)); } else if (*li == "C") { buildSettings->AddAttribute("OTHER_CFLAGS", - this->CreateString(flags.c_str())); + this->CreateString(flags)); } } @@ -2444,11 +2444,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { install_name_dir = ""; extraLinkOptions += " -install_name "; - extraLinkOptions += XCodeEscapePath(install_name.c_str()); + extraLinkOptions += XCodeEscapePath(install_name); } } buildSettings->AddAttribute("INSTALL_PATH", - this->CreateString(install_name_dir.c_str())); + this->CreateString(install_name_dir)); // Create the LD_RUNPATH_SEARCH_PATHS cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); @@ -2473,18 +2473,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, { search_paths += " "; } - search_paths += this->XCodeEscapePath(runpath.c_str()); + search_paths += this->XCodeEscapePath(runpath); } } if(!search_paths.empty()) { buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS", - this->CreateString(search_paths.c_str())); + this->CreateString(search_paths)); } } buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(gtgt), - this->CreateString(extraLinkOptions.c_str())); + this->CreateString(extraLinkOptions)); buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); buildSettings->AddAttribute("SECTORDER_FLAGS", @@ -2525,7 +2525,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, v << major << "." << minor << "." << patch; } buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", - this->CreateString(v.str().c_str())); + this->CreateString(v.str())); // SOVERSION -> compatibility_version gtgt->GetTargetVersion(true, major, minor, patch); @@ -2537,7 +2537,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, vso << major << "." << minor << "." << patch; } buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", - this->CreateString(vso.str().c_str())); + this->CreateString(vso.str())); } // put this last so it can override existing settings // Convert "XCODE_ATTRIBUTE_*" properties directly. @@ -2674,14 +2674,14 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->CreateBuildSettings(gtgt, buildSettings, configVector[i].c_str()); - config->AddAttribute("name", this->CreateString(configVector[i].c_str())); + config->AddAttribute("name", this->CreateString(configVector[i])); config->SetComment(configVector[i].c_str()); config->AddAttribute("buildSettings", buildSettings); } if(!configVector.empty()) { configlist->AddAttribute("defaultConfigurationName", - this->CreateString(configVector[0].c_str())); + this->CreateString(configVector[0])); configlist->AddAttribute("defaultConfigurationIsVisible", this->CreateString("0")); return configVector[0]; @@ -2813,7 +2813,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt, { fullName = gtgt->GetFullName(defConfig.c_str()); } - fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); + fileRef->AddAttribute("path", this->CreateString(fullName)); if(this->XcodeVersion == 15) { fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3021,7 +3021,7 @@ void cmGlobalXCodeGenerator { linkObjs += sep; sep = " "; - linkObjs += this->XCodeEscapePath(oi->c_str()); + linkObjs += this->XCodeEscapePath(*oi); } this->AppendBuildSettingAttribute( target, this->GetTargetLinkFlagsVar(gt), @@ -3068,10 +3068,10 @@ void cmGlobalXCodeGenerator // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it: linkDirs += " "; linkDirs += this->XCodeEscapePath( - (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str()); + *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"); } linkDirs += " "; - linkDirs += this->XCodeEscapePath(libDir->c_str()); + linkDirs += this->XCodeEscapePath(*libDir); } } this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS", @@ -3091,7 +3091,7 @@ void cmGlobalXCodeGenerator sep = " "; if(li->IsPath) { - linkLibs += this->XCodeEscapePath(li->Value.c_str()); + linkLibs += this->XCodeEscapePath(li->Value); } else if (!li->Target || li->Target->GetType() != cmState::INTERFACE_LIBRARY) @@ -3200,7 +3200,7 @@ cmXCodeObject *cmGlobalXCodeGenerator cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); cmXCodeObject* groupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); - group->AddAttribute("name", this->CreateString(name.c_str())); + group->AddAttribute("name", this->CreateString(name)); group->AddAttribute("children", groupChildren); if(this->XcodeVersion == 15) { @@ -3447,7 +3447,7 @@ bool cmGlobalXCodeGenerator std::string pdir = this->RelativeToBinary(root->GetCurrentSourceDirectory()); this->RootObject->AddAttribute("projectDirPath", - this->CreateString(pdir.c_str())); + this->CreateString(pdir)); this->RootObject->AddAttribute("projectRoot", this->CreateString("")); } cmXCodeObject* configlist = @@ -3528,7 +3528,7 @@ bool cmGlobalXCodeGenerator else { // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO). - buildSettings->AddAttribute("ARCHS", this->CreateString(archs.c_str())); + buildSettings->AddAttribute("ARCHS", this->CreateString(archs)); } if(deploymentTarget && *deploymentTarget) { @@ -3538,12 +3538,12 @@ bool cmGlobalXCodeGenerator if(!this->GeneratorToolset.empty()) { buildSettings->AddAttribute("GCC_VERSION", - this->CreateString(this->GeneratorToolset.c_str())); + this->CreateString(this->GeneratorToolset)); } std::string symroot = root->GetCurrentBinaryDirectory(); symroot += "/build"; - buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str())); + buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot)); for(Configs::iterator i = configs.begin(); i != configs.end(); ++i) { @@ -3932,17 +3932,16 @@ std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p) } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) +std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p) { - std::string ret = p; - if(ret.find(' ') != ret.npos) + if(p.find(' ') != p.npos) { - std::string t = ret; - ret = "\""; - ret += t; - ret += "\""; + std::string t = "\""; + t += p; + t += "\""; + return t; } - return ret; + return p; } //---------------------------------------------------------------------------- @@ -4025,7 +4024,7 @@ cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs, // Append the flag with needed escapes. std::string tmp; this->AppendFlag(tmp, def); - defs.Add(tmp.c_str()); + defs.Add(tmp); } } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 862746f..f7bfb26 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -96,7 +96,7 @@ private: bool CreateGroups(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); - std::string XCodeEscapePath(const char* p); + std::string XCodeEscapePath(const std::string& p); std::string RelativeToSource(const char* p); std::string RelativeToBinary(const char* p); std::string ConvertToRelativeForMake(const char* p); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3a56c2a..f01ff74 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1824,10 +1824,11 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmState::CacheEntryType type, bool force) { - bool haveVal = value ? true : false; - std::string val = haveVal ? value : ""; const char* existingValue = this->GetState()->GetInitializedCacheValue(name); + // must be outside the following if() to keep it alive long enough + std::string nvalue; + if(existingValue && (this->GetState()->GetCacheEntryType(name) == cmState::UNINITIALIZED)) @@ -1836,15 +1837,16 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, // if it is a force, then use the value being passed in if(!force) { - val = existingValue; - haveVal = true; + value = existingValue; } if ( type == cmState::PATH || type == cmState::FILEPATH ) { std::vector<std::string>::size_type cc; std::vector<std::string> files; - std::string nvalue = ""; - cmSystemTools::ExpandListArgument(val, files); + nvalue = value ? value : ""; + + cmSystemTools::ExpandListArgument(nvalue, files); + nvalue = ""; for ( cc = 0; cc < files.size(); cc ++ ) { if(!cmSystemTools::IsOff(files[cc].c_str())) @@ -1859,13 +1861,12 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, } this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type); - val = this->GetState()->GetInitializedCacheValue(name); - haveVal = true; + nvalue = this->GetState()->GetInitializedCacheValue(name); + value = nvalue.c_str(); } } - this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0, - doc, type); + this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type); // if there was a definition then remove it this->StateSnapshot.RemoveDefinition(name); } diff --git a/Tests/CFBundleTest/Localized.rsrc b/Tests/CFBundleTest/Localized.rsrc Binary files differindex cbf3523..7973c1f 100644 --- a/Tests/CFBundleTest/Localized.rsrc +++ b/Tests/CFBundleTest/Localized.rsrc diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt index 259ee26..0e9527d 100644 --- a/Tests/FindBoost/CMakeLists.txt +++ b/Tests/FindBoost/CMakeLists.txt @@ -8,3 +8,14 @@ add_test(NAME FindBoost.Test COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + +add_test(NAME FindBoost.TestHeaders COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBoost/TestHeaders" + "${CMake_BINARY_DIR}/Tests/FindBoost/TestHeaders" + ${build_generator_args} + --build-project TestFindBoostHeaders + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindBoost/TestHeaders/CMakeLists.txt b/Tests/FindBoost/TestHeaders/CMakeLists.txt new file mode 100644 index 0000000..d7be327 --- /dev/null +++ b/Tests/FindBoost/TestHeaders/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindBoostHeaders CXX) +include(CTest) + +find_package(Boost REQUIRED) + +add_executable(test_boost_headers_tgt main.cxx) +target_link_libraries(test_boost_headers_tgt + Boost::boost) +add_test(NAME test_boost_headers_tgt COMMAND test_boost_headers_tgt) diff --git a/Tests/FindBoost/TestHeaders/main.cxx b/Tests/FindBoost/TestHeaders/main.cxx new file mode 100644 index 0000000..0400d6d --- /dev/null +++ b/Tests/FindBoost/TestHeaders/main.cxx @@ -0,0 +1,9 @@ +#include <boost/any.hpp> + +int main() { + boost::any a; + a = 5; + a = std::string("A string"); + + return 0; +} |