diff options
108 files changed, 1386 insertions, 531 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index 2d12c07..f522c44 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -69,4 +69,17 @@ macro(_cmake_find_compiler lang) endif() unset(_${lang}_COMPILER_HINTS) unset(_languages) + + # Look for a make tool provided by Xcode + if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE) + foreach(comp ${CMAKE_${lang}_COMPILER_LIST}) + execute_process(COMMAND xcrun --find ${comp} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err) + if(_xcrun_out) + set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_out}") + break() + endif() + endforeach() + endif() endmacro() diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index e9ae995..5d35ce3 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -28,9 +28,6 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) if(DEFINED CMAKE_${lang}_VERBOSE_FLAG) set(CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}") endif() - if(CMAKE_${lang}_COMPILER_TARGET) - set(CMAKE_FLAGS "${CMAKE_FLAGS} -DCMAKE_${lang}_COMPILER_TARGET=${CMAKE_${lang}_COMPILER_TARGET}") - endif() try_compile(CMAKE_${lang}_ABI_COMPILED ${CMAKE_BINARY_DIR} ${src} CMAKE_FLAGS "${CMAKE_FLAGS}" diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index ae91a29..ebd9ce0 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -109,12 +109,9 @@ Id flags: ${testflags} # Compile the compiler identification source. if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)") set(vs_version ${CMAKE_MATCH_1}) - set(id_arch ${CMAKE_VS_PLATFORM_NAME}) + set(id_platform ${CMAKE_VS_PLATFORM_NAME}) set(id_lang "${lang}") set(id_cl cl.exe) - if(NOT id_arch) - set(id_arch Win32) - endif() if(NOT "${vs_version}" VERSION_LESS 10) set(v 10) set(ext vcxproj) @@ -126,16 +123,8 @@ Id flags: ${testflags} set(v 6) set(ext dsp) endif() - if("${id_arch}" STREQUAL "x64") - set(id_machine_10 MachineX64) - elseif("${id_arch}" STREQUAL "Itanium") - set(id_machine_10 MachineIA64) - set(id_arch ia64) - elseif("${id_arch}" STREQUAL "ARM") - set(id_machine_10 MachineARM) - else() - set(id_machine_6 x86) - set(id_machine_10 MachineX86) + if("${id_platform}" STREQUAL "Itanium") + set(id_platform ia64) endif() if(CMAKE_VS_PLATFORM_TOOLSET) set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>") @@ -149,7 +138,7 @@ Id flags: ${testflags} set(id_subsystem 1) endif() if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]") - set(build /p:Configuration=Debug /p:Platform=@id_arch@ /p:VisualStudioVersion=${vs_version}.0) + set(build /p:Configuration=Debug /p:Platform=@id_platform@ /p:VisualStudioVersion=${vs_version}.0) elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]") set(build /make) else() @@ -341,6 +330,35 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) endif() endforeach() + # Detect the exact architecture from the PE header. + if(WIN32) + # The offset to the PE signature is stored at 0x3c. + file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX) + string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1) + string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2) + set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}") + string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}") + math(EXPR peoffset "${peoffsetexpression}") + + file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX) + if(peheader STREQUAL "50450000a201") + set(ARCHITECTURE_ID "SH3") + elseif(peheader STREQUAL "50450000a301") + set(ARCHITECTURE_ID "SH3DSP") + elseif(peheader STREQUAL "50450000a601") + set(ARCHITECTURE_ID "SH4") + elseif(peheader STREQUAL "50450000a801") + set(ARCHITECTURE_ID "SH5") + elseif(peheader STREQUAL "50450000c201") + set(ARCHITECTURE_ID "THUMB") + endif() + endif() + # Check if a valid compiler and platform were found. if(COMPILER_ID AND NOT COMPILER_ID_TWICE) set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}") diff --git a/Modules/CMakeUnixFindMake.cmake b/Modules/CMakeUnixFindMake.cmake index c75cf7c..3714926 100644 --- a/Modules/CMakeUnixFindMake.cmake +++ b/Modules/CMakeUnixFindMake.cmake @@ -14,3 +14,13 @@ find_program(CMAKE_MAKE_PROGRAM NAMES gmake make smake) mark_as_advanced(CMAKE_MAKE_PROGRAM) + +# Look for a make tool provided by Xcode +if(NOT CMAKE_MAKE_PROGRAM AND CMAKE_HOST_APPLE) + execute_process(COMMAND xcrun --find make + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err) + if(_xcrun_out) + set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${_xcrun_out}") + endif() +endif() diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 66b00bd..ec4562a 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -25,5 +25,4 @@ macro(__compiler_clang lang) set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") - set(CMAKE_${lang}_COMPILE_OPTION_TARGET "-target ") endmacro() diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index ab4705f..1a7a539 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|@id_arch@"> + <ProjectConfiguration Include="Debug|@id_platform@"> <Configuration>Debug</Configuration> - <Platform>@id_arch@</Platform> + <Platform>@id_platform@</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> @@ -12,7 +12,7 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'" Label="Configuration"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> @id_toolset@ <CharacterSet>MultiByte</CharacterSet> @@ -20,11 +20,11 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">.\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">$(Configuration)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">false</LinkIncremental> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'"> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'"> <ClCompile> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -40,7 +40,6 @@ <Link> <GenerateDebugInformation>false</GenerateDebugInformation> <SubSystem>Console</SubSystem> - <TargetMachine>@id_machine_10@</TargetMachine> </Link> <PostBuildEvent> <Command>for %%i in (@id_cl@) do %40echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i</Command> diff --git a/Modules/CompilerId/VS-6.dsp.in b/Modules/CompilerId/VS-6.dsp.in index 4f7e676..48c9a23 100644 --- a/Modules/CompilerId/VS-6.dsp.in +++ b/Modules/CompilerId/VS-6.dsp.in @@ -1,7 +1,7 @@ # Microsoft Developer Studio Project File - Name="CompilerId@id_lang@" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 -# TARGTYPE "Win32 (@id_machine_6@) Application" 0x0101 +# TARGTYPE "Win32 (x86) Application" 0x0101 CFG=CompilerId@id_lang@ - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, @@ -16,7 +16,7 @@ CFG=CompilerId@id_lang@ - Win32 Debug !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "CompilerId@id_lang@ - Win32 Debug" (based on "Win32 (@id_machine_6@) Application") +!MESSAGE "CompilerId@id_lang@ - Win32 Debug" (based on "Win32 (x86) Application") !MESSAGE # Begin Project @@ -29,7 +29,7 @@ CPP=cl.exe # PROP Target_Dir "" # ADD CPP /nologo /MDd /c LINK32=link.exe -# ADD LINK32 /nologo /version:0.0 /subsystem:console /machine:@id_machine_6@ /out:"CompilerId@id_lang@.exe" /IGNORE:4089 +# ADD LINK32 /nologo /version:0.0 /subsystem:console /machine:x86 /out:"CompilerId@id_lang@.exe" /IGNORE:4089 # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Cmds=for %%i in (@id_cl@) do @echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i diff --git a/Modules/CompilerId/VS-7.vcproj.in b/Modules/CompilerId/VS-7.vcproj.in index fa48cad..9e3c3c3 100644 --- a/Modules/CompilerId/VS-7.vcproj.in +++ b/Modules/CompilerId/VS-7.vcproj.in @@ -10,12 +10,12 @@ > <Platforms> <Platform - Name="@id_arch@" + Name="@id_platform@" /> </Platforms> <Configurations> <Configuration - Name="Debug|@id_arch@" + Name="Debug|@id_platform@" OutputDirectory="." IntermediateDirectory="$(ConfigurationName)" ConfigurationType="1" diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 865cc8e..0930880 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -134,11 +134,23 @@ elseif("${CMAKE_GENERATOR}" MATCHES Xcode set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9") if(CMAKE_OSX_DEPLOYMENT_TARGET) set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}}) + set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") + if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}") + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}") + else() + set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}}) + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") + message(WARNING + "CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' " + "but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n" + "Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"\n" + "matching the host OS X version." + ) + endif() else() set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}}) + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") endif() - set(_CMAKE_OSX_SYSROOT_DEFAULT - "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") else() # Assume developer files are in root (such as Xcode 4.5 command-line tools). set(_CMAKE_OSX_SYSROOT_DEFAULT "") @@ -326,6 +338,12 @@ set(CMAKE_SYSTEM_APPBUNDLE_PATH unset(_apps_paths) include(Platform/UnixPaths) +if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr) + foreach(lang C CXX) + list(APPEND CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) + endforeach() +endif() list(APPEND CMAKE_SYSTEM_PREFIX_PATH /sw # Fink /opt/local # MacPorts diff --git a/Modules/Platform/QNX.cmake b/Modules/Platform/QNX.cmake index 315f721..2598411 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -13,9 +13,6 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples -set(CMAKE_C_COMPILE_OPTION_TARGET "-V") -set(CMAKE_CXX_COMPILE_OPTION_TARGET "-V") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 9f97570..685638a 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -141,8 +141,12 @@ if(WINCE) set(_RTC1 "") set(_FLAGS_CXX " /GR /EHsc") - set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib") + set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib") set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib") + + if (MSVC_VERSION LESS 1500) + set(CMAKE_C_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT} corelibc.lib") + endif () else() set(_PLATFORM_DEFINES "/DWIN32") @@ -171,13 +175,6 @@ set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) if(NOT _MACHINE_ARCH_FLAG) set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) endif() -if(WINCE) - if(_MACHINE_ARCH_FLAG MATCHES "ARM") - set(_MACHINE_ARCH_FLAG "THUMB") - elseif(_MACHINE_ARCH_FLAG MATCHES "SH") - set(_MACHINE_ARCH_FLAG "SH4") - endif() -endif() set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /machine:${_MACHINE_ARCH_FLAG}") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ef7c8fb..b9a95ee 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 11) -set(CMake_VERSION_TWEAK 20130806) +set(CMake_VERSION_TWEAK 20130815) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx index a22c7be..934481b 100644 --- a/Source/CTest/cmCTestBatchTestHandler.cxx +++ b/Source/CTest/cmCTestBatchTestHandler.cxx @@ -89,7 +89,7 @@ void cmCTestBatchTestHandler::WriteTestCommand(int test, std::fstream& fout) command = cmSystemTools::ConvertToOutputPath(command.c_str()); //Prepends memcheck args to our command string if this is a memcheck - this->TestHandler->GenerateTestCommand(processArgs); + this->TestHandler->GenerateTestCommand(processArgs, test); processArgs.push_back(command); for(std::vector<std::string>::iterator arg = processArgs.begin(); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 8baa673..3ae2ac6 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -200,6 +200,7 @@ void cmCTestMemCheckHandler::Initialize() this->CustomMaximumPassedTestOutputSize = 0; this->CustomMaximumFailedTestOutputSize = 0; this->MemoryTester = ""; + this->MemoryTesterDynamicOptions.clear(); this->MemoryTesterOptions.clear(); this->MemoryTesterStyle = UNKNOWN; this->MemoryTesterOutputFile = ""; @@ -242,12 +243,28 @@ int cmCTestMemCheckHandler::PostProcessHandler() //---------------------------------------------------------------------- void cmCTestMemCheckHandler::GenerateTestCommand( - std::vector<std::string>& args) + std::vector<std::string>& args, int test) { std::vector<cmStdString>::size_type pp; - std::string memcheckcommand = ""; - memcheckcommand + cmStdString index; + cmOStringStream stream; + std::string memcheckcommand = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); + stream << test; + index = stream.str(); + for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ ) + { + cmStdString arg = this->MemoryTesterDynamicOptions[pp]; + cmStdString::size_type pos = arg.find("??"); + if (pos != cmStdString::npos) + { + arg.replace(pos, 2, index); + } + args.push_back(arg); + memcheckcommand += " \""; + memcheckcommand += arg; + memcheckcommand += "\""; + } for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ ) { args.push_back(this->MemoryTesterOptions[pp]); @@ -478,7 +495,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() = cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); this->MemoryTesterOutputFile - = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; + = this->CTest->GetBinaryDir() + + "/Testing/Temporary/MemoryChecker.??.log"; switch ( this->MemoryTesterStyle ) { @@ -510,7 +528,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } std::string outputFile = "--log-file=" + this->MemoryTesterOutputFile; - this->MemoryTesterOptions.push_back(outputFile); + this->MemoryTesterDynamicOptions.push_back(outputFile); break; } case cmCTestMemCheckHandler::PURIFY: @@ -538,19 +556,19 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() outputFile = "-log-file="; #endif outputFile += this->MemoryTesterOutputFile; - this->MemoryTesterOptions.push_back(outputFile); + this->MemoryTesterDynamicOptions.push_back(outputFile); break; } case cmCTestMemCheckHandler::BOUNDS_CHECKER: { this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; std::string dpbdFile = this->CTest->GetBinaryDir() - + "/Testing/Temporary/MemoryChecker.DPbd"; + + "/Testing/Temporary/MemoryChecker.??.DPbd"; this->BoundsCheckerDPBDFile = dpbdFile; - this->MemoryTesterOptions.push_back("/B"); - this->MemoryTesterOptions.push_back(dpbdFile); - this->MemoryTesterOptions.push_back("/X"); - this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); + this->MemoryTesterDynamicOptions.push_back("/B"); + this->MemoryTesterDynamicOptions.push_back(dpbdFile); + this->MemoryTesterDynamicOptions.push_back("/X"); + this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile); this->MemoryTesterOptions.push_back("/M"); break; } @@ -898,25 +916,23 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( // This method puts the bounds checker output file into the output // for the test void -cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res) +cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, + int test) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessBoundsCheckerTest for : " << res.Name.c_str() << std::endl); - if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) ) + cmStdString ofile = testOutputFileName(test); + if ( ofile.empty() ) { - std::string log = "Cannot find memory tester output file: " - + this->MemoryTesterOutputFile; - cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } // put a scope around this to close ifs so the file can be removed { - std::ifstream ifs(this->MemoryTesterOutputFile.c_str()); + std::ifstream ifs(ofile.c_str()); if ( !ifs ) { - std::string log = "Cannot read memory tester output file: " - + this->MemoryTesterOutputFile; + std::string log = "Cannot read memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } @@ -939,38 +955,39 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res) } void -cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res) +cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res, + int test) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessPurifyTest for : " << res.Name.c_str() << std::endl); - appendMemTesterOutput(res); + appendMemTesterOutput(res, test); } void -cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res) +cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res, + int test) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessValgrindTest for : " << res.Name.c_str() << std::endl); - appendMemTesterOutput(res); + appendMemTesterOutput(res, test); } void -cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res) +cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, + int test) { - if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) ) + cmStdString ofile = testOutputFileName(test); + + if ( ofile.empty() ) { - std::string log = "Cannot find memory tester output file: " - + this->MemoryTesterOutputFile; - cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } - std::ifstream ifs(this->MemoryTesterOutputFile.c_str()); + std::ifstream ifs(ofile.c_str()); if ( !ifs ) { - std::string log = "Cannot read memory tester output file: " - + this->MemoryTesterOutputFile; + std::string log = "Cannot read memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } @@ -981,3 +998,25 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res) res.Output += "\n"; } } + +cmStdString +cmCTestMemCheckHandler::testOutputFileName(int test) +{ + cmStdString index; + cmOStringStream stream; + stream << test; + index = stream.str(); + cmStdString ofile = this->MemoryTesterOutputFile; + cmStdString::size_type pos = ofile.find("??"); + ofile.replace(pos, 2, index); + + if ( !cmSystemTools::FileExists(ofile.c_str()) ) + { + std::string log = "Cannot find memory tester output file: " + + ofile; + cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); + ofile = ""; + } + + return ofile; +} diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 0a8c1b3..040d2e0 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -37,7 +37,7 @@ public: protected: virtual int PreProcessHandler(); virtual int PostProcessHandler(); - virtual void GenerateTestCommand(std::vector<std::string>& args); + virtual void GenerateTestCommand(std::vector<std::string>& args, int test); private: @@ -89,6 +89,7 @@ private: std::string BoundsCheckerDPBDFile; std::string BoundsCheckerXMLFile; std::string MemoryTester; + std::vector<cmStdString> MemoryTesterDynamicOptions; std::vector<cmStdString> MemoryTesterOptions; int MemoryTesterStyle; std::string MemoryTesterOutputFile; @@ -117,12 +118,16 @@ private: bool ProcessMemCheckBoundsCheckerOutput(const std::string& str, std::string& log, int* results); - void PostProcessPurifyTest(cmCTestTestResult& res); - void PostProcessBoundsCheckerTest(cmCTestTestResult& res); - void PostProcessValgrindTest(cmCTestTestResult& res); + void PostProcessPurifyTest(cmCTestTestResult& res, int test); + void PostProcessBoundsCheckerTest(cmCTestTestResult& res, int test); + void PostProcessValgrindTest(cmCTestTestResult& res, int test); ///! append MemoryTesterOutputFile to the test log - void appendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res); + void appendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res, + int test); + + ///! generate the output filename for the given test index + cmStdString testOutputFileName(int test); }; #endif diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ddd7e45..0e2fa41 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -389,13 +389,13 @@ void cmCTestRunTest::MemCheckPostProcess() switch ( handler->MemoryTesterStyle ) { case cmCTestMemCheckHandler::VALGRIND: - handler->PostProcessValgrindTest(this->TestResult); + handler->PostProcessValgrindTest(this->TestResult, this->Index); break; case cmCTestMemCheckHandler::PURIFY: - handler->PostProcessPurifyTest(this->TestResult); + handler->PostProcessPurifyTest(this->TestResult, this->Index); break; case cmCTestMemCheckHandler::BOUNDS_CHECKER: - handler->PostProcessBoundsCheckerTest(this->TestResult); + handler->PostProcessBoundsCheckerTest(this->TestResult, this->Index); break; default: break; @@ -524,7 +524,7 @@ void cmCTestRunTest::ComputeArguments() = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str()); //Prepends memcheck args to our command string - this->TestHandler->GenerateTestCommand(this->Arguments); + this->TestHandler->GenerateTestCommand(this->Arguments, this->Index); for(std::vector<std::string>::iterator i = this->Arguments.begin(); i != this->Arguments.end(); ++i) { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 7a3edb5..497774d 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1107,7 +1107,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, } //---------------------------------------------------------------------- -void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&) +void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&, int) { } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 8e59e59..93b793b 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -153,7 +153,7 @@ protected: // compute a final test list virtual int PreProcessHandler(); virtual int PostProcessHandler(); - virtual void GenerateTestCommand(std::vector<std::string>& args); + virtual void GenerateTestCommand(std::vector<std::string>& args, int test); int ExecuteCommands(std::vector<cmStdString>& vec); void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result); diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 1684fb2..ef25294 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -11,6 +11,9 @@ #============================================================================= project(QtDialog) +if(POLICY CMP0020) + cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required +endif() find_package(Qt5Widgets QUIET) if (Qt5Widgets_FOUND) include_directories(${Qt5Widgets_INCLUDE_DIRS}) @@ -29,6 +32,11 @@ if (Qt5Widgets_FOUND) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") + + if(WIN32 AND TARGET Qt5::Core) + get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION) + get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH) + endif() else() set(QT_MIN_VERSION "4.4.0") find_package(Qt4 REQUIRED) @@ -38,6 +46,13 @@ else() endif() include(${QT_USE_FILE}) + + if(WIN32 AND EXISTS "${QT_QMAKE_EXECUTABLE}") + get_filename_component(_Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) + if(EXISTS "${_Qt_BIN_DIR}/QtCore4.dll") + set(Qt_BIN_DIR ${_Qt_BIN_DIR}) + endif() + endif() endif() set(SRCS @@ -91,6 +106,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES}) +if(Qt_BIN_DIR) + set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR}) +endif() if(APPLE) set_target_properties(cmake-gui PROPERTIES diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 2f26b0c..dbeeb07 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -12,10 +12,10 @@ #include "cmCommandArgumentParserHelper.h" #include "cmSystemTools.h" -#include "cmCommandArgumentLexer.h" - #include "cmMakefile.h" +#include "cmCommandArgumentLexer.h" + int cmCommandArgument_yyparse( yyscan_t yyscanner ); // cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index 9c1795e..cc35f84 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -12,10 +12,10 @@ #include "cmExprParserHelper.h" #include "cmSystemTools.h" -#include "cmExprLexer.h" - #include "cmMakefile.h" +#include "cmExprLexer.h" + int cmExpr_yyparse( yyscan_t yyscanner ); // cmExprParserHelper::cmExprParserHelper() diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index a619cec..e1fb8f1 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -126,6 +126,9 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator> commaTokens; std::vector<cmGeneratorExpressionToken>::const_iterator colonToken; + + bool emptyParamTermination = false; + if (this->it != this->Tokens.end() && this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) { @@ -133,6 +136,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( parameters.resize(parameters.size() + 1); assert(this->it != this->Tokens.end()); ++this->it; + if(this->it == this->Tokens.end()) + { + emptyParamTermination = true; + } while (this->it != this->Tokens.end() && this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) @@ -141,6 +148,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( parameters.resize(parameters.size() + 1); assert(this->it != this->Tokens.end()); ++this->it; + if(this->it == this->Tokens.end()) + { + emptyParamTermination = true; + } } while (this->it != this->Tokens.end() && this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) @@ -164,6 +175,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( parameters.resize(parameters.size() + 1); assert(this->it != this->Tokens.end()); ++this->it; + if(this->it == this->Tokens.end()) + { + emptyParamTermination = true; + } } while (this->it != this->Tokens.end() && this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) @@ -203,7 +218,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( assert(parameters.size() > commaTokens.size()); for ( ; pit != pend; ++pit, ++commaIt) { - extendResult(result, *pit); + if (!pit->empty() && !emptyParamTermination) + { + extendResult(result, *pit); + } if (commaIt != commaTokens.end()) { extendText(result, *commaIt); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0837f99..b2a337c 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -30,17 +30,17 @@ public: if(!strcmp(name, vs10Win32generatorName)) { return new cmGlobalVisualStudio10Generator( - vs10Win32generatorName, NULL, NULL); + name, NULL, NULL); } if(!strcmp(name, vs10Win64generatorName)) { return new cmGlobalVisualStudio10Generator( - vs10Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + name, "x64", "CMAKE_FORCE_WIN64"); } if(!strcmp(name, vs10IA64generatorName)) { return new cmGlobalVisualStudio10Generator( - vs10IA64generatorName, "Itanium", "CMAKE_FORCE_IA64"); + name, "Itanium", "CMAKE_FORCE_IA64"); } return 0; } @@ -69,9 +69,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const char* name, const char* architectureId, + const char* name, const char* platformName, const char* additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, architectureId, + : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; @@ -79,6 +79,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;" "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); + this->MasmEnabled = false; } //---------------------------------------------------------------------------- @@ -161,13 +162,23 @@ void cmGlobalVisualStudio10Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) { - if(this->ArchitectureId == "Itanium" || this->ArchitectureId == "x64") + if(this->PlatformName == "Itanium" || this->PlatformName == "x64") { if(this->IsExpressEdition() && !this->Find64BitTools(mf)) { return; } } + + for(std::vector<std::string>::const_iterator it = lang.begin(); + it != lang.end(); ++it) + { + if(*it == "ASM_MASM") + { + this->MasmEnabled = true; + } + } + cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index dbe6044..0a95091 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -25,7 +25,7 @@ class cmGlobalVisualStudio10Generator : { public: cmGlobalVisualStudio10Generator(const char* name, - const char* architectureId, const char* additionalPlatformDefinition); + const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); virtual bool SetGeneratorToolset(std::string const& ts); @@ -54,6 +54,9 @@ public: /** Is the installed VS an Express edition? */ bool IsExpressEdition() const { return this->ExpressEdition; } + /** Is the Microsoft Assembler enabled? */ + bool IsMasmEnabled() const { return this->MasmEnabled; } + /** The toolset name for the target platform. */ const char* GetPlatformToolset(); @@ -83,6 +86,7 @@ protected: std::string PlatformToolset; bool ExpressEdition; + bool MasmEnabled; bool UseFolderProperty(); diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 624d01d..8ae7331 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -13,31 +13,56 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs11Win32generatorName[] = "Visual Studio 11"; -static const char vs11Win64generatorName[] = "Visual Studio 11 Win64"; -static const char vs11ARMgeneratorName[] = "Visual Studio 11 ARM"; +static const char vs11generatorName[] = "Visual Studio 11"; class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs11Win32generatorName)) + if(strstr(name, vs11generatorName) != name) + { + return 0; + } + + const char* p = name + sizeof(vs11generatorName) - 1; + if(p[0] == '\0') { return new cmGlobalVisualStudio11Generator( - vs11Win32generatorName, NULL, NULL); + name, NULL, NULL); + } + + if(p[0] != ' ') + { + return 0; } - if(!strcmp(name, vs11Win64generatorName)) + + ++p; + + if(!strcmp(p, "ARM")) { return new cmGlobalVisualStudio11Generator( - vs11Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + name, "ARM", NULL); } - if(!strcmp(name, vs11ARMgeneratorName)) + + if(!strcmp(p, "Win64")) { return new cmGlobalVisualStudio11Generator( - vs11ARMgeneratorName, "ARM", NULL); + name, "x64", "CMAKE_FORCE_WIN64"); } - return 0; + + std::set<std::string> installedSDKs = + cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs(); + + if(installedSDKs.find(p) == installedSDKs.end()) + { + return 0; + } + + cmGlobalVisualStudio11Generator* ret = + new cmGlobalVisualStudio11Generator(name, p, NULL); + ret->WindowsCEVersion = "8.00"; + return ret; } virtual void GetDocumentation(cmDocumentationEntry& entry) const { @@ -51,9 +76,18 @@ public: } virtual void GetGenerators(std::vector<std::string>& names) const { - names.push_back(vs11Win32generatorName); - names.push_back(vs11Win64generatorName); - names.push_back(vs11ARMgeneratorName); } + names.push_back(vs11generatorName); + names.push_back(vs11generatorName + std::string(" ARM")); + names.push_back(vs11generatorName + std::string(" Win64")); + + std::set<std::string> installedSDKs = + cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs(); + for(std::set<std::string>::const_iterator i = + installedSDKs.begin(); i != installedSDKs.end(); ++i) + { + names.push_back("Visual Studio 11 " + *i); + } + } }; //---------------------------------------------------------------------------- @@ -64,9 +98,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( - const char* name, const char* architectureId, + const char* name, const char* platformName, const char* additionalPlatformDefinition) - : cmGlobalVisualStudio10Generator(name, architectureId, + : cmGlobalVisualStudio10Generator(name, platformName, additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; @@ -109,3 +143,36 @@ bool cmGlobalVisualStudio11Generator::UseFolderProperty() // Express editions in VS10 and earlier, but they are in VS11 Express. return cmGlobalVisualStudio8Generator::UseFolderProperty(); } + +//---------------------------------------------------------------------------- +std::set<std::string> +cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs() +{ + const char sdksKey[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "Windows CE Tools\\SDKs"; + + std::vector<std::string> subkeys; + cmSystemTools::GetRegistrySubKeys(sdksKey, subkeys, + cmSystemTools::KeyWOW64_32); + + std::set<std::string> ret; + for(std::vector<std::string>::const_iterator i = + subkeys.begin(); i != subkeys.end(); ++i) + { + std::string key = sdksKey; + key += '\\'; + key += *i; + key += ';'; + + std::string path; + if(cmSystemTools::ReadRegistryValue(key.c_str(), + path, + cmSystemTools::KeyWOW64_32) && + !path.empty()) + { + ret.insert(*i); + } + } + + return ret; +} diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 174f1cc..7cc7e69 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -21,7 +21,7 @@ class cmGlobalVisualStudio11Generator: { public: cmGlobalVisualStudio11Generator(const char* name, - const char* architectureId, const char* additionalPlatformDefinition); + const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); virtual void WriteSLNHeader(std::ostream& fout); @@ -34,7 +34,9 @@ public: protected: virtual const char* GetIDEVersion() { return "11.0"; } bool UseFolderProperty(); + static std::set<std::string> GetInstalledWindowsCESDKs(); private: class Factory; + friend class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index d77b84d..c56dfff 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -25,17 +25,17 @@ public: if(!strcmp(name, vs12Win32generatorName)) { return new cmGlobalVisualStudio12Generator( - vs12Win32generatorName, NULL, NULL); + name, NULL, NULL); } if(!strcmp(name, vs12Win64generatorName)) { return new cmGlobalVisualStudio12Generator( - vs12Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + name, "x64", "CMAKE_FORCE_WIN64"); } if(!strcmp(name, vs12ARMgeneratorName)) { return new cmGlobalVisualStudio12Generator( - vs12ARMgeneratorName, "ARM", NULL); + name, "ARM", NULL); } return 0; } @@ -64,9 +64,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( - const char* name, const char* architectureId, + const char* name, const char* platformName, const char* additionalPlatformDefinition) - : cmGlobalVisualStudio11Generator(name, architectureId, + : cmGlobalVisualStudio11Generator(name, platformName, additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS12FindMake.cmake"; @@ -100,12 +100,3 @@ cmLocalGenerator *cmGlobalVisualStudio12Generator::CreateLocalGenerator() lg->SetGlobalGenerator(this); return lg; } - -//---------------------------------------------------------------------------- -bool cmGlobalVisualStudio12Generator::UseFolderProperty() -{ - // Intentionally skip over the parent class implementation and call the - // grand-parent class's implementation. Folders are not supported by the - // Express editions in VS10 and earlier, but they are in VS12 Express. - return cmGlobalVisualStudio8Generator::UseFolderProperty(); -} diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 5844ee0..064e310 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -21,7 +21,7 @@ class cmGlobalVisualStudio12Generator: { public: cmGlobalVisualStudio12Generator(const char* name, - const char* architectureId, const char* additionalPlatformDefinition); + const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); virtual void WriteSLNHeader(std::ostream& fout); @@ -33,7 +33,6 @@ public: virtual std::string GetUserMacrosDirectory() { return ""; } protected: virtual const char* GetIDEVersion() { return "12.0"; } - bool UseFolderProperty(); private: class Factory; }; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 2494f55..51efc46 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -16,7 +16,8 @@ #include "cmake.h" //---------------------------------------------------------------------------- -cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() +cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( + const char* platformName) : cmGlobalVisualStudio7Generator(platformName) { this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfiguration"; @@ -281,20 +282,20 @@ void cmGlobalVisualStudio71Generator const std::set<std::string>& configsPartOfDefaultBuild, const char* platformMapping) { + const char* platformName = + platformMapping ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|" - << (platformMapping ? platformMapping : "Win32") << std::endl; + << ".ActiveCfg = " << *i << "|" << platformName << std::endl; std::set<std::string>::const_iterator ci = configsPartOfDefaultBuild.find(*i); if(!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|" - << (platformMapping ? platformMapping : "Win32") << std::endl; + << ".Build.0 = " << *i << "|" << platformName << std::endl; } } } diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 6d91f97..e136db7 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -23,7 +23,7 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator { public: - cmGlobalVisualStudio71Generator(); + cmGlobalVisualStudio71Generator(const char* platformName = NULL); static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory <cmGlobalVisualStudio71Generator>(); } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 9a34ecf..b475665 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -17,9 +17,16 @@ #include "cmMakefile.h" #include "cmake.h" -cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() +cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( + const char* platformName) { this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; + + if (!platformName) + { + platformName = "Win32"; + } + this->PlatformName = platformName; } @@ -144,6 +151,13 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() return lg; } +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); + mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); +} + void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) { // process the configurations @@ -601,20 +615,20 @@ void cmGlobalVisualStudio7Generator const std::set<std::string>& configsPartOfDefaultBuild, const char* platformMapping) { + const char* platformName = + platformMapping ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|" - << (platformMapping ? platformMapping : "Win32") << "\n"; + << ".ActiveCfg = " << *i << "|" << platformName << "\n"; std::set<std::string>::const_iterator ci = configsPartOfDefaultBuild.find(*i); if(!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|" - << (platformMapping ? platformMapping : "Win32") << "\n"; + << ".Build.0 = " << *i << "|" << platformName << "\n"; } } } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 3ebb408..4d22cff 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -26,7 +26,7 @@ struct cmIDEFlagTable; class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: - cmGlobalVisualStudio7Generator(); + cmGlobalVisualStudio7Generator(const char* platformName = NULL); static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory <cmGlobalVisualStudio7Generator>(); } @@ -36,9 +36,14 @@ public: return cmGlobalVisualStudio7Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 7";} + ///! Get the name for the platform. + const char* GetPlatformName() const { return this->PlatformName.c_str(); } + ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + virtual void AddPlatformDefinitions(cmMakefile* mf); + /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -153,6 +158,7 @@ protected: // Set during OutputSLNFile with the name of the current project. // There is one SLN file per project. std::string CurrentProject; + std::string PlatformName; }; #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 864e8db..e4244e0 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -57,8 +57,7 @@ public: } cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( - name, parser.GetArchitectureFamily(), NULL); - ret->PlatformName = p; + name, p, NULL); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -96,16 +95,14 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( - const char* name, const char* architectureId, + const char* name, const char* platformName, const char* additionalPlatformDefinition) + : cmGlobalVisualStudio71Generator(platformName) { this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; - if (architectureId) - { - this->ArchitectureId = architectureId; - } + if (additionalPlatformDefinition) { this->AdditionalPlatformDefinition = additionalPlatformDefinition; @@ -113,20 +110,6 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( } //---------------------------------------------------------------------------- -const char* cmGlobalVisualStudio8Generator::GetPlatformName() const -{ - if (!this->PlatformName.empty()) - { - return this->PlatformName.c_str(); - } - if (this->ArchitectureId == "X86") - { - return "Win32"; - } - return this->ArchitectureId.c_str(); -} - -//---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { @@ -142,7 +125,6 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) { cmGlobalVisualStudio71Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); if(this->TargetsWindowsCE()) { diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index bcbd7a0..d181742 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -24,14 +24,12 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: cmGlobalVisualStudio8Generator(const char* name, - const char* architectureId, const char* additionalPlatformDefinition); + const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. virtual const char* GetName() const {return this->Name.c_str();} - const char* GetPlatformName() const; - /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -87,7 +85,6 @@ protected: const char* path, cmTarget &t); std::string Name; - std::string PlatformName; std::string WindowsCEVersion; private: diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 2082384..fba6ed1 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -62,8 +62,7 @@ public: } cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator( - name, parser.GetArchitectureFamily(), NULL); - ret->PlatformName = p; + name, p, NULL); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -102,9 +101,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( - const char* name, const char* architectureId, + const char* name, const char* platformName, const char* additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, architectureId, + : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 1310a93..202aa8d 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -25,7 +25,7 @@ class cmGlobalVisualStudio9Generator : { public: cmGlobalVisualStudio9Generator(const char* name, - const char* architectureId, const char* additionalPlatformDefinition); + const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index f4be0ce..5931016 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -21,7 +21,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { - this->ArchitectureId = "X86"; this->AdditionalPlatformDefinition = NULL; } @@ -499,9 +498,6 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId.c_str()); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId.c_str()); - if(this->AdditionalPlatformDefinition) { mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 9d81170..b665158 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -104,7 +104,6 @@ protected: std::string GetUtilityDepend(cmTarget* target); typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; - std::string ArchitectureId; const char* AdditionalPlatformDefinition; private: diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b515727..9c04109 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1038,20 +1038,11 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, // If this is the compiler then look for the extra variable // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; - const char* compilerTarget = 0; - const char* compilerOptionTarget = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); - compilerTarget - = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str()); - compilerOptionTarget - = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTION_TARGET").c_str()); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -1072,11 +1063,6 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, ret += " "; ret += compilerArg1; } - if (compilerTarget && compilerOptionTarget) - { - ret += compilerOptionTarget; - ret += compilerTarget; - } return ret; } return replace; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 667d86f..e5b4057 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -573,22 +573,20 @@ cmLocalVisualStudio6Generator // Add the rule with the given dependencies and commands. const char* no_main_dependency = 0; - this->Makefile->AddCustomCommandToOutput(output, - depends, - no_main_dependency, - origCommand.GetCommandLines(), - comment.c_str(), - origCommand.GetWorkingDirectory()); + if(cmSourceFile* outsf = + this->Makefile->AddCustomCommandToOutput( + output, depends, no_main_dependency, + origCommand.GetCommandLines(), comment.c_str(), + origCommand.GetWorkingDirectory())) + { + target.AddSourceFile(outsf); + } // Replace the dependencies with the output of this rule so that the // next rule added will run after this one. depends.clear(); depends.push_back(output); - // Add a source file representing this output to the project. - cmSourceFile* outsf = this->Makefile->GetSourceFileWithOutput(output); - target.AddSourceFile(outsf); - // Free the fake output name. delete [] output; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 672edf4..58cc6f4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -146,11 +146,10 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force += "/"; force += tgt.GetName(); force += "_force"; - this->Makefile->AddCustomCommandToOutput(force.c_str(), no_depends, - no_main_dependency, - force_commands, " ", 0, true); if(cmSourceFile* file = - this->Makefile->GetSourceFileWithOutput(force.c_str())) + this->Makefile->AddCustomCommandToOutput( + force.c_str(), no_depends, no_main_dependency, + force_commands, " ", 0, true)) { tgt.AddSourceFile(file); } @@ -920,7 +919,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } this->OutputTargetRules(fout, configName, target, libName); - this->OutputBuildTool(fout, configName, target, targetOptions.IsDebug()); + this->OutputBuildTool(fout, configName, target, targetOptions); fout << "\t\t</Configuration>\n"; } @@ -941,9 +940,7 @@ cmLocalVisualStudio7Generator } void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, - const char* configName, - cmTarget &target, - bool isDebug) + const char* configName, cmTarget &target, const Options& targetOptions) { cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); @@ -1111,7 +1108,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, temp += targetNamePDB; fout << "\t\t\t\tProgramDatabaseFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; - if(isDebug) + if(targetOptions.IsDebug()) { fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"; } @@ -1209,7 +1206,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" << targetNamePDB << "\"\n"; - if(isDebug) + if(targetOptions.IsDebug()) { fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"; } @@ -1223,9 +1220,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, { fout << "\t\t\t\tSubSystem=\"8\"\n"; } - fout << "\t\t\t\tEntryPointSymbol=\"" - << (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup") - << "\"\n"; + + if(!linkOptions.GetFlag("EntryPointSymbol")) + { + const char* entryPointSymbol = targetOptions.UsingUnicode() ? + (isWin32Executable ? "wWinMainCRTStartup" : "mainWCRTStartup") : + (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup"); + fout << "\t\t\t\tEntryPointSymbol=\"" << entryPointSymbol << "\"\n"; + } } else if ( this->FortranProject ) { diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d9e2ef0..92e4d3c 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -90,7 +90,7 @@ private: void OutputTargetRules(std::ostream& fout, const char* configName, cmTarget &target, const char *libName); void OutputBuildTool(std::ostream& fout, const char* configName, - cmTarget& t, bool debug); + cmTarget& t, const Options& targetOptions); void OutputLibraryDirectories(std::ostream& fout, std::vector<std::string> const& dirs); void WriteProjectSCC(std::ostream& fout, cmTarget& target); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c4859b6..57b86fd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -150,6 +150,7 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->Initialize(); this->CheckSystemVars = mf.CheckSystemVars; this->ListFileStack = mf.ListFileStack; + this->OutputToSource = mf.OutputToSource; } //---------------------------------------------------------------------------- @@ -1010,11 +1011,32 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeAllowMakeVars(true); file->SetCustomCommand(cc); + this->UpdateOutputToSourceMap(outputs, file); } return file; } //---------------------------------------------------------------------------- +void +cmMakefile::UpdateOutputToSourceMap(std::vector<std::string> const& outputs, + cmSourceFile* source) +{ + for(std::vector<std::string>::const_iterator o = outputs.begin(); + o != outputs.end(); ++o) + { + this->UpdateOutputToSourceMap(*o, source); + } +} + +//---------------------------------------------------------------------------- +void +cmMakefile::UpdateOutputToSourceMap(std::string const& output, + cmSourceFile* source) +{ + this->OutputToSource[output] = source; +} + +//---------------------------------------------------------------------------- cmSourceFile* cmMakefile::AddCustomCommandToOutput(const char* output, const std::vector<std::string>& depends, @@ -1994,7 +2016,7 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) return &it->second; } -cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) +cmSourceFile *cmMakefile::LinearGetSourceFileWithOutput(const char *cname) { std::string name = cname; std::string out; @@ -2030,6 +2052,25 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) return 0; } +cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) +{ + std::string name = cname; + + // If the queried path is not absolute we use the backward compatible + // linear-time search for an output with a matching suffix. + if(!cmSystemTools::FileIsFullPath(cname)) + { + return LinearGetSourceFileWithOutput(cname); + } + // Otherwise we use an efficient lookup map. + OutputToSourceMap::iterator o = this->OutputToSource.find(name); + if (o != this->OutputToSource.end()) + { + return (*o).second; + } + return 0; +} + #if defined(CMAKE_BUILD_WITH_CMAKE) cmSourceGroup* cmMakefile::GetSourceGroup(const std::vector<std::string>&name) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 711a208..8bce9fd 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -29,6 +29,9 @@ #include <cmsys/auto_ptr.hxx> #include <cmsys/RegularExpression.hxx> +#if defined(CMAKE_BUILD_WITH_CMAKE) +# include <cmsys/hash_map.hxx> +#endif class cmFunctionBlocker; class cmCommand; @@ -1039,6 +1042,26 @@ private: bool GeneratingBuildSystem; + /** + * Old version of GetSourceFileWithOutput(const char*) kept for + * backward-compatibility. It implements a linear search and support + * relative file paths. It is used as a fall back by + * GetSourceFileWithOutput(const char*). + */ + cmSourceFile *LinearGetSourceFileWithOutput(const char *cname); + + // A map for fast output to input look up. +#if defined(CMAKE_BUILD_WITH_CMAKE) + typedef cmsys::hash_map<std::string, cmSourceFile*> OutputToSourceMap; +#else + typedef std::map<std::string, cmSourceFile*> OutputToSourceMap; +#endif + OutputToSourceMap OutputToSource; + + void UpdateOutputToSourceMap(std::vector<std::string> const& outputs, + cmSourceFile* source); + void UpdateOutputToSourceMap(std::string const& output, + cmSourceFile* source); }; //---------------------------------------------------------------------------- diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 0ba673e..a823f05 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -543,7 +543,7 @@ cmPolicies::cmPolicies() "the INCLUDE_DIRECTORIES target property. " "The NEW behavior for this policy is to issue a FATAL_ERROR if " "INCLUDE_DIRECTORIES contains a relative path.", - 2,8,11,20130516, cmPolicies::WARN); + 2,8,12,0, cmPolicies::WARN); this->DefinePolicy( CMP0022, "CMP0022", @@ -574,7 +574,7 @@ cmPolicies::cmPolicies() "The NEW behavior for this policy is to use the INTERFACE_LINK_LIBRARIES " "property for in-build targets, and ignore the old properties matching " "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?.", - 2,8,11,20130516, cmPolicies::WARN); + 2,8,12,0, cmPolicies::WARN); this->DefinePolicy( CMP0023, "CMP0023", @@ -600,7 +600,7 @@ cmPolicies::cmPolicies() "target_link_libraries signatures to be mixed. " "The NEW behavior for this policy is to not to allow mixing of the " "keyword and plain signatures.", - 2,8,11,20130724, cmPolicies::WARN); + 2,8,12,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index 3905e9b..8ad6fce 100644 --- a/Source/cmVariableWatch.cxx +++ b/Source/cmVariableWatch.cxx @@ -37,37 +37,63 @@ cmVariableWatch::cmVariableWatch() cmVariableWatch::~cmVariableWatch() { + cmVariableWatch::StringToVectorOfPairs::iterator svp_it; + + for ( svp_it = this->WatchMap.begin(); + svp_it != this->WatchMap.end(); ++svp_it ) + { + cmVariableWatch::VectorOfPairs::iterator p_it; + + for ( p_it = svp_it->second.begin(); + p_it != svp_it->second.end(); ++p_it ) + { + delete *p_it; + } + } } -void cmVariableWatch::AddWatch(const std::string& variable, - WatchMethod method, void* client_data /*=0*/) +bool cmVariableWatch::AddWatch(const std::string& variable, + WatchMethod method, void* client_data /*=0*/, + DeleteData delete_data /*=0*/) { - cmVariableWatch::Pair p; - p.Method = method; - p.ClientData = client_data; + cmVariableWatch::Pair* p = new cmVariableWatch::Pair; + p->Method = method; + p->ClientData = client_data; + p->DeleteDataCall = delete_data; cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable]; cmVariableWatch::VectorOfPairs::size_type cc; for ( cc = 0; cc < vp->size(); cc ++ ) { - cmVariableWatch::Pair* pair = &(*vp)[cc]; - if ( pair->Method == method ) + cmVariableWatch::Pair* pair = (*vp)[cc]; + if ( pair->Method == method && + client_data && client_data == pair->ClientData) { - (*vp)[cc] = p; - return; + // Callback already exists + return false; } } vp->push_back(p); + return true; } void cmVariableWatch::RemoveWatch(const std::string& variable, - WatchMethod method) + WatchMethod method, + void* client_data /*=0*/) { + if ( !this->WatchMap.count(variable) ) + { + return; + } cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable]; cmVariableWatch::VectorOfPairs::iterator it; for ( it = vp->begin(); it != vp->end(); ++it ) { - if ( it->Method == method ) + if ( (*it)->Method == method && + // If client_data is NULL, we want to disconnect all watches against + // the given method; otherwise match ClientData as well. + (!client_data || (client_data == (*it)->ClientData))) { + delete *it; vp->erase(it); return; } @@ -87,7 +113,7 @@ void cmVariableWatch::VariableAccessed(const std::string& variable, cmVariableWatch::VectorOfPairs::const_iterator it; for ( it = vp->begin(); it != vp->end(); it ++ ) { - it->Method(variable, access_type, it->ClientData, + (*it)->Method(variable, access_type, (*it)->ClientData, newValue, mf); } } diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 7dd4ac5..790c75a 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -26,6 +26,7 @@ class cmVariableWatch public: typedef void (*WatchMethod)(const std::string& variable, int access_type, void* client_data, const char* newValue, const cmMakefile* mf); + typedef void (*DeleteData)(void* client_data); cmVariableWatch(); ~cmVariableWatch(); @@ -33,9 +34,10 @@ public: /** * Add watch to the variable */ - void AddWatch(const std::string& variable, WatchMethod method, - void* client_data=0); - void RemoveWatch(const std::string& variable, WatchMethod method); + bool AddWatch(const std::string& variable, WatchMethod method, + void* client_data=0, DeleteData delete_data=0); + void RemoveWatch(const std::string& variable, WatchMethod method, + void* client_data=0); /** * This method is called when variable is accessed @@ -67,10 +69,18 @@ protected: { WatchMethod Method; void* ClientData; - Pair() : Method(0), ClientData(0) {} + DeleteData DeleteDataCall; + Pair() : Method(0), ClientData(0), DeleteDataCall(0) {} + ~Pair() + { + if (this->DeleteDataCall && this->ClientData) + { + this->DeleteDataCall(this->ClientData); + } + } }; - typedef std::vector< Pair > VectorOfPairs; + typedef std::vector< Pair* > VectorOfPairs; typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs; StringToVectorOfPairs WatchMap; diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 70c6524..33e159b 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -14,63 +14,27 @@ #include "cmVariableWatch.h" //---------------------------------------------------------------------------- -static void cmVariableWatchCommandVariableAccessed( - const std::string& variable, int access_type, void* client_data, - const char* newValue, const cmMakefile* mf) +struct cmVariableWatchCallbackData { - cmVariableWatchCommand* command - = static_cast<cmVariableWatchCommand*>(client_data); - command->VariableAccessed(variable, access_type, newValue, mf); -} + bool InCallback; + std::string Command; +}; //---------------------------------------------------------------------------- -cmVariableWatchCommand::cmVariableWatchCommand() +static void cmVariableWatchCommandVariableAccessed( + const std::string& variable, int access_type, void* client_data, + const char* newValue, const cmMakefile* mf) { - this->InCallback = false; -} + cmVariableWatchCallbackData* data + = static_cast<cmVariableWatchCallbackData*>(client_data); -//---------------------------------------------------------------------------- -bool cmVariableWatchCommand -::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) -{ - if ( args.size() < 1 ) - { - this->SetError("must be called with at least one argument."); - return false; - } - std::string variable = args[0]; - if ( args.size() > 1 ) - { - std::string command = args[1]; - this->Handlers[variable].Commands.push_back(args[1]); - } - if ( variable == "CMAKE_CURRENT_LIST_FILE" ) - { - cmOStringStream ostr; - ostr << "cannot be set on the variable: " << variable.c_str(); - this->SetError(ostr.str().c_str()); - return false; - } - - this->Makefile->GetCMakeInstance()->GetVariableWatch()->AddWatch( - variable, cmVariableWatchCommandVariableAccessed, this); - - return true; -} - -//---------------------------------------------------------------------------- -void cmVariableWatchCommand::VariableAccessed(const std::string& variable, - int access_type, const char* newValue, const cmMakefile* mf) -{ - if ( this->InCallback ) + if ( data->InCallback ) { return; } - this->InCallback = true; + data->InCallback = true; cmListFileFunction newLFF; - cmVariableWatchCommandHandler *handler = &this->Handlers[variable]; - cmVariableWatchCommandHandler::VectorOfCommands::iterator it; cmListFileArgument arg; bool processed = false; const char* accessString = cmVariableWatch::GetAccessAsString(access_type); @@ -80,10 +44,8 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable, cmMakefile* makefile = const_cast<cmMakefile*>(mf); std::string stack = makefile->GetProperty("LISTFILE_STACK"); - for ( it = handler->Commands.begin(); it != handler->Commands.end(); - ++ it ) + if ( !data->Command.empty() ) { - std::string command = *it; newLFF.Arguments.clear(); newLFF.Arguments.push_back( cmListFileArgument(variable, cmListFileArgument::Quoted, @@ -100,7 +62,7 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable, newLFF.Arguments.push_back( cmListFileArgument(stack, cmListFileArgument::Quoted, "unknown", 9999)); - newLFF.Name = command; + newLFF.Name = data->Command; newLFF.FilePath = "Some weird path"; newLFF.Line = 9999; cmExecutionStatus status; @@ -111,10 +73,10 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable, cmOStringStream error; error << "Error in cmake code at\n" << arg.FilePath << ":" << arg.Line << ":\n" - << "A command failed during the invocation of callback\"" - << command << "\"."; + << "A command failed during the invocation of callback \"" + << data->Command << "\"."; cmSystemTools::Error(error.str().c_str()); - this->InCallback = false; + data->InCallback = false; return; } processed = true; @@ -123,8 +85,75 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable, { cmOStringStream msg; msg << "Variable \"" << variable.c_str() << "\" was accessed using " - << accessString << " with value \"" << newValue << "\"."; + << accessString << " with value \"" << (newValue?newValue:"") << "\"."; makefile->IssueMessage(cmake::LOG, msg.str()); } - this->InCallback = false; + + data->InCallback = false; +} + +//---------------------------------------------------------------------------- +static void deleteVariableWatchCallbackData(void* client_data) +{ + cmVariableWatchCallbackData* data + = static_cast<cmVariableWatchCallbackData*>(client_data); + delete data; +} + +//---------------------------------------------------------------------------- +cmVariableWatchCommand::cmVariableWatchCommand() +{ +} + +//---------------------------------------------------------------------------- +cmVariableWatchCommand::~cmVariableWatchCommand() +{ + std::set<std::string>::const_iterator it; + for ( it = this->WatchedVariables.begin(); + it != this->WatchedVariables.end(); + ++it ) + { + this->Makefile->GetCMakeInstance()->GetVariableWatch()->RemoveWatch( + *it, cmVariableWatchCommandVariableAccessed); + } +} + +//---------------------------------------------------------------------------- +bool cmVariableWatchCommand +::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) +{ + if ( args.size() < 1 ) + { + this->SetError("must be called with at least one argument."); + return false; + } + std::string variable = args[0]; + std::string command; + if ( args.size() > 1 ) + { + command = args[1]; + } + if ( variable == "CMAKE_CURRENT_LIST_FILE" ) + { + cmOStringStream ostr; + ostr << "cannot be set on the variable: " << variable.c_str(); + this->SetError(ostr.str().c_str()); + return false; + } + + cmVariableWatchCallbackData* data = new cmVariableWatchCallbackData; + + data->InCallback = false; + data->Command = command; + + this->WatchedVariables.insert(variable); + if ( !this->Makefile->GetCMakeInstance()->GetVariableWatch()->AddWatch( + variable, cmVariableWatchCommandVariableAccessed, + data, deleteVariableWatchCallbackData) ) + { + deleteVariableWatchCallbackData(data); + return false; + } + + return true; } diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h index 3abc088..545535c 100644 --- a/Source/cmVariableWatchCommand.h +++ b/Source/cmVariableWatchCommand.h @@ -14,13 +14,6 @@ #include "cmCommand.h" -class cmVariableWatchCommandHandler -{ -public: - typedef std::vector<std::string> VectorOfCommands; - VectorOfCommands Commands; -}; - /** \class cmVariableWatchCommand * \brief Watch when the variable changes and invoke command * @@ -39,6 +32,9 @@ public: //! Default constructor cmVariableWatchCommand(); + //! Destructor. + ~cmVariableWatchCommand(); + /** * This is called when the command is first encountered in * the CMakeLists.txt file. @@ -83,13 +79,8 @@ public: cmTypeMacro(cmVariableWatchCommand, cmCommand); - void VariableAccessed(const std::string& variable, int access_type, - const char* newValue, const cmMakefile* mf); - protected: - std::map<std::string, cmVariableWatchCommandHandler> Handlers; - - bool InCallback; + std::set<std::string> WatchedVariables; }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 937509e..ea05347 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -307,6 +307,11 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1); this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1); + if (this->GlobalGenerator->IsMasmEnabled()) + { + this->WriteString("<Import Project=\"$(VCTargetsPath)\\" + "BuildCustomizations\\masm.props\" />\n", 2); + } this->WriteString("</ImportGroup>\n", 1); this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1); this->WriteString("<Import Project=\"" VS10_USER_PROPS "\"" @@ -326,6 +331,11 @@ void cmVisualStudio10TargetGenerator::Generate() "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\"" " />\n", 1); this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1); + if (this->GlobalGenerator->IsMasmEnabled()) + { + this->WriteString("<Import Project=\"$(VCTargetsPath)\\" + "BuildCustomizations\\masm.targets\" />\n", 2); + } this->WriteString("</ImportGroup>\n", 1); this->WriteString("</Project>", 0); // The groups are stored in a separate file for VS 10 @@ -982,24 +992,37 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() si != this->GeneratorTarget->ObjectSources.end(); ++si) { const char* lang = (*si)->GetLanguage(); - bool cl = strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0; - bool rc = strcmp(lang, "RC") == 0; - const char* tool = cl? "ClCompile" : (rc? "ResourceCompile" : "None"); - this->WriteSource(tool, *si, " "); - // ouput any flags specific to this source file - if(cl && this->OutputSourceSpecificFlags(*si)) + const char* tool = NULL; + if (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0) + { + tool = "ClCompile"; + } + else if (strcmp(lang, "ASM_MASM") == 0 && + this->GlobalGenerator->IsMasmEnabled()) + { + tool = "MASM"; + } + else if (strcmp(lang, "RC") == 0) { - // if the source file has specific flags the tag - // is ended on a new line - this->WriteString("</ClCompile>\n", 2); + tool = "ResourceCompile"; } - else if(rc && this->OutputSourceSpecificFlags(*si)) + + if (tool) { - this->WriteString("</ResourceCompile>\n", 2); + this->WriteSource(tool, *si, " "); + if (this->OutputSourceSpecificFlags(*si)) + { + this->WriteString("</", 2); + (*this->BuildFileStream ) << tool << ">\n"; + } + else + { + (*this->BuildFileStream ) << " />\n"; + } } else { - (*this->BuildFileStream ) << " />\n"; + this->WriteSource("None", *si); } } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index f4df1a9..6aca787 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -100,13 +100,13 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose) } } -bool cmVisualStudioGeneratorOptions::IsDebug() +bool cmVisualStudioGeneratorOptions::IsDebug() const { return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end(); } //---------------------------------------------------------------------------- -bool cmVisualStudioGeneratorOptions::UsingUnicode() +bool cmVisualStudioGeneratorOptions::UsingUnicode() const { // Look for the a _UNICODE definition. for(std::vector<std::string>::const_iterator di = this->Defines.begin(); @@ -120,7 +120,7 @@ bool cmVisualStudioGeneratorOptions::UsingUnicode() return false; } //---------------------------------------------------------------------------- -bool cmVisualStudioGeneratorOptions::UsingSBCS() +bool cmVisualStudioGeneratorOptions::UsingSBCS() const { // Look for the a _SBCS definition. for(std::vector<std::string>::const_iterator di = this->Defines.begin(); diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index a1a55da..90f7667 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -47,10 +47,10 @@ public: void SetVerboseMakefile(bool verbose); // Check for specific options. - bool UsingUnicode(); - bool UsingSBCS(); + bool UsingUnicode() const; + bool UsingSBCS() const; - bool IsDebug(); + bool IsDebug() const; // Write options to output. void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index b302246..219a5eb 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -20,8 +20,12 @@ int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version) const std::string vckey = registryBase + "\\Setup\\VC;ProductDir"; const std::string vskey = registryBase + "\\Setup\\VS;ProductDir"; - if(!cmSystemTools::ReadRegistryValue(vckey.c_str(), this->VcInstallDir) || - !cmSystemTools::ReadRegistryValue(vskey.c_str(), this->VsInstallDir)) + if(!cmSystemTools::ReadRegistryValue(vckey.c_str(), + this->VcInstallDir, + cmSystemTools::KeyWOW64_32) || + !cmSystemTools::ReadRegistryValue(vskey.c_str(), + this->VsInstallDir, + cmSystemTools::KeyWOW64_32)) { return 0; } diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 6f0281d..0f27836 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -649,6 +649,68 @@ IF(KWSYS_USE_SystemInformation) SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1) ENDIF() + IF(UNIX) + INCLUDE(CheckIncludeFileCXX) + # check for simple stack trace + # usually it's in libc but on FreeBSD + # it's in libexecinfo + FIND_LIBRARY(EXECINFO_LIB "execinfo") + IF (NOT EXECINFO_LIB) + SET(EXECINFO_LIB "") + ENDIF() + CHECK_INCLUDE_FILE_CXX("execinfo.h" KWSYS_CXX_HAS_EXECINFOH) + IF (KWSYS_CXX_HAS_EXECINFOH) + # we have the backtrace header check if it + # can be used with this compiler + SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB}) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BACKTRACE + "Checking whether backtrace works with this C++ compiler" DIRECT) + SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES) + IF (KWSYS_CXX_HAS_BACKTRACE) + # backtrace is supported by this system and compiler. + # now check for the more advanced capabilities. + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE=1) + # check for symbol lookup using dladdr + CHECK_INCLUDE_FILE_CXX("dlfcn.h" KWSYS_CXX_HAS_DLFCNH) + IF (KWSYS_CXX_HAS_DLFCNH) + # we have symbol lookup libraries and headers + # check if they can be used with this compiler + SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${CMAKE_DL_LIBS}) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_DLADDR + "Checking whether dladdr works with this C++ compiler" DIRECT) + SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES) + IF (KWSYS_CXX_HAS_DLADDR) + # symbol lookup is supported by this system + # and compiler. + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP=1) + ENDIF() + ENDIF() + # c++ demangling support + # check for cxxabi headers + CHECK_INCLUDE_FILE_CXX("cxxabi.h" KWSYS_CXX_HAS_CXXABIH) + IF (KWSYS_CXX_HAS_CXXABIH) + # check if cxxabi can be used with this + # system and compiler. + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CXXABI + "Checking whether cxxabi works with this C++ compiler" DIRECT) + IF (KWSYS_CXX_HAS_CXXABI) + # c++ demangle using cxxabi is supported with + # this system and compiler + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE=1) + ENDIF() + ENDIF() + # basic backtrace works better with release build + # don't bother with advanced features for release + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS_DEBUG KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS_RELWITHDEBINFO KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1) + ENDIF() + ENDIF() + ENDIF() IF(BORLAND) KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM "Checking whether Borland CXX compiler supports assembler instructions" DIRECT) @@ -913,12 +975,23 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) ENDIF(UNIX) ENDIF(KWSYS_USE_DynamicLoader) - IF(KWSYS_USE_SystemInformation AND WIN32) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32) - IF(KWSYS_SYS_HAS_PSAPI) - TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} Psapi) + IF(KWSYS_USE_SystemInformation) + IF(WIN32) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32) + IF(KWSYS_SYS_HAS_PSAPI) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} Psapi) + ENDIF() + ELSEIF(UNIX) + IF (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE) + # backtrace on FreeBSD is not in libc + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${EXECINFO_LIB}) + ENDIF() + IF (KWSYS_CXX_HAS_DLADDR) + # for symbol lookup using dladdr + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) + ENDIF() ENDIF() - ENDIF(KWSYS_USE_SystemInformation AND WIN32) + ENDIF() # Apply user-defined target properties to the library. IF(KWSYS_PROPERTIES_CXX) diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 9db1dee..beefd7d 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -18,6 +18,10 @@ # include <winsock.h> // WSADATA, include before sys/types.h #endif +#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE) +# define _GNU_SOURCE +#endif + // TODO: // We need an alternative implementation for many functions in this file // when USE_ASM_INSTRUCTIONS gets defined as 0. @@ -114,8 +118,15 @@ typedef int siginfo_t; # define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN # endif # if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 >= 1050 -# include <execinfo.h> -# define KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE +# if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) +# include <execinfo.h> +# if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE) +# include <cxxabi.h> +# endif +# if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP) +# include <dlfcn.h> +# endif +# endif # endif #endif @@ -130,10 +141,13 @@ typedef int siginfo_t; # define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN # endif # endif -# if defined(__GNUC__) +# if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) # include <execinfo.h> -# if !(defined(__LSB_VERSION__) && __LSB_VERSION__ < 41) -# define KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE +# if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE) +# include <cxxabi.h> +# endif +# if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP) +# include <dlfcn.h> # endif # endif # if defined(KWSYS_CXX_HAS_RLIMIT64) @@ -357,6 +371,10 @@ public: static void SetStackTraceOnError(int enable); + // get current stack + static + kwsys_stl::string GetProgramStack(int firstFrame, int wholePath); + /** Run the different checks */ void RunCPUCheck(); void RunOSCheck(); @@ -812,6 +830,11 @@ void SystemInformation::SetStackTraceOnError(int enable) SystemInformationImplementation::SetStackTraceOnError(enable); } +kwsys_stl::string SystemInformation::GetProgramStack(int firstFrame, int wholePath) +{ + return SystemInformationImplementation::GetProgramStack(firstFrame, wholePath); +} + /** Run the different checks */ void SystemInformation::RunCPUCheck() { @@ -908,6 +931,12 @@ int LoadLines( } continue; } + char *pBuf=buf; + while(*pBuf) + { + if (*pBuf=='\n') *pBuf='\0'; + pBuf+=1; + } lines.push_back(buf); ++nRead; } @@ -1046,12 +1075,29 @@ void StacktraceSignalHandler( #if defined(__linux) || defined(__APPLE__) kwsys_ios::ostringstream oss; oss + << kwsys_ios::endl << "=========================================================" << kwsys_ios::endl << "Process id " << getpid() << " "; switch (sigNo) { + case SIGINT: + oss << "Caught SIGINT"; + break; + + case SIGTERM: + oss << "Caught SIGTERM"; + break; + + case SIGABRT: + oss << "Caught SIGABRT"; + break; + case SIGFPE: - oss << "Caught SIGFPE "; + oss + << "Caught SIGFPE at " + << (sigInfo->si_addr==0?"0x":"") + << sigInfo->si_addr + << " "; switch (sigInfo->si_code) { # if defined(FPE_INTDIV) @@ -1099,7 +1145,11 @@ void StacktraceSignalHandler( break; case SIGSEGV: - oss << "Caught SIGSEGV "; + oss + << "Caught SIGSEGV at " + << (sigInfo->si_addr==0?"0x":"") + << sigInfo->si_addr + << " "; switch (sigInfo->si_code) { case SEGV_MAPERR: @@ -1116,16 +1166,12 @@ void StacktraceSignalHandler( } break; - case SIGINT: - oss << "Caught SIGTERM"; - break; - - case SIGTERM: - oss << "Caught SIGTERM"; - break; - case SIGBUS: - oss << "Caught SIGBUS type "; + oss + << "Caught SIGBUS at " + << (sigInfo->si_addr==0?"0x":"") + << sigInfo->si_addr + << " "; switch (sigInfo->si_code) { case BUS_ADRALN: @@ -1134,13 +1180,25 @@ void StacktraceSignalHandler( # if defined(BUS_ADRERR) case BUS_ADRERR: - oss << "non-exestent physical address"; + oss << "nonexistent physical address"; break; # endif # if defined(BUS_OBJERR) case BUS_OBJERR: - oss << "object specific hardware error"; + oss << "object-specific hardware error"; + break; +# endif + +# if defined(BUS_MCEERR_AR) + case BUS_MCEERR_AR: + oss << "Hardware memory error consumed on a machine check; action required."; + break; +# endif + +# if defined(BUS_MCEERR_AO) + case BUS_MCEERR_AO: + oss << "Hardware memory error detected in process but not consumed; action optional."; break; # endif @@ -1151,7 +1209,11 @@ void StacktraceSignalHandler( break; case SIGILL: - oss << "Caught SIGILL "; + oss + << "Caught SIGILL at " + << (sigInfo->si_addr==0?"0x":"") + << sigInfo->si_addr + << " "; switch (sigInfo->si_code) { case ILL_ILLOPC: @@ -1205,20 +1267,16 @@ void StacktraceSignalHandler( oss << "Caught " << sigNo << " code " << sigInfo->si_code; break; } - oss << kwsys_ios::endl; -#if defined(KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE) - oss << "Program Stack:" << kwsys_ios::endl; - void *stackSymbols[128]; - int n=backtrace(stackSymbols,128); - char **stackText=backtrace_symbols(stackSymbols,n); - for (int i=0; i<n; ++i) - { - oss << " " << stackText[i] << kwsys_ios::endl; - } -#endif oss - << "=========================================================" << kwsys_ios::endl; + << kwsys_ios::endl + << "Program Stack:" << kwsys_ios::endl + << SystemInformationImplementation::GetProgramStack(2,0) + << "=========================================================" << kwsys_ios::endl; kwsys_ios::cerr << oss.str() << kwsys_ios::endl; + + // restore the previously registered handlers + // and abort + SystemInformationImplementation::SetStackTraceOnError(0); abort(); #else // avoid warning C4100 @@ -1227,8 +1285,213 @@ void StacktraceSignalHandler( #endif } #endif + +#if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) +#define safes(_arg)((_arg)?(_arg):"???") + +// Description: +// A container for symbol properties. Each instance +// must be Initialized. +class SymbolProperties +{ +public: + SymbolProperties(); + + // Description: + // The SymbolProperties instance must be initialized by + // passing a stack address. + void Initialize(void *address); + + // Description: + // Get the symbol's stack address. + void *GetAddress() const { return this->Address; } + + // Description: + // If not set paths will be removed. eg, from a binary + // or source file. + void SetReportPath(int rp){ this->ReportPath=rp; } + + // Description: + // Set/Get the name of the binary file that the symbol + // is found in. + void SetBinary(const char *binary) + { this->Binary=safes(binary); } + + kwsys_stl::string GetBinary() const; + + // Description: + // Set the name of the function that the symbol is found in. + // If c++ demangling is supported it will be demangled. + void SetFunction(const char *function) + { this->Function=this->Demangle(function); } + + kwsys_stl::string GetFunction() const + { return this->Function; } + + // Description: + // Set/Get the name of the source file where the symbol + // is defined. + void SetSourceFile(const char *sourcefile) + { this->SourceFile=safes(sourcefile); } + + kwsys_stl::string GetSourceFile() const + { return this->GetFileName(this->SourceFile); } + + // Description: + // Set/Get the line number where the symbol is defined + void SetLineNumber(long linenumber){ this->LineNumber=linenumber; } + long GetLineNumber() const { return this->LineNumber; } + + // Description: + // Set the address where the biinary image is mapped + // into memory. + void SetBinaryBaseAddress(void *address) + { this->BinaryBaseAddress=address; } + +private: + void *GetRealAddress() const + { return (void*)((char*)this->Address-(char*)this->BinaryBaseAddress); } + + kwsys_stl::string GetFileName(const kwsys_stl::string &path) const; + kwsys_stl::string Demangle(const char *symbol) const; + +private: + kwsys_stl::string Binary; + void *BinaryBaseAddress; + void *Address; + kwsys_stl::string SourceFile; + kwsys_stl::string Function; + long LineNumber; + int ReportPath; +}; + +// -------------------------------------------------------------------------- +kwsys_ios::ostream &operator<<( + kwsys_ios::ostream &os, + const SymbolProperties &sp) +{ +#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP) + os + << kwsys_ios::hex << sp.GetAddress() << " : " + << sp.GetFunction() + << " [(" << sp.GetBinary() << ") " + << sp.GetSourceFile() << ":" + << kwsys_ios::dec << sp.GetLineNumber() << "]"; +#elif defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) + void *addr = sp.GetAddress(); + char **syminfo = backtrace_symbols(&addr,1); + os << safes(syminfo[0]); + free(syminfo); +#else + (void)os; + (void)sp; +#endif + return os; +} + +// -------------------------------------------------------------------------- +SymbolProperties::SymbolProperties() +{ + // not using an initializer list + // to avoid some PGI compiler warnings + this->SetBinary("???"); + this->SetBinaryBaseAddress(NULL); + this->Address = NULL; + this->SetSourceFile("???"); + this->SetFunction("???"); + this->SetLineNumber(-1); + this->SetReportPath(0); + // avoid PGI compiler warnings + this->GetRealAddress(); + this->GetFunction(); + this->GetSourceFile(); + this->GetLineNumber(); +} + +// -------------------------------------------------------------------------- +kwsys_stl::string SymbolProperties::GetFileName(const kwsys_stl::string &path) const +{ + kwsys_stl::string file(path); + if (!this->ReportPath) + { + size_t at = file.rfind("/"); + if (at!=kwsys_stl::string::npos) + { + file = file.substr(at+1,kwsys_stl::string::npos); + } + } + return file; +} + +// -------------------------------------------------------------------------- +kwsys_stl::string SymbolProperties::GetBinary() const +{ +// only linux has proc fs +#if defined(__linux__) + if (this->Binary=="/proc/self/exe") + { + kwsys_stl::string binary; + char buf[1024]={'\0'}; + ssize_t ll=0; + if ((ll=readlink("/proc/self/exe",buf,1024))>0) + { + buf[ll]='\0'; + binary=buf; + } + else + { + binary="/proc/self/exe"; + } + return this->GetFileName(binary); + } +#endif + return this->GetFileName(this->Binary); +} + +// -------------------------------------------------------------------------- +kwsys_stl::string SymbolProperties::Demangle(const char *symbol) const +{ + kwsys_stl::string result = safes(symbol); +#if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE) + int status = 0; + size_t bufferLen = 1024; + char *buffer = (char*)malloc(1024); + char *demangledSymbol = + abi::__cxa_demangle(symbol, buffer, &bufferLen, &status); + if (!status) + { + result = demangledSymbol; + } + free(buffer); +#else + (void)symbol; +#endif + return result; +} + +// -------------------------------------------------------------------------- +void SymbolProperties::Initialize(void *address) +{ + this->Address = address; +#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP) + // first fallback option can demangle c++ functions + Dl_info info; + int ierr=dladdr(this->Address,&info); + if (ierr && info.dli_sname && info.dli_saddr) + { + this->SetBinary(info.dli_fname); + this->SetFunction(info.dli_sname); + } +#else + // second fallback use builtin backtrace_symbols + // to decode the bactrace. +#endif +} +#endif // don't define this class if we're not using it + } // anonymous namespace + SystemInformationImplementation::SystemInformationImplementation() { this->TotalVirtualMemory = 0; @@ -3336,12 +3599,61 @@ SystemInformationImplementation::GetProcessId() } /** +return current program stack in a string +demangle cxx symbols if possible. +*/ +kwsys_stl::string SystemInformationImplementation::GetProgramStack( + int firstFrame, + int wholePath) +{ + kwsys_stl::string programStack = "" +#if !defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) + "WARNING: The stack could not be examined " + "because backtrace is not supported.\n" +#elif !defined(KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD) + "WARNING: The stack trace will not use advanced " + "capabilities because this is a release build.\n" +#else +# if !defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP) + "WARNING: Function names will not be demangled because " + "dladdr is not available.\n" +# endif +# if !defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE) + "WARNING: Function names will not be demangled " + "because cxxabi is not available.\n" +# endif +#endif + ; + + kwsys_ios::ostringstream oss; +#if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) + void *stackSymbols[256]; + int nFrames=backtrace(stackSymbols,256); + for (int i=firstFrame; i<nFrames; ++i) + { + SymbolProperties symProps; + symProps.SetReportPath(wholePath); + symProps.Initialize(stackSymbols[i]); + oss << symProps << kwsys_ios::endl; + } +#else + (void)firstFrame; + (void)wholePath; +#endif + programStack += oss.str(); + + return programStack; +} + + +/** when set print stack trace in response to common signals. */ void SystemInformationImplementation::SetStackTraceOnError(int enable) { #if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) static int saOrigValid=0; + static struct sigaction saABRTOrig; static struct sigaction saSEGVOrig; static struct sigaction saTERMOrig; static struct sigaction saINTOrig; @@ -3349,9 +3661,11 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) static struct sigaction saBUSOrig; static struct sigaction saFPEOrig; + if (enable && !saOrigValid) { // save the current actions + sigaction(SIGABRT,0,&saABRTOrig); sigaction(SIGSEGV,0,&saSEGVOrig); sigaction(SIGTERM,0,&saTERMOrig); sigaction(SIGINT,0,&saINTOrig); @@ -3365,9 +3679,10 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) // install ours struct sigaction sa; sa.sa_sigaction=(SigAction)StacktraceSignalHandler; - sa.sa_flags=SA_SIGINFO|SA_RESTART; + sa.sa_flags=SA_SIGINFO|SA_RESTART|SA_RESETHAND; sigemptyset(&sa.sa_mask); + sigaction(SIGABRT,&sa,0); sigaction(SIGSEGV,&sa,0); sigaction(SIGTERM,&sa,0); sigaction(SIGINT,&sa,0); @@ -3379,6 +3694,7 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) if (!enable && saOrigValid) { // restore previous actions + sigaction(SIGABRT,&saABRTOrig,0); sigaction(SIGSEGV,&saSEGVOrig,0); sigaction(SIGTERM,&saTERMOrig,0); sigaction(SIGINT,&saINTOrig,0); diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in index f7c454e..a9fd05d 100644 --- a/Source/kwsys/SystemInformation.hxx.in +++ b/Source/kwsys/SystemInformation.hxx.in @@ -136,6 +136,12 @@ public: static void SetStackTraceOnError(int enable); + // format and return the current program stack in a string. In + // order to produce an informative stack trace the application + // should be dynamically linked and compiled with debug symbols. + static + kwsys_stl::string GetProgramStack(int firstFrame, int wholePath); + /** Run the different checks */ void RunCPUCheck(); void RunOSCheck(); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 935b836..e9a1fd3 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -695,6 +695,52 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, #endif #if defined(_WIN32) && !defined(__CYGWIN__) +static bool SystemToolsParseRegistryKey(const char* key, + HKEY& primaryKey, + kwsys_stl::string& second, + kwsys_stl::string& valuename) +{ + kwsys_stl::string primary = key; + + size_t start = primary.find("\\"); + if (start == kwsys_stl::string::npos) + { + return false; + } + + size_t valuenamepos = primary.find(";"); + if (valuenamepos != kwsys_stl::string::npos) + { + valuename = primary.substr(valuenamepos+1); + } + + second = primary.substr(start+1, valuenamepos-start-1); + primary = primary.substr(0, start); + + if (primary == "HKEY_CURRENT_USER") + { + primaryKey = HKEY_CURRENT_USER; + } + if (primary == "HKEY_CURRENT_CONFIG") + { + primaryKey = HKEY_CURRENT_CONFIG; + } + if (primary == "HKEY_CLASSES_ROOT") + { + primaryKey = HKEY_CLASSES_ROOT; + } + if (primary == "HKEY_LOCAL_MACHINE") + { + primaryKey = HKEY_LOCAL_MACHINE; + } + if (primary == "HKEY_USERS") + { + primaryKey = HKEY_USERS; + } + + return true; +} + static DWORD SystemToolsMakeRegistryMode(DWORD mode, SystemTools::KeyWOW64 view) { @@ -718,6 +764,55 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, } #endif +#if defined(_WIN32) && !defined(__CYGWIN__) +bool +SystemTools::GetRegistrySubKeys(const char *key, + kwsys_stl::vector<kwsys_stl::string>& subkeys, + KeyWOW64 view) +{ + HKEY primaryKey = HKEY_CURRENT_USER; + kwsys_stl::string second; + kwsys_stl::string valuename; + if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) + { + return false; + } + + HKEY hKey; + if(RegOpenKeyEx(primaryKey, + second.c_str(), + 0, + SystemToolsMakeRegistryMode(KEY_READ, view), + &hKey) != ERROR_SUCCESS) + { + return false; + } + else + { + char name[1024]; + DWORD dwNameSize = sizeof(name)/sizeof(name[0]); + + DWORD i = 0; + while (RegEnumKey(hKey, i, name, dwNameSize) == ERROR_SUCCESS) + { + subkeys.push_back(name); + ++i; + } + + RegCloseKey(hKey); + } + + return true; +} +#else +bool SystemTools::GetRegistrySubKeys(const char *, + kwsys_stl::vector<kwsys_stl::string>&, + KeyWOW64) +{ + return false; +} +#endif + // Read a registry value. // Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath @@ -730,47 +825,14 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, KeyWOW64 view) { bool valueset = false; - kwsys_stl::string primary = key; + HKEY primaryKey = HKEY_CURRENT_USER; kwsys_stl::string second; kwsys_stl::string valuename; - - size_t start = primary.find("\\"); - if (start == kwsys_stl::string::npos) + if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) { return false; } - size_t valuenamepos = primary.find(";"); - if (valuenamepos != kwsys_stl::string::npos) - { - valuename = primary.substr(valuenamepos+1); - } - - second = primary.substr(start+1, valuenamepos-start-1); - primary = primary.substr(0, start); - - HKEY primaryKey = HKEY_CURRENT_USER; - if (primary == "HKEY_CURRENT_USER") - { - primaryKey = HKEY_CURRENT_USER; - } - if (primary == "HKEY_CURRENT_CONFIG") - { - primaryKey = HKEY_CURRENT_CONFIG; - } - if (primary == "HKEY_CLASSES_ROOT") - { - primaryKey = HKEY_CLASSES_ROOT; - } - if (primary == "HKEY_LOCAL_MACHINE") - { - primaryKey = HKEY_LOCAL_MACHINE; - } - if (primary == "HKEY_USERS") - { - primaryKey = HKEY_USERS; - } - HKEY hKey; if(RegOpenKeyEx(primaryKey, second.c_str(), @@ -834,47 +896,14 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, bool SystemTools::WriteRegistryValue(const char *key, const char *value, KeyWOW64 view) { - kwsys_stl::string primary = key; + HKEY primaryKey = HKEY_CURRENT_USER; kwsys_stl::string second; kwsys_stl::string valuename; - - size_t start = primary.find("\\"); - if (start == kwsys_stl::string::npos) + if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) { return false; } - size_t valuenamepos = primary.find(";"); - if (valuenamepos != kwsys_stl::string::npos) - { - valuename = primary.substr(valuenamepos+1); - } - - second = primary.substr(start+1, valuenamepos-start-1); - primary = primary.substr(0, start); - - HKEY primaryKey = HKEY_CURRENT_USER; - if (primary == "HKEY_CURRENT_USER") - { - primaryKey = HKEY_CURRENT_USER; - } - if (primary == "HKEY_CURRENT_CONFIG") - { - primaryKey = HKEY_CURRENT_CONFIG; - } - if (primary == "HKEY_CLASSES_ROOT") - { - primaryKey = HKEY_CLASSES_ROOT; - } - if (primary == "HKEY_LOCAL_MACHINE") - { - primaryKey = HKEY_LOCAL_MACHINE; - } - if (primary == "HKEY_USERS") - { - primaryKey = HKEY_USERS; - } - HKEY hKey; DWORD dwDummy; char lpClass[] = ""; @@ -919,47 +948,14 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) #if defined(_WIN32) && !defined(__CYGWIN__) bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) { - kwsys_stl::string primary = key; + HKEY primaryKey = HKEY_CURRENT_USER; kwsys_stl::string second; kwsys_stl::string valuename; - - size_t start = primary.find("\\"); - if (start == kwsys_stl::string::npos) + if (!SystemToolsParseRegistryKey(key, primaryKey, second, valuename)) { return false; } - size_t valuenamepos = primary.find(";"); - if (valuenamepos != kwsys_stl::string::npos) - { - valuename = primary.substr(valuenamepos+1); - } - - second = primary.substr(start+1, valuenamepos-start-1); - primary = primary.substr(0, start); - - HKEY primaryKey = HKEY_CURRENT_USER; - if (primary == "HKEY_CURRENT_USER") - { - primaryKey = HKEY_CURRENT_USER; - } - if (primary == "HKEY_CURRENT_CONFIG") - { - primaryKey = HKEY_CURRENT_CONFIG; - } - if (primary == "HKEY_CLASSES_ROOT") - { - primaryKey = HKEY_CLASSES_ROOT; - } - if (primary == "HKEY_LOCAL_MACHINE") - { - primaryKey = HKEY_LOCAL_MACHINE; - } - if (primary == "HKEY_USERS") - { - primaryKey = HKEY_USERS; - } - HKEY hKey; if(RegOpenKeyEx(primaryKey, second.c_str(), @@ -4869,7 +4865,8 @@ static int SystemToolsDebugReport(int, char* message, int*) void SystemTools::EnableMSVCDebugHook() { - if (getenv("DART_TEST_FROM_DART")) + if (getenv("DART_TEST_FROM_DART") || + getenv("DASHBOARD_TEST_FROM_CTEST")) { _CrtSetReportHook(SystemToolsDebugReport); } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index e55d431..d6dae39 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -716,6 +716,13 @@ public: enum KeyWOW64 { KeyWOW64_Default, KeyWOW64_32, KeyWOW64_64 }; /** + * Get a list of subkeys. + */ + static bool GetRegistrySubKeys(const char *key, + kwsys_stl::vector<kwsys_stl::string>& subkeys, + KeyWOW64 view = KeyWOW64_Default); + + /** * Read a registry value */ static bool ReadRegistryValue(const char *key, kwsys_stl::string &value, diff --git a/Source/kwsys/auto_ptr.hxx.in b/Source/kwsys/auto_ptr.hxx.in index 857b1db..ad9654c 100644 --- a/Source/kwsys/auto_ptr.hxx.in +++ b/Source/kwsys/auto_ptr.hxx.in @@ -31,6 +31,17 @@ # define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) a #endif +// In C++11, clang will warn about using dynamic exception specifications +// as they are deprecated. But as this class is trying to faithfully +// mimic std::auto_ptr, we want to keep the 'throw()' decorations below. +// So we suppress the warning. +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated" +# endif +#endif + namespace @KWSYS_NAMESPACE@ { @@ -198,4 +209,11 @@ public: } // namespace @KWSYS_NAMESPACE@ +// Undo warning suppression. +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated") +# pragma clang diagnostic pop +# endif +#endif + #endif diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in index c835503..651de82 100644 --- a/Source/kwsys/hashtable.hxx.in +++ b/Source/kwsys/hashtable.hxx.in @@ -62,6 +62,17 @@ # pragma set woff 3970 /* pointer to int conversion */ 3321 3968 #endif +// In C++11, clang will warn about using dynamic exception specifications +// as they are deprecated. But as this class is trying to faithfully +// mimic unordered_set and unordered_map, we want to keep the 'throw()' +// decorations below. So we suppress the warning. +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated" +# endif +#endif + #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_TEMPLATE # define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) @KWSYS_NAMESPACE@_stl::allocator< T > #elif @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE @@ -1268,6 +1279,13 @@ using @KWSYS_NAMESPACE@::operator==; using @KWSYS_NAMESPACE@::operator!=; #endif +// Undo warning suppression. +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated") +# pragma clang diagnostic pop +# endif +#endif + #if defined(_MSC_VER) # pragma warning (pop) #endif diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake index d042450..f9ee254 100644 --- a/Source/kwsys/kwsysPlatformTests.cmake +++ b/Source/kwsys/kwsysPlatformTests.cmake @@ -19,6 +19,7 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert) ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}} COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS} + CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}" OUTPUT_VARIABLE OUTPUT) IF(${var}_COMPILED) FILE(APPEND @@ -150,9 +151,11 @@ ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN) MACRO(KWSYS_PLATFORM_CXX_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES}) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS}) + SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES}) KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) + SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES) ENDMACRO(KWSYS_PLATFORM_CXX_TEST) MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index a7e3b50..be7a09e 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -513,6 +513,54 @@ int main() } #endif +#ifdef TEST_KWSYS_CXX_HAS_BACKTRACE +#if defined(__PATHSCALE__) || defined(__PATHCC__) \ + || (defined(__LSB_VERSION__) && (__LSB_VERSION__ < 41)) +backtrace doesnt work with this compiler or os +#endif +#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE) +# define _GNU_SOURCE +#endif +#include <execinfo.h> +int main() +{ + void *stackSymbols[256]; + backtrace(stackSymbols,256); + backtrace_symbols(&stackSymbols[0],1); + return 0; +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_DLADDR +#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE) +# define _GNU_SOURCE +#endif +#include <dlfcn.h> +int main() +{ + Dl_info info; + int ierr=dladdr((void*)main,&info); + return 0; +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_CXXABI +#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE) +# define _GNU_SOURCE +#endif +#include <cxxabi.h> +int main() +{ + int status = 0; + size_t bufferLen = 512; + char buffer[512] = {'\0'}; + const char *function="_ZN5kwsys17SystemInformation15GetProgramStackEii"; + char *demangledFunction = + abi::__cxa_demangle(function, buffer, &bufferLen, &status); + return status; +} +#endif + #ifdef TEST_KWSYS_CXX_TYPE_INFO /* Collect fundamental type information and save it to a CMake script. */ diff --git a/Source/kwsys/testSystemInformation.cxx b/Source/kwsys/testSystemInformation.cxx index 738043f..53d51ac 100644 --- a/Source/kwsys/testSystemInformation.cxx +++ b/Source/kwsys/testSystemInformation.cxx @@ -95,7 +95,24 @@ int testSystemInformation(int, char*[]) kwsys_ios::cout << "CPU feature " << i << "\n"; } } - //int GetProcessorCacheXSize(long int); -// bool DoesCPUSupportFeature(long int); + + /* test stack trace + */ + kwsys_ios::cout + << "Program Stack:" << kwsys_ios::endl + << kwsys::SystemInformation::GetProgramStack(0,0) << kwsys_ios::endl + << kwsys_ios::endl; + + /* test segv handler + info.SetStackTraceOnError(1); + double *d = (double*)100; + *d=0; + */ + + /* test abort handler + info.SetStackTraceOnError(1); + abort(); + */ + return 0; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index dc8d869..9c3ed59 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2056,9 +2056,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" ) - set(CTestLimitDashJ_EXTRA_OPTIONS --force-new-ctest-process) - add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4 - --output-on-failure -C "\${CTestTest_CONFIG}") + if(NOT BORLAND) + set(CTestLimitDashJ_EXTRA_OPTIONS --force-new-ctest-process) + add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4 + --output-on-failure -C "\${CTestTest_CONFIG}") + endif() add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels) set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2") diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 2db9282..86d7385 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -66,6 +66,7 @@ function(gen_mc_test NAME CHECKER) -D PSEUDO_PURIFY=$<TARGET_FILE:pseudo_purify> -D PSEUDO_VALGRIND=$<TARGET_FILE:pseudo_valgrind> -D ERROR_COMMAND=$<TARGET_FILE:memcheck_fail> + ${ARGN} ) endfunction(gen_mc_test) @@ -74,10 +75,11 @@ function(gen_mcnl_test NAME CHECKER) -D PSEUDO_BC=$<TARGET_FILE:pseudonl_BC> -D PSEUDO_PURIFY=$<TARGET_FILE:pseudonl_purify> -D PSEUDO_VALGRIND=$<TARGET_FILE:pseudonl_valgrind> + ${ARGN} ) set_tests_properties(CTestTestMemcheck${NAME} PROPERTIES - PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/${NAME}/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error in read script: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake\n") + PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/${NAME}/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake\n") endfunction(gen_mcnl_test) unset(CTEST_EXTRA_CONFIG) @@ -109,14 +111,17 @@ set(CTEST_EXTRA_CONFIG "set(CTEST_CUSTOM_MEMCHECK_IGNORE RunCMakeAgain)\n") set(CMAKELISTS_EXTRA_CODE "add_test(NAME RunCMakeAgain COMMAND \"\${CMAKE_COMMAND}\" --version)") gen_mc_test(DummyValgrindIgnoreMemcheck "\${PSEUDO_VALGRIND}") +unset(CTEST_EXTRA_CONFIG) +gen_mc_test(DummyValgrindTwoTargets "\${PSEUDO_VALGRIND}" "-VV") + set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE \"\${CMAKE_CURRENT_BINARY_DIR}/does-not-exist\")") unset(CMAKELISTS_EXTRA_CODE) gen_mc_test(DummyValgrindInvalidSupFile "\${PSEUDO_VALGRIND}") -# CTest will add the logfile option as last option. Tell the dummy memcheck -# to ignore that argument. This will cause the logfile to be missing, which -# will be the prove for us that the custom option is indeed used. -set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"--\")") +# CTest will add the logfile option before any custom options. Set the logfile +# again, this time to an empty string. This will cause the logfile to be +# missing, which will be the prove for us that the custom option is indeed used. +set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"--log-file=\")") gen_mc_test(DummyValgrindCustomOptions "\${PSEUDO_VALGRIND}") unset(CTEST_EXTRA_CONFIG) @@ -161,4 +166,8 @@ set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n") set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES - PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n") + PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n") + +set_tests_properties(CTestTestMemcheckDummyValgrindTwoTargets PROPERTIES + PASS_REGULAR_EXPRESSION + "\nMemory check project ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets\n.*\n *Start 1: RunCMake\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*\n *Start 2: RunCMakeAgain\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*\n") diff --git a/Tests/CTestTestMemcheck/memtester.cxx.in b/Tests/CTestTestMemcheck/memtester.cxx.in index da6f5a4..55a34e3 100644 --- a/Tests/CTestTestMemcheck/memtester.cxx.in +++ b/Tests/CTestTestMemcheck/memtester.cxx.in @@ -28,12 +28,6 @@ main(int argc, char **argv) std::string logfile; for (int i = 1; i < argc; i++) { std::string arg = argv[i]; - // stop processing options, this allows to force - // the logfile to be ignored - if (arg == "--") - { - break; - } if (arg.find(logarg) == 0) { if (nextarg) @@ -46,7 +40,7 @@ main(int argc, char **argv) { logfile = arg.substr(logarg.length()); } - break; + // keep searching, it may be overridden later to provoke an error } } diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 9ee4fc5..4d8d7ed 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -184,6 +184,8 @@ add_custom_target(check-part3 ALL -Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>> -Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>> -Dtest_alias_target_name=$<STREQUAL:$<TARGET_PROPERTY:Alias::SomeLib,NAME>,$<TARGET_PROPERTY:empty1,NAME>> + -Dtest_early_termination_1=$<$<1:>: + -Dtest_early_termination_2=$<$<1:>:, -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 5a6a441..74a596c 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -24,3 +24,5 @@ endforeach() check(test_alias_file_exe "1") check(test_alias_file_lib "1") check(test_alias_target_name "1") +check(test_early_termination_1 "$<:") +check(test_early_termination_2 "$<:,") diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake b/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake index 7c61961..f42d8e4 100644 --- a/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) cmake_policy(SET CMP0004 NEW) diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake b/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake index d6ed72c..3fa58b6 100644 --- a/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) cmake_policy(SET CMP0004 OLD) diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake b/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake index eab680a..2970476 100644 --- a/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) cmake_policy(SET CMP0004 NEW) diff --git a/Tests/RunCMake/CMP0004/CMakeLists.txt b/Tests/RunCMake/CMP0004/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/CMP0004/CMakeLists.txt +++ b/Tests/RunCMake/CMP0004/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0019/CMakeLists.txt b/Tests/RunCMake/CMP0019/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/CMP0019/CMakeLists.txt +++ b/Tests/RunCMake/CMP0019/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CTest/CMakeLists.txt b/Tests/RunCMake/CTest/CMakeLists.txt index f6e84c0..73e6a78 100644 --- a/Tests/RunCMake/CTest/CMakeLists.txt +++ b/Tests/RunCMake/CTest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) if(NOT NoProject) project(${RunCMake_TEST} NONE) endif() diff --git a/Tests/RunCMake/CompatibleInterface/CMakeLists.txt b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt index 68dd8d6..f452db1 100644 --- a/Tests/RunCMake/CompatibleInterface/CMakeLists.txt +++ b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerChange/CMakeLists.txt b/Tests/RunCMake/CompilerChange/CMakeLists.txt index 3b92518..b4b3016 100644 --- a/Tests/RunCMake/CompilerChange/CMakeLists.txt +++ b/Tests/RunCMake/CompilerChange/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) if(NOT RunCMake_TEST) set(RunCMake_TEST "$ENV{RunCMake_TEST}") # needed when cache is deleted endif() diff --git a/Tests/RunCMake/Configure/CMakeLists.txt b/Tests/RunCMake/Configure/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/Configure/CMakeLists.txt +++ b/Tests/RunCMake/Configure/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt b/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt +++ b/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalData/CMakeLists.txt b/Tests/RunCMake/ExternalData/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/ExternalData/CMakeLists.txt +++ b/Tests/RunCMake/ExternalData/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FPHSA/CMakeLists.txt b/Tests/RunCMake/FPHSA/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/FPHSA/CMakeLists.txt +++ b/Tests/RunCMake/FPHSA/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/File_Generate/CMakeLists.txt b/Tests/RunCMake/File_Generate/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/File_Generate/CMakeLists.txt +++ b/Tests/RunCMake/File_Generate/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorExpression/CMakeLists.txt b/Tests/RunCMake/GeneratorExpression/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/GeneratorExpression/CMakeLists.txt +++ b/Tests/RunCMake/GeneratorExpression/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorToolset/CMakeLists.txt b/Tests/RunCMake/GeneratorToolset/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/GeneratorToolset/CMakeLists.txt +++ b/Tests/RunCMake/GeneratorToolset/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/IncompatibleQt/CMakeLists.txt b/Tests/RunCMake/IncompatibleQt/CMakeLists.txt index 68dd8d6..f452db1 100644 --- a/Tests/RunCMake/IncompatibleQt/CMakeLists.txt +++ b/Tests/RunCMake/IncompatibleQt/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Languages/CMakeLists.txt b/Tests/RunCMake/Languages/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/Languages/CMakeLists.txt +++ b/Tests/RunCMake/Languages/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt index a7f0779..a17c8cd 100644 --- a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt +++ b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt b/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt index 22577da..90afc12 100644 --- a/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt +++ b/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) # MSVC creates extra targets which pollute the stderr unless we set this. diff --git a/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt b/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt +++ b/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetPolicies/CMakeLists.txt b/Tests/RunCMake/TargetPolicies/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/TargetPolicies/CMakeLists.txt +++ b/Tests/RunCMake/TargetPolicies/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt index 22577da..90afc12 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) # MSVC creates extra targets which pollute the stderr unless we set this. diff --git a/Tests/RunCMake/VisibilityPreset/CMakeLists.txt b/Tests/RunCMake/VisibilityPreset/CMakeLists.txt index 22577da..90afc12 100644 --- a/Tests/RunCMake/VisibilityPreset/CMakeLists.txt +++ b/Tests/RunCMake/VisibilityPreset/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) # MSVC creates extra targets which pollute the stderr unless we set this. diff --git a/Tests/RunCMake/add_dependencies/CMakeLists.txt b/Tests/RunCMake/add_dependencies/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/add_dependencies/CMakeLists.txt +++ b/Tests/RunCMake/add_dependencies/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/alias_targets/CMakeLists.txt b/Tests/RunCMake/alias_targets/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/alias_targets/CMakeLists.txt +++ b/Tests/RunCMake/alias_targets/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/build_command/CMakeLists.txt b/Tests/RunCMake/build_command/CMakeLists.txt index f6e84c0..73e6a78 100644 --- a/Tests/RunCMake/build_command/CMakeLists.txt +++ b/Tests/RunCMake/build_command/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) if(NOT NoProject) project(${RunCMake_TEST} NONE) endif() diff --git a/Tests/RunCMake/find_package/CMakeLists.txt b/Tests/RunCMake/find_package/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/find_package/CMakeLists.txt +++ b/Tests/RunCMake/find_package/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/get_filename_component/CMakeLists.txt b/Tests/RunCMake/get_filename_component/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/get_filename_component/CMakeLists.txt +++ b/Tests/RunCMake/get_filename_component/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/if/CMakeLists.txt b/Tests/RunCMake/if/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/if/CMakeLists.txt +++ b/Tests/RunCMake/if/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include/CMakeLists.txt b/Tests/RunCMake/include/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/include/CMakeLists.txt +++ b/Tests/RunCMake/include/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_directories/CMakeLists.txt b/Tests/RunCMake/include_directories/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/include_directories/CMakeLists.txt +++ b/Tests/RunCMake/include_directories/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_external_msproject/CMakeLists.txt b/Tests/RunCMake/include_external_msproject/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/include_external_msproject/CMakeLists.txt +++ b/Tests/RunCMake/include_external_msproject/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/list/CMakeLists.txt b/Tests/RunCMake/list/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/list/CMakeLists.txt +++ b/Tests/RunCMake/list/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/target_link_libraries/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/target_link_libraries/CMakeLists.txt +++ b/Tests/RunCMake/target_link_libraries/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/try_compile/CMakeLists.txt b/Tests/RunCMake/try_compile/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/try_compile/CMakeLists.txt +++ b/Tests/RunCMake/try_compile/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/variable_watch/CMakeLists.txt b/Tests/RunCMake/variable_watch/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/variable_watch/CMakeLists.txt +++ b/Tests/RunCMake/variable_watch/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake index 8d20476..9becb4c 100644 --- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake +++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(ModifiedAccess) run_cmake(NoWatcher) +run_cmake(WatchTwice) diff --git a/Tests/RunCMake/variable_watch/WatchTwice-stderr.txt b/Tests/RunCMake/variable_watch/WatchTwice-stderr.txt new file mode 100644 index 0000000..fa7d347 --- /dev/null +++ b/Tests/RunCMake/variable_watch/WatchTwice-stderr.txt @@ -0,0 +1,2 @@ +From watch1 +From watch2 diff --git a/Tests/RunCMake/variable_watch/WatchTwice.cmake b/Tests/RunCMake/variable_watch/WatchTwice.cmake new file mode 100644 index 0000000..540cfc1 --- /dev/null +++ b/Tests/RunCMake/variable_watch/WatchTwice.cmake @@ -0,0 +1,11 @@ +function (watch1) + message("From watch1") +endfunction () + +function (watch2) + message("From watch2") +endfunction () + +variable_watch(watched watch1) +variable_watch(watched watch2) +set(access "${watched}") diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index b8f6b3c..91965e9 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -72,11 +72,11 @@ macro(ADD_DOCS target dependency) endmacro() # Help cmake-gui find the Qt DLLs on Windows. -set(WIN_SHELL_GENS "Visual Studio|NMake|MinGW|Watcom|Borland") -if(BUILD_QtDialog AND "${CMAKE_GENERATOR}" MATCHES "${WIN_SHELL_GENS}" - AND EXISTS "${QT_QMAKE_EXECUTABLE}" AND NOT CMAKE_NO_AUTO_QT_ENV) - get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) - if(EXISTS "${Qt_BIN_DIR}/QtCore4.dll") +if(TARGET cmake-gui) + get_property(Qt_BIN_DIR TARGET cmake-gui PROPERTY Qt_BIN_DIR) + set(WIN_SHELL_GENS "Visual Studio|NMake|MinGW|Watcom|Borland") + if(Qt_BIN_DIR AND "${CMAKE_GENERATOR}" MATCHES "${WIN_SHELL_GENS}" + AND NOT CMAKE_NO_AUTO_QT_ENV) # Tell the macro to set the path before running cmake-gui. string(REPLACE ";" "\\;" _PATH "PATH=${Qt_BIN_DIR};%PATH%") set(cmake-gui-PATH COMMAND set "${_PATH}") |