diff options
74 files changed, 872 insertions, 260 deletions
diff --git a/Modules/CMakeDetermineASM-ATTCompiler.cmake b/Modules/CMakeDetermineASM-ATTCompiler.cmake index cec09e9..03c5668 100644 --- a/Modules/CMakeDetermineASM-ATTCompiler.cmake +++ b/Modules/CMakeDetermineASM-ATTCompiler.cmake @@ -15,6 +15,6 @@ # determine the compiler to use for ASM using AT&T syntax, e.g. GNU as set(ASM_DIALECT "-ATT") -set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ${_CMAKE_TOOLCHAIN_PREFIX}gas ${_CMAKE_TOOLCHAIN_PREFIX}as) +set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gas ${_CMAKE_TOOLCHAIN_PREFIX}as) include(CMakeDetermineASMCompiler) set(ASM_DIALECT) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 3643b17..0fecb5d 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -39,8 +39,8 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) endif() endif() else() # some specific assembler "dialect" - if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) - message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT must be preset !") + if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT AND NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST) + message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT or CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST must be preset !") endif() endif() diff --git a/Modules/CMakeDetermineASM_NASMCompiler.cmake b/Modules/CMakeDetermineASM_NASMCompiler.cmake index 50f71dd..5d783b1 100644 --- a/Modules/CMakeDetermineASM_NASMCompiler.cmake +++ b/Modules/CMakeDetermineASM_NASMCompiler.cmake @@ -14,7 +14,7 @@ # Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible -set(CMAKE_ASM_NASM_COMPILER_INIT nasm yasm) +set(CMAKE_ASM_NASM_COMPILER_LIST nasm yasm) if(NOT CMAKE_ASM_NASM_COMPILER) find_program(CMAKE_ASM_NASM_COMPILER nasm diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index 98e5bb8..17b4bbf 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -1,32 +1,25 @@ -# - Includes a public function for assisting users in trying to determine the -# Visual Studio service pack in use. -# -# Sets the passed in variable to one of the following values or an empty -# string if unknown. -# vc80 -# vc80sp1 -# vc90 -# vc90sp1 -# vc100 -# vc100sp1 -# vc110 +# - Determine the Visual Studio service pack of the 'cl' in use. +# The functionality of this module has been superseded by the platform +# variable CMAKE_<LANG>_COMPILER_VERSION that contains the compiler version +# number. # # Usage: -# =========================== -# -# if(MSVC) -# include(CMakeDetermineVSServicePack) -# DetermineVSServicePack( my_service_pack ) -# -# if( my_service_pack ) -# message(STATUS "Detected: ${my_service_pack}") -# endif() +# if(MSVC) +# include(CMakeDetermineVSServicePack) +# DetermineVSServicePack( my_service_pack ) +# if( my_service_pack ) +# message(STATUS "Detected: ${my_service_pack}") # endif() -# -# =========================== +# endif() +# Function DetermineVSServicePack sets the given variable to one of the +# following values or an empty string if unknown: +# vc80, vc80sp1 +# vc90, vc90sp1 +# vc100, vc100sp1 +# vc110, vc110sp1, vc110sp2 #============================================================================= -# Copyright 2009-2011 Kitware, Inc. +# Copyright 2009-2013 Kitware, Inc. # Copyright 2009-2010 Philip Lowman <philip@yhbt.com> # Copyright 2010-2011 Aaron C. meadows <cmake@shadowguarddev.com> # @@ -57,6 +50,10 @@ function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version) set(_version "vc100sp1") elseif(${_cl_version} VERSION_EQUAL "17.00.50727.1") set(_version "vc110") + elseif(${_cl_version} VERSION_EQUAL "17.00.51106.1") + set(_version "vc110sp1") + elseif(${_cl_version} VERSION_EQUAL "17.00.60315.1") + set(_version "vc110sp2") else() set(_version "") endif() diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 504704d..e5e10c3 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -30,6 +30,7 @@ macro(__compiler_gnu lang) endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(CMAKE_SYSROOT_FLAG "--sysroot=") # Older versions of gcc (< 4.5) contain a bug causing them to report a missing # header file as a warning if depfiles are enabled, causing check_header_file diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index d1ce2f4..4cc32be 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1020,7 +1020,12 @@ if(Boost_FOUND) # We were unable to find some libraries, so generate a sensible # error message that lists the libraries we were unable to find. set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n") + "${Boost_ERROR_REASON}\nCould not find the following") + if(Boost_USE_STATIC_LIBS) + set(Boost_ERROR_REASON "${Boost_ERROR_REASON} static") + endif() + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON} Boost libraries:\n") foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) set(Boost_ERROR_REASON "${Boost_ERROR_REASON} boost_${COMPONENT}\n") diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 06cf962..f398c79 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -164,6 +164,7 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) cairo cairomm-1.0 gdk-pixbuf-2.0 + gthread-2.0 gdkmm-2.4 giomm-2.4 gtk-2.0 @@ -460,9 +461,13 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h) _GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true) + _GTK2_FIND_LIBRARY (GTK2_PANGOCAIRO_LIBRARY pangocairo false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) _GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true) + _GTK2_FIND_LIBRARY (GTK2_GTHREAD_LIBRARY gthread false true) + _GTK2_FIND_LIBRARY (GTK2_GIO_LIBRARY gio false true) _GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h) @@ -489,8 +494,6 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h) _GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true) - _GTK2_FIND_LIBRARY (GTK2_PANGOCAIRO_LIBRARY pangocairo true true) - _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h) _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMMCONFIG_INCLUDE_DIR cairommconfig.h) _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 3cd3cef..131d979 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -68,6 +68,7 @@ if (UNIX) /usr/openwin/include /usr/openwin/share/include /opt/graphics/OpenGL/include + /opt/X11/include ) set(X11_LIB_SEARCH_PATH @@ -75,6 +76,7 @@ if (UNIX) /usr/X11R6/lib /usr/X11R7/lib /usr/openwin/lib + /opt/X11/lib ) find_path(X11_X11_INCLUDE_PATH X11/X.h ${X11_INC_SEARCH_PATH}) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 9c23127..0242b24 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -221,6 +221,13 @@ set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake) function(add_jar _TARGET_NAME) + # In CMake < 2.8.12, add_jar used variables which were set prior to calling + # add_jar for customizing the behavior of add_jar. In order to be backwards + # compatible, check if any of those variables are set, and use them to + # initialize values of the named arguments. (Giving the corresponding named + # argument will override the value set here.) + # + # New features should use named arguments only. if(DEFINED CMAKE_JAVA_TARGET_VERSION) set(_add_jar_VERSION "${CMAKE_JAVA_TARGET_VERSION}") endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1893167..70d4b48 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -11,7 +11,11 @@ #============================================================================= include(CheckIncludeFile) # Check if we can build support for ELF parsing. -CHECK_INCLUDE_FILE("elf.h" HAVE_ELF_H) +if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") + CHECK_INCLUDE_FILES("stdint.h;elf_abi.h" HAVE_ELF_H) +else() + CHECK_INCLUDE_FILE("elf.h" HAVE_ELF_H) +endif() if(HAVE_ELF_H) set(CMAKE_USE_ELF_PARSER 1) else() @@ -113,7 +117,8 @@ endif() set(SRCS cmStandardIncludes.cxx cmArchiveWrite.cxx - cmBootstrapCommands.cxx + cmBootstrapCommands1.cxx + cmBootstrapCommands2.cxx cmCacheManager.cxx cmCacheManager.h cmCommands.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d191cc7..7393ec2 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 20130612) +set(CMake_VERSION_TWEAK 20130624) #set(CMake_VERSION_RC 1) diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx new file mode 100644 index 0000000..9093579 --- /dev/null +++ b/Source/cmBootstrapCommands1.cxx @@ -0,0 +1,91 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +// This file is used to compile all the commands +// that CMake knows about at compile time. +// This is sort of a boot strapping approach since you would +// like to have CMake to build CMake. +#include "cmCommands.h" +#include "cmAddCustomCommandCommand.cxx" +#include "cmAddCustomTargetCommand.cxx" +#include "cmAddDefinitionsCommand.cxx" +#include "cmAddDependenciesCommand.cxx" +#include "cmAddExecutableCommand.cxx" +#include "cmAddLibraryCommand.cxx" +#include "cmAddSubDirectoryCommand.cxx" +#include "cmAddTestCommand.cxx" +#include "cmBreakCommand.cxx" +#include "cmBuildCommand.cxx" +#include "cmCMakeMinimumRequired.cxx" +#include "cmCMakePolicyCommand.cxx" +#include "cmCommandArgumentsHelper.cxx" +#include "cmConfigureFileCommand.cxx" +#include "cmCoreTryCompile.cxx" +#include "cmCreateTestSourceList.cxx" +#include "cmDefinePropertyCommand.cxx" +#include "cmElseCommand.cxx" +#include "cmEnableLanguageCommand.cxx" +#include "cmEnableTestingCommand.cxx" +#include "cmEndForEachCommand.cxx" +#include "cmEndFunctionCommand.cxx" +#include "cmEndIfCommand.cxx" +#include "cmEndMacroCommand.cxx" +#include "cmEndWhileCommand.cxx" +#include "cmExecProgramCommand.cxx" +#include "cmExecuteProcessCommand.cxx" +#include "cmExternalMakefileProjectGenerator.cxx" +#include "cmFindBase.cxx" +#include "cmFindCommon.cxx" +#include "cmFileCommand.cxx" +#include "cmFindFileCommand.cxx" +#include "cmFindLibraryCommand.cxx" +#include "cmFindPackageCommand.cxx" +#include "cmFindPathCommand.cxx" +#include "cmFindProgramCommand.cxx" +#include "cmForEachCommand.cxx" +#include "cmFunctionCommand.cxx" + +void GetBootstrapCommands1(std::list<cmCommand*>& commands) +{ + commands.push_back(new cmAddCustomCommandCommand); + commands.push_back(new cmAddCustomTargetCommand); + commands.push_back(new cmAddDefinitionsCommand); + commands.push_back(new cmAddDependenciesCommand); + commands.push_back(new cmAddExecutableCommand); + commands.push_back(new cmAddLibraryCommand); + commands.push_back(new cmAddSubDirectoryCommand); + commands.push_back(new cmAddTestCommand); + commands.push_back(new cmBreakCommand); + commands.push_back(new cmBuildCommand); + commands.push_back(new cmCMakeMinimumRequired); + commands.push_back(new cmCMakePolicyCommand); + commands.push_back(new cmConfigureFileCommand); + commands.push_back(new cmCreateTestSourceList); + commands.push_back(new cmDefinePropertyCommand); + commands.push_back(new cmElseCommand); + commands.push_back(new cmEnableLanguageCommand); + commands.push_back(new cmEnableTestingCommand); + commands.push_back(new cmEndForEachCommand); + commands.push_back(new cmEndFunctionCommand); + commands.push_back(new cmEndIfCommand); + commands.push_back(new cmEndMacroCommand); + commands.push_back(new cmEndWhileCommand); + commands.push_back(new cmExecProgramCommand); + commands.push_back(new cmExecuteProcessCommand); + commands.push_back(new cmFileCommand); + commands.push_back(new cmFindFileCommand); + commands.push_back(new cmFindLibraryCommand); + commands.push_back(new cmFindPackageCommand); + commands.push_back(new cmFindPathCommand); + commands.push_back(new cmFindProgramCommand); + commands.push_back(new cmForEachCommand); + commands.push_back(new cmFunctionCommand); +} diff --git a/Source/cmBootstrapCommands.cxx b/Source/cmBootstrapCommands2.cxx index 1b7a751..be72526 100644 --- a/Source/cmBootstrapCommands.cxx +++ b/Source/cmBootstrapCommands2.cxx @@ -14,44 +14,6 @@ // This is sort of a boot strapping approach since you would // like to have CMake to build CMake. #include "cmCommands.h" -#include "cmAddCustomCommandCommand.cxx" -#include "cmAddCustomTargetCommand.cxx" -#include "cmAddDefinitionsCommand.cxx" -#include "cmAddDependenciesCommand.cxx" -#include "cmAddExecutableCommand.cxx" -#include "cmAddLibraryCommand.cxx" -#include "cmAddSubDirectoryCommand.cxx" -#include "cmAddTestCommand.cxx" -#include "cmBreakCommand.cxx" -#include "cmBuildCommand.cxx" -#include "cmCMakeMinimumRequired.cxx" -#include "cmCMakePolicyCommand.cxx" -#include "cmCommandArgumentsHelper.cxx" -#include "cmConfigureFileCommand.cxx" -#include "cmCoreTryCompile.cxx" -#include "cmCreateTestSourceList.cxx" -#include "cmDefinePropertyCommand.cxx" -#include "cmElseCommand.cxx" -#include "cmEnableLanguageCommand.cxx" -#include "cmEnableTestingCommand.cxx" -#include "cmEndForEachCommand.cxx" -#include "cmEndFunctionCommand.cxx" -#include "cmEndIfCommand.cxx" -#include "cmEndMacroCommand.cxx" -#include "cmEndWhileCommand.cxx" -#include "cmExecProgramCommand.cxx" -#include "cmExecuteProcessCommand.cxx" -#include "cmExternalMakefileProjectGenerator.cxx" -#include "cmFindBase.cxx" -#include "cmFindCommon.cxx" -#include "cmFileCommand.cxx" -#include "cmFindFileCommand.cxx" -#include "cmFindLibraryCommand.cxx" -#include "cmFindPackageCommand.cxx" -#include "cmFindPathCommand.cxx" -#include "cmFindProgramCommand.cxx" -#include "cmForEachCommand.cxx" -#include "cmFunctionCommand.cxx" #include "cmGeneratorExpressionEvaluationFile.cxx" #include "cmGetCMakePropertyCommand.cxx" #include "cmGetDirectoryPropertyCommand.cxx" @@ -96,41 +58,8 @@ #include "cmUnsetCommand.cxx" #include "cmWhileCommand.cxx" -void GetBootstrapCommands(std::list<cmCommand*>& commands) +void GetBootstrapCommands2(std::list<cmCommand*>& commands) { - commands.push_back(new cmAddCustomCommandCommand); - commands.push_back(new cmAddCustomTargetCommand); - commands.push_back(new cmAddDefinitionsCommand); - commands.push_back(new cmAddDependenciesCommand); - commands.push_back(new cmAddExecutableCommand); - commands.push_back(new cmAddLibraryCommand); - commands.push_back(new cmAddSubDirectoryCommand); - commands.push_back(new cmAddTestCommand); - commands.push_back(new cmBreakCommand); - commands.push_back(new cmBuildCommand); - commands.push_back(new cmCMakeMinimumRequired); - commands.push_back(new cmCMakePolicyCommand); - commands.push_back(new cmConfigureFileCommand); - commands.push_back(new cmCreateTestSourceList); - commands.push_back(new cmDefinePropertyCommand); - commands.push_back(new cmElseCommand); - commands.push_back(new cmEnableLanguageCommand); - commands.push_back(new cmEnableTestingCommand); - commands.push_back(new cmEndForEachCommand); - commands.push_back(new cmEndFunctionCommand); - commands.push_back(new cmEndIfCommand); - commands.push_back(new cmEndMacroCommand); - commands.push_back(new cmEndWhileCommand); - commands.push_back(new cmExecProgramCommand); - commands.push_back(new cmExecuteProcessCommand); - commands.push_back(new cmFileCommand); - commands.push_back(new cmFindFileCommand); - commands.push_back(new cmFindLibraryCommand); - commands.push_back(new cmFindPackageCommand); - commands.push_back(new cmFindPathCommand); - commands.push_back(new cmFindProgramCommand); - commands.push_back(new cmForEachCommand); - commands.push_back(new cmFunctionCommand); commands.push_back(new cmGetCMakePropertyCommand); commands.push_back(new cmGetDirectoryPropertyCommand); commands.push_back(new cmGetFilenameComponentCommand); diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx new file mode 100644 index 0000000..62f2383 --- /dev/null +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -0,0 +1,126 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCMakeHostSystemInformationCommand.h" + +#include <cmsys/ios/sstream> + +// cmCMakeHostSystemInformation +bool cmCMakeHostSystemInformationCommand +::InitialPass(std::vector<std::string> const &args, cmExecutionStatus &) +{ + size_t current_index = 0; + + if(args.size() < (current_index + 2) || args[current_index] != "RESULT") + { + this->SetError("missing RESULT specification."); + return false; + } + + std::string variable = args[current_index + 1]; + current_index += 2; + + if(args.size() < (current_index + 2) || args[current_index] != "QUERY") + { + this->SetError("missing QUERY specification"); + return false; + } + + cmsys::SystemInformation info; + info.RunCPUCheck(); + info.RunOSCheck(); + info.RunMemoryCheck(); + + std::string result_list; + for(size_t i = current_index + 1; i < args.size(); ++i) + { + std::string key = args[i]; + if(i != current_index + 1) + { + result_list += ";"; + } + std::string value; + if(!this->GetValue(info, key, value)) return false; + + result_list += value; + } + + this->Makefile->AddDefinition(variable.c_str(), result_list.c_str()); + + return true; +} + +bool cmCMakeHostSystemInformationCommand +::GetValue(cmsys::SystemInformation &info, + std::string const& key, std::string &value) +{ + if(key == "NUMBER_OF_LOGICAL_CORES") + { + value = this->ValueToString(info.GetNumberOfLogicalCPU()); + } + else if(key == "NUMBER_OF_PHYSICAL_CORES") + { + value = this->ValueToString(info.GetNumberOfPhysicalCPU()); + } + else if(key == "HOSTNAME") + { + value = this->ValueToString(info.GetHostname()); + } + else if(key == "FQDN") + { + value = this->ValueToString(info.GetFullyQualifiedDomainName()); + } + else if(key == "TOTAL_VIRTUAL_MEMORY") + { + value = this->ValueToString(info.GetTotalVirtualMemory()); + } + else if(key == "AVAILABLE_VIRTUAL_MEMORY") + { + value = this->ValueToString(info.GetAvailableVirtualMemory()); + } + else if(key == "TOTAL_PHYSICAL_MEMORY") + { + value = this->ValueToString(info.GetTotalPhysicalMemory()); + } + else if(key == "AVAILABLE_PHYSICAL_MEMORY") + { + value = this->ValueToString(info.GetAvailablePhysicalMemory()); + } + else + { + std::string e = "does not recognize <key> " + key; + this->SetError(e.c_str()); + return false; + } + + return true; +} + +std::string cmCMakeHostSystemInformationCommand +::ValueToString(size_t value) const +{ + cmsys_ios::stringstream tmp; + tmp << value; + return tmp.str(); +} + +std::string cmCMakeHostSystemInformationCommand +::ValueToString(const char *value) const +{ + std::string safe_string = value ? value : ""; + return safe_string; +} + +std::string cmCMakeHostSystemInformationCommand +::ValueToString(std::string const& value) const +{ + return value; +} diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h new file mode 100644 index 0000000..d1b8700 --- /dev/null +++ b/Source/cmCMakeHostSystemInformationCommand.h @@ -0,0 +1,102 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCMakeHostSystemInformationCommand_h +#define cmCMakeHostSystemInformationCommand_h + +#include "cmCommand.h" + +#include <cmsys/SystemInformation.hxx> + +/** \class cmCMakeHostSystemInformationCommand + * \brief Query host system specific information + * + * cmCMakeHostSystemInformationCommand queries system information of + * the sytem on which CMake runs. + */ +class cmCMakeHostSystemInformationCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmCMakeHostSystemInformationCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector<std::string> const& args, + cmExecutionStatus &status); + + /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() const { return true; } + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() const + { + return "cmake_host_system_information"; + } + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() const + { + return "Query host system specific information."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() const + { + return + " cmake_host_system_information(RESULT <variable> QUERY <key> ...)\n" + "Queries system information of the host system on which cmake runs. " + "One or more <key> can be provided to " + "select the information to be queried. " + "The list of queried values is stored in <variable>.\n" + "<key> can be one of the following values:\n" + " NUMBER_OF_LOGICAL_CORES = Number of logical cores.\n" + " NUMBER_OF_PHYSICAL_CORES = Number of physical cores.\n" + " HOSTNAME = Hostname.\n" + " FQDN = Fully qualified domain name.\n" + " TOTAL_VIRTUAL_MEMORY = " + "Total virtual memory in megabytes.\n" + " AVAILABLE_VIRTUAL_MEMORY = " + "Available virtual memory in megabytes.\n" + " TOTAL_PHYSICAL_MEMORY = " + "Total physical memory in megabytes.\n" + " AVAILABLE_PHYSICAL_MEMORY = " + "Available physical memory in megabytes.\n" + ; + } + + cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand); + +private: + bool GetValue(cmsys::SystemInformation &info, + std::string const& key, std::string &value); + + std::string ValueToString(size_t value) const; + std::string ValueToString(const char *value) const; + std::string ValueToString(std::string const& value) const; +}; + +#endif diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 3cfbf43..1e2a85c 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -14,6 +14,7 @@ #include "cmAddCompileOptionsCommand.cxx" #include "cmAuxSourceDirectoryCommand.cxx" #include "cmBuildNameCommand.cxx" +#include "cmCMakeHostSystemInformationCommand.cxx" #include "cmElseIfCommand.cxx" #include "cmExportCommand.cxx" #include "cmExportLibraryDependencies.cxx" @@ -56,6 +57,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands.push_back(new cmAddCompileOptionsCommand); commands.push_back(new cmAuxSourceDirectoryCommand); commands.push_back(new cmBuildNameCommand); + commands.push_back(new cmCMakeHostSystemInformationCommand); commands.push_back(new cmElseIfCommand); commands.push_back(new cmExportCommand); commands.push_back(new cmExportLibraryDependenciesCommand); diff --git a/Source/cmCommands.h b/Source/cmCommands.h index 096fc20..c56673f 100644 --- a/Source/cmCommands.h +++ b/Source/cmCommands.h @@ -16,12 +16,13 @@ class cmCommand; /** * Global function to return all compiled in commands. - * To add a new command edit cmCommands.cxx or cmBootstrapCommands.cxx + * To add a new command edit cmCommands.cxx or cmBootstrapCommands[12].cxx * and add your command. * It is up to the caller to delete the commands created by this * call. */ -void GetBootstrapCommands(std::list<cmCommand*>& commands); +void GetBootstrapCommands1(std::list<cmCommand*>& commands); +void GetBootstrapCommands2(std::list<cmCommand*>& commands); void GetPredefinedCommands(std::list<cmCommand*>& commands); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 02495c4..0ba0139 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -499,7 +499,7 @@ bool cmComputeLinkInformation::Compute() if(!this->LinkLanguage) { cmSystemTools:: - Error("CMake can not determine linker language for target:", + Error("CMake can not determine linker language for target: ", this->Target->GetName()); return false; } @@ -1884,6 +1884,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, } if(use_build_rpath || use_link_rpath) { + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); ri != rdirs.end(); ++ri) @@ -1907,9 +1909,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (d.find(rootPath) == 0) { - runtimeDirs.push_back(*ri); + d = d.substr(rootPath.size()); + } + if(emitted.insert(d).second) + { + runtimeDirs.push_back(d); } } } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index bf28428..b43a7a7 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -38,10 +38,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) char targetNameBuf[64]; bool didOutputVariable = false; bool didCopyFile = false; + bool useSources = argv[2] == "SOURCES"; + std::vector<std::string> sources; enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions, - DoingLinkLibraries, DoingOutputVariable, DoingCopyFile }; - Doing doing = DoingNone; + DoingLinkLibraries, DoingOutputVariable, DoingCopyFile, + DoingSources }; + Doing doing = useSources? DoingSources : DoingNone; for(size_t i=3; i < argv.size(); ++i) { if(argv[i] == "CMAKE_FLAGS") @@ -118,6 +121,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) copyFile = argv[i].c_str(); doing = DoingNone; } + else if(doing == DoingSources) + { + sources.push_back(argv[i]); + } else if(i == 3) { this->SrcFileSignature = false; @@ -149,6 +156,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) return -1; } + if(useSources && sources.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "SOURCES must be followed by at least one source file"); + return -1; + } + // compute the binary dir when TRY_COMPILE is called with a src file // signature if (this->SrcFileSignature) @@ -193,6 +207,44 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt"; cmSystemTools::RemoveFile(ccFile.c_str()); + // Choose sources. + if(!useSources) + { + sources.push_back(argv[2]); + } + + // Detect languages to enable. + cmGlobalGenerator* gg = + this->Makefile->GetCMakeInstance()->GetGlobalGenerator(); + std::set<std::string> testLangs; + for(std::vector<std::string>::iterator si = sources.begin(); + si != sources.end(); ++si) + { + std::string ext = cmSystemTools::GetFilenameLastExtension(*si); + if(const char* lang = gg->GetLanguageFromExtension(ext.c_str())) + { + testLangs.insert(lang); + } + else + { + cmOStringStream err; + err << "Unknown extension \"" << ext << "\" for file\n" + << " " << *si << "\n" + << "try_compile() works only for enabled languages. " + << "Currently these are:\n "; + std::vector<std::string> langs; + gg->GetEnabledLanguages(langs); + for(std::vector<std::string>::iterator l = langs.begin(); + l != langs.end(); ++l) + { + err << " " << *l; + } + err << "\nSee project() command to enable other languages."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str()); + return -1; + } + } + // we need to create a directory and CMakeLists file etc... // first create the directories sourceDirectory = this->BinaryDirectory.c_str(); @@ -209,10 +261,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) return -1; } - std::string source = argv[2]; - std::string ext = cmSystemTools::GetFilenameLastExtension(source); - const char* lang =(this->Makefile->GetCMakeInstance()->GetGlobalGenerator() - ->GetLanguageFromExtension(ext.c_str())); const char* def = this->Makefile->GetDefinition("CMAKE_MODULE_PATH"); fprintf(fout, "cmake_minimum_required(VERSION %u.%u.%u.%u)\n", cmVersion::GetMajorVersion(), cmVersion::GetMinorVersion(), @@ -222,57 +270,39 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) fprintf(fout, "SET(CMAKE_MODULE_PATH %s)\n", def); } - const char* rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; - std::string rulesOverrideLang = - rulesOverrideBase + (lang ? std::string("_") + lang : std::string("")); - if(const char* rulesOverridePath = - this->Makefile->GetDefinition(rulesOverrideLang.c_str())) + std::string projectLangs; + for(std::set<std::string>::iterator li = testLangs.begin(); + li != testLangs.end(); ++li) { - fprintf(fout, "SET(%s \"%s\")\n", - rulesOverrideLang.c_str(), rulesOverridePath); - } - else if(const char* rulesOverridePath2 = - this->Makefile->GetDefinition(rulesOverrideBase)) - { - fprintf(fout, "SET(%s \"%s\")\n", - rulesOverrideBase, rulesOverridePath2); - } - - if(lang) - { - fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE %s)\n", lang); - } - else - { - fclose(fout); - cmOStringStream err; - err << "Unknown extension \"" << ext << "\" for file\n" - << " " << source << "\n" - << "try_compile() works only for enabled languages. " - << "Currently these are:\n "; - std::vector<std::string> langs; - this->Makefile->GetCMakeInstance()->GetGlobalGenerator()-> - GetEnabledLanguages(langs); - for(std::vector<std::string>::iterator l = langs.begin(); - l != langs.end(); ++l) + projectLangs += " " + *li; + std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; + std::string rulesOverrideLang = rulesOverrideBase + "_" + *li; + if(const char* rulesOverridePath = + this->Makefile->GetDefinition(rulesOverrideLang.c_str())) { - err << " " << *l; + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideLang.c_str(), rulesOverridePath); + } + else if(const char* rulesOverridePath2 = + this->Makefile->GetDefinition(rulesOverrideBase.c_str())) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideBase.c_str(), rulesOverridePath2); } - err << "\nSee project() command to enable other languages."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str()); - return -1; } - std::string langFlags = "CMAKE_"; - langFlags += lang; - langFlags += "_FLAGS"; + fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str()); fprintf(fout, "SET(CMAKE_VERBOSE_MAKEFILE 1)\n"); - fprintf(fout, "SET(CMAKE_%s_FLAGS \"", lang); - const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); - if(flags) + for(std::set<std::string>::iterator li = testLangs.begin(); + li != testLangs.end(); ++li) { - fprintf(fout, " %s ", flags); + fprintf(fout, "SET(CMAKE_%s_FLAGS \"", li->c_str()); + std::string langFlags = "CMAKE_" + *li + "_FLAGS"; + if(const char* flags = this->Makefile->GetDefinition(langFlags.c_str())) + { + fprintf(fout, " %s ", flags); + } + fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n"); } - fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n"); fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n"); fprintf(fout, "LINK_DIRECTORIES(${LINK_DIRECTORIES})\n"); @@ -357,7 +387,19 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", this->BinaryDirectory.c_str()); /* Create the actual executable. */ - fprintf(fout, "ADD_EXECUTABLE(%s \"%s\")\n", targetName, source.c_str()); + fprintf(fout, "ADD_EXECUTABLE(%s", targetName); + for(std::vector<std::string>::iterator si = sources.begin(); + si != sources.end(); ++si) + { + fprintf(fout, " \"%s\"", si->c_str()); + + // Add dependencies on any non-temporary sources. + if(si->find("CMakeTmp") == si->npos) + { + this->Makefile->AddCMakeDependFile(si->c_str()); + } + } + fprintf(fout, ")\n"); if (useOldLinkLibs) { fprintf(fout, @@ -371,12 +413,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } fclose(fout); projectName = "CMAKE_TRY_COMPILE"; - // if the source is not in CMakeTmp - if(source.find("CMakeTmp") == source.npos) - { - this->Makefile->AddCMakeDependFile(source.c_str()); - } - } bool erroroc = cmSystemTools::GetErrorOccuredFlag(); diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index a1505bd..a4f6ac4 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -54,8 +54,8 @@ std::string cmCryptoHash::HashFile(const char* file) this->Initialize(); // Should be efficient enough on most system: - const int bufferSize = 4096; - char buffer[bufferSize]; + cm_sha2_uint64_t buffer[512]; + char* buffer_c = reinterpret_cast<char*>(buffer); unsigned char const* buffer_uc = reinterpret_cast<unsigned char const*>(buffer); // This copy loop is very sensitive on certain platforms with @@ -65,7 +65,7 @@ std::string cmCryptoHash::HashFile(const char* file) // error occurred. Therefore, the loop should be safe everywhere. while(fin) { - fin.read(buffer, bufferSize); + fin.read(buffer_c, sizeof(buffer)); if(int gcount = static_cast<int>(fin.gcount())) { this->Append(buffer_uc, gcount); diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index a8b3847..12ee9fa 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -44,9 +44,9 @@ "used.\n" \ " $<C_COMPILER_ID:comp> = '1' if the CMake-id of the C " \ "compiler matches comp, otherwise '0'.\n" \ - " $<CXX_COMPILER_ID> = The CMake-id of the CXX compiler " \ + " $<CXX_COMPILER_ID> = The CMake-id of the CXX compiler " \ "used.\n" \ - " $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX " \ + " $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX " \ "compiler matches comp, otherwise '0'.\n" \ " $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n" \ " $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n" \ diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 689508f..ed51c47 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -561,6 +561,16 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables That Change Behavior"); cm->DefineProperty + ("CMAKE_SYSROOT", cmProperty::VARIABLE, + "Path to pass to the compiler in the --sysroot flag.", + "The CMAKE_SYSROOT content is passed to the compiler in the --sysroot " + "flag, if supported. The path is also stripped from the RPATH if " + "necessary on installation. The CMAKE_SYSROOT is also used to prefix " + "paths searched by the find_* commands.", + false, + "Variables That Change Behavior"); + + cm->DefineProperty ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, "Prefixes to prepend when looking for libraries.", "This specifies what prefixes to add to library names when " @@ -648,6 +658,10 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "WARNING: DESTDIR may not be used on Windows because installation" " prefix usually contains a drive letter like in \"C:/Program Files\"" " which cannot be prepended with some other prefix." + "\n" + "The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH " + "so that find_package, find_program, find_library, find_path, and " + "find_file will search the prefix for other software." ,false, "Variables That Change Behavior"); @@ -725,7 +739,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "adds /bin to each of the directories in the path, FIND_LIBRARY() " "appends /lib to each of the directories, and FIND_PATH() and " "FIND_FILE() append /include . By default this contains the standard " - "directories for the current system. It is NOT intended " + "directories for the current system and the CMAKE_INSTALL_PREFIX. " + "It is NOT intended " "to be modified by the project, use CMAKE_PREFIX_PATH for this. See also " "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " "CMAKE_SYSTEM_PROGRAM_PATH, and CMAKE_SYSTEM_IGNORE_PATH.", false, diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 1158fc0..30de9a8 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -19,7 +19,12 @@ #include <cmsys/CPU.h> // Include the ELF format information system header. -#include <elf.h> +#if defined(__OpenBSD__) +# include <stdint.h> +# include <elf_abi.h> +#else +# include <elf.h> +#endif #if defined(__sun) # include <sys/link.h> // For dynamic section information #endif diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index ee963f9..747448b 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -59,18 +59,21 @@ public: virtual const char* GetFullDocumentation() const { return - " enable_language(languageName [OPTIONAL] )\n" + " enable_language(<lang> [OPTIONAL] )\n" "This command enables support for the named language in CMake. " "This is the same as the project command but does not create " "any of the extra variables that are created by the project command. " "Example languages are CXX, C, Fortran. " - "If OPTIONAL is used, use the CMAKE_<languageName>_COMPILER_WORKS " - "variable to check whether the language has been enabled successfully." "\n" - "This command must be called on file scope (not inside a function) and " - "the language enabled can only be used in the calling project or its " - "subdirectories added by add_subdirectory(). Also note that at present, " - "the OPTIONAL argument does not work."; + "This command must be called in file scope, not in a function call. " + "Furthermore, it must be called in the highest directory common to " + "all targets using the named language directly for compiling sources " + "or indirectly through link dependencies. " + "It is simplest to enable all needed languages in the top-level " + "directory of a project." + "\n" + "The OPTIONAL keyword is a placeholder for future implementation " + "and does not currently work."; } cmTypeMacro(cmEnableLanguageCommand, cmCommand); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 948508b..e7b185a 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -31,8 +31,10 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; - this->FindTargets("INTERFACE_INCLUDE_DIRECTORIES", te, emittedDeps); - this->FindTargets("INTERFACE_COMPILE_DEFINITIONS", te, emittedDeps); +#define FIND_TARGETS(PROPERTY) \ + this->FindTargets(#PROPERTY, te, emittedDeps); + + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) this->PopulateProperties(te, properties, emittedDeps); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 6b02e15..d80e775 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -554,12 +554,15 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( fileIt != sFiles.end(); ++fileIt) { - std::string linkName4 = linkName3; - linkName4 += "/"; - linkName4 += - cmSystemTools::GetFilenameName((*fileIt)->GetFullPath()); - this->AppendLinkedResource(fout, linkName4, - (*fileIt)->GetFullPath(), LinkToFile); + std::string fullPath = (*fileIt)->GetFullPath(); + if (!cmSystemTools::FileIsDirectory(fullPath.c_str())) + { + std::string linkName4 = linkName3; + linkName4 += "/"; + linkName4 += cmSystemTools::GetFilenameName(fullPath); + this->AppendLinkedResource(fout, linkName4, + fullPath, LinkToFile); + } } } } diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index b44864e..5daa47d 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -62,10 +62,15 @@ void cmFindCommon::GenerateDocumentation() "The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more " "directories to be prepended to all other search directories. " "This effectively \"re-roots\" the entire search under given locations. " - "By default it is empty. It is especially useful when " + "By default it is empty. " + "The variable CMAKE_SYSROOT can also be used to specify exactly one " + "directory to use as a prefix. Setting CMAKE_SYSROOT also has other " + "effects. See the documentation for that variable for more. " + "These are especially useful when " "cross-compiling to point to the root directory of the " "target environment and CMake will search there too. By default at first " - "the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted " + "the CMAKE_SYSROOT directory is searched, then the directories listed in " + "CMAKE_FIND_ROOT_PATH and then the non-rooted " "directories will be searched. " "The default behavior can be adjusted by setting " "CMAKE_FIND_ROOT_PATH_MODE_XXX. This behavior can be manually " @@ -187,16 +192,27 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) { return; } + const char* sysroot = + this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - if((rootPath == 0) || (strlen(rootPath) == 0)) + const bool noSysroot = !sysroot || !*sysroot; + const bool noRootPath = !rootPath || !*rootPath; + if(noSysroot && noRootPath) { return; } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - cmSystemTools::ExpandListArgument(rootPath, roots); + if (sysroot) + { + roots.push_back(sysroot); + } + if (rootPath) + { + cmSystemTools::ExpandListArgument(rootPath, roots); + } for(std::vector<std::string>::iterator ri = roots.begin(); ri != roots.end(); ++ri) { diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index e5ffb0c..3e03c09 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -33,8 +33,13 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( } this->CheckResult = this->checkGraph(); - if (CheckResult == DAG && (top->EvaluatingIncludeDirectories() - || top->EvaluatingCompileDefinitions())) +#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) \ + top->METHOD () || + + if (CheckResult == DAG && ( + CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(TEST_TRANSITIVE_PROPERTY_METHOD) + false) + ) { std::map<cmStdString, std::set<cmStdString> >::const_iterator it = top->Seen.find(target); diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 8d9fd76..85b13e5 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -16,6 +16,16 @@ #include "cmGeneratorExpressionEvaluator.h" +#define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \ + F(EvaluatingIncludeDirectories) \ + F(EvaluatingCompileDefinitions) \ + F(EvaluatingCompileOptions) + +#define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ + F(INTERFACE_INCLUDE_DIRECTORIES) \ + F(INTERFACE_COMPILE_DEFINITIONS) \ + F(INTERFACE_COMPILE_OPTIONS) + //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker { @@ -38,9 +48,11 @@ struct cmGeneratorExpressionDAGChecker const std::string &expr); bool EvaluatingLinkLibraries(); - bool EvaluatingIncludeDirectories() const; - bool EvaluatingCompileDefinitions() const; - bool EvaluatingCompileOptions() const; + +#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) \ + bool METHOD () const; + +CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(DECLARE_TRANSITIVE_PROPERTY_METHOD) private: Result checkGraph() const; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 28f749d..701c547 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -266,8 +266,6 @@ struct CompilerIdNode : public cmGeneratorExpressionNode { return compilerId ? compilerId : ""; } - else - { cmsys::RegularExpression compilerIdValidator; compilerIdValidator.compile("^[A-Za-z0-9_]*$"); if (!compilerIdValidator.find(parameters.begin()->c_str())) @@ -286,7 +284,6 @@ struct CompilerIdNode : public cmGeneratorExpressionNode return "1"; } return "0"; - } } }; @@ -491,11 +488,13 @@ static const struct JoinNode : public cmGeneratorExpressionNode } } joinNode; +#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \ + , #PROPERTY + //---------------------------------------------------------------------------- static const char* targetPropertyTransitiveWhitelist[] = { - "INTERFACE_INCLUDE_DIRECTORIES" - , "INTERFACE_COMPILE_DEFINITIONS" - , "INTERFACE_COMPILE_OPTIONS" + 0 + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME) }; std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, @@ -675,7 +674,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode // No error. We just skip cyclic references. return std::string(); case cmGeneratorExpressionDAGChecker::ALREADY_SEEN: - for (size_t i = 0; + for (size_t i = 1; i < (sizeof(targetPropertyTransitiveWhitelist) / sizeof(*targetPropertyTransitiveWhitelist)); ++i) @@ -703,9 +702,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } else { - assert(dagCheckerParent->EvaluatingIncludeDirectories() - || dagCheckerParent->EvaluatingCompileDefinitions() - || dagCheckerParent->EvaluatingCompileOptions()); +#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) \ + dagCheckerParent->METHOD () || + + assert( + CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( + ASSERT_TRANSITIVE_PROPERTY_METHOD) + false); } } @@ -732,7 +735,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target; - const char **transBegin = targetPropertyTransitiveWhitelist; + const char **transBegin = targetPropertyTransitiveWhitelist + 1; const char **transEnd = targetPropertyTransitiveWhitelist + (sizeof(targetPropertyTransitiveWhitelist) / sizeof(*targetPropertyTransitiveWhitelist)); @@ -798,7 +801,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode return linkedTargetsContent; } - for (size_t i = 0; + for (size_t i = 1; i < (sizeof(targetPropertyTransitiveWhitelist) / sizeof(*targetPropertyTransitiveWhitelist)); ++i) diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 8bb5487..e7ad91a 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -11,6 +11,8 @@ ============================================================================*/ #include "cmGetCMakePropertyCommand.h" +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" #include "cmake.h" // cmGetCMakePropertyCommand diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 7d33358..985dc50 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -13,6 +13,9 @@ #include "cmake.h" #include "cmTest.h" +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmSourceFile.h" #include "cmPropertyDefinition.h" //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3e3e5e4..ad74767 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -415,7 +415,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { if(!mf->ReadListFile(0,fpath.c_str())) { - cmSystemTools::Error("Could not find cmake module file:", + cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } // if this file was found then the language was already determined @@ -445,7 +445,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, mf->GetModulesFile(determineCompiler.c_str()); if(!mf->ReadListFile(0,determineFile.c_str())) { - cmSystemTools::Error("Could not find cmake module file:", + cmSystemTools::Error("Could not find cmake module file: ", determineFile.c_str()); } needTestLanguage[lang] = true; @@ -479,7 +479,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, fpath += "Compiler.cmake"; if(!mf->ReadListFile(0,fpath.c_str())) { - cmSystemTools::Error("Could not find cmake module file:", + cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } this->SetLanguageEnabledFlag(lang, mf); @@ -498,7 +498,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake"); if(!mf->ReadListFile(0,fpath.c_str())) { - cmSystemTools::Error("Could not find cmake module file:", + cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } } @@ -524,12 +524,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, std::string informationFile = mf->GetModulesFile(fpath.c_str()); if (informationFile.empty()) { - cmSystemTools::Error("Could not find cmake module file:", + cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } else if(!mf->ReadListFile(0, informationFile.c_str())) { - cmSystemTools::Error("Could not process cmake module file:", + cmSystemTools::Error("Could not process cmake module file: ", informationFile.c_str()); } } @@ -568,7 +568,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, std::string ifpath = mf->GetModulesFile(testLang.c_str()); if(!mf->ReadListFile(0,ifpath.c_str())) { - cmSystemTools::Error("Could not find cmake module file:", + cmSystemTools::Error("Could not find cmake module file: ", ifpath.c_str()); } std::string compilerWorks = "CMAKE_"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5083cb3..d9a2620 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1719,7 +1719,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, else if(binary) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", target.GetName()); return; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c2da4a9..f943161 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -761,7 +761,7 @@ void cmLocalGenerator if(!llang) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", target.Target->GetName()); return; } @@ -1425,6 +1425,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + std::vector<std::string> implicitDirs; // Load implicit include directories for this language. std::string impDirVar = "CMAKE_"; @@ -1437,7 +1439,9 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, for(std::vector<std::string>::const_iterator i = impDirVec.begin(); i != impDirVec.end(); ++i) { - emitted.insert(*i); + std::string d = rootPath + *i; + cmSystemTools::ConvertToUnixSlashes(d); + emitted.insert(d); if (!stripImplicitInclDirs) { implicitDirs.push_back(*i); @@ -1600,7 +1604,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(!linkLanguage) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", target->Target->GetName()); return; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 4c78f7f..2527429 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1228,7 +1228,7 @@ void cmLocalVisualStudio6Generator if(!linkLanguage) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", target.GetName()); return; } @@ -1649,7 +1649,7 @@ void cmLocalVisualStudio6Generator if(!linkLanguage) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", target.GetName()); return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e7badf0..9e6a193 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -686,7 +686,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(!linkLanguage) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", target.GetName()); return; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e4219a9..271183e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -365,6 +365,22 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); + if (const char *rootPath = + this->Makefile->GetDefinition("CMAKE_SYSROOT")) + { + if (*rootPath) + { + if (const char *sysrootFlag = + this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) + { + flags += " "; + flags += sysrootFlag; + flags += this->LocalGenerator->EscapeForShell(rootPath); + flags += " "; + } + } + } + vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 347f26d..36d1a5a 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -589,6 +589,26 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::SHELL); vars.ObjectDir = objdir.c_str(); vars.Target = targetOutPathReal.c_str(); + + if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) + { + if (const char *rootPath = + this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) + { + if (*rootPath) + { + if (const char *sysrootFlag = + this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) + { + linkFlags += " "; + linkFlags += sysrootFlag; + linkFlags += this->LocalGenerator->EscapeForShell(rootPath); + linkFlags += " "; + } + } + } + } + vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); if (this->Target->HasSOName(this->ConfigName)) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 10b7849..f31b1a8 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -686,6 +686,23 @@ cmMakefileTargetGenerator cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); + + if (const char *rootPath = + this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) + { + if (*rootPath) + { + if (const char *sysrootFlag = + this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) + { + flags += " "; + flags += sysrootFlag; + flags += this->LocalGenerator->EscapeForShell(rootPath); + flags += " "; + } + } + } + vars.Flags = flags.c_str(); std::string definesString = "$("; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1bc4302..6d352ed 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -71,7 +71,8 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() void cmNinjaNormalTargetGenerator::Generate() { if (!this->TargetLinkLanguage) { - cmSystemTools::Error("CMake can not determine linker language for target:", + cmSystemTools::Error("CMake can not determine linker language for " + "target: ", this->GetTarget()->GetName()); return; } @@ -223,7 +224,27 @@ cmNinjaNormalTargetGenerator vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - vars.Flags = "$FLAGS"; + + std::string flags = "$FLAGS"; + + if (const char *rootPath = + this->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT")) + { + if (*rootPath) + { + if (const char *sysrootFlag = + this->GetMakefile()->GetDefinition("CMAKE_SYSROOT_FLAG")) + { + flags += " "; + flags += sysrootFlag; + flags += this->GetLocalGenerator()->EscapeForShell(rootPath); + flags += " "; + } + } + } + + vars.Flags = flags.c_str(); + vars.LinkFlags = "$LINK_FLAGS"; std::string langFlags; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ae18a48..43b7baa 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -414,7 +414,23 @@ cmNinjaTargetGenerator cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", mf->GetDefinition("CMAKE_C_COMPILER")); flags += " " + depFlagsStr; - } + + if (const char *rootPath = + this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) + { + if (*rootPath) + { + if (const char *sysrootFlag = + this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) + { + flags += " "; + flags += sysrootFlag; + flags += this->LocalGenerator->EscapeForShell(rootPath); + flags += " "; + } + } + } + } vars.Flags = flags.c_str(); diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 5de93fb..05c43c4 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -495,7 +495,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, if (!makefile->ReadListFile(0, filename.c_str())) { - cmSystemTools::Error("Error processing file:", filename.c_str()); + cmSystemTools::Error("Error processing file: ", filename.c_str()); return false; } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 1fbde01..68ba13f 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -534,8 +534,12 @@ void cmStringCommand::ClearMatches(cmMakefile* mf) { char name[128]; sprintf(name, "CMAKE_MATCH_%d", i); - mf->AddDefinition(name, ""); - mf->MarkVariableAsUsed(name); + const char* s = mf->GetDefinition(name); + if(s && *s != 0) + { + mf->AddDefinition(name, ""); + mf->MarkVariableAsUsed(name); + } } } @@ -544,10 +548,14 @@ void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) { for (unsigned int i=0; i<10; i++) { - char name[128]; - sprintf(name, "CMAKE_MATCH_%d", i); - mf->AddDefinition(name, re.match(i).c_str()); - mf->MarkVariableAsUsed(name); + std::string m = re.match(i); + if(m.size() > 0) + { + char name[128]; + sprintf(name, "CMAKE_MATCH_%d", i); + mf->AddDefinition(name, re.match(i).c_str()); + mf->MarkVariableAsUsed(name); + } } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 803d0da..d294104 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1951,7 +1951,7 @@ bool extract_tar(const char* outFileName, bool verbose, { cmSystemTools::Error("Problem with archive_write_header(): ", archive_error_string(ext)); - cmSystemTools::Error("Current file:", + cmSystemTools::Error("Current file: ", archive_entry_pathname(entry)); break; } @@ -2425,7 +2425,10 @@ bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath, RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE); std::vector<std::string> strs = cmSystemTools::tokenize(output, "\n"); - if(strs.size() == 2) + // otool returns extra lines reporting multiple install names + // in case the binary is multi-arch and none of the architectures + // is native (e.g. i386;ppc on x86_64) + if(strs.size() >= 2) { soname = strs[1]; return true; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index f5be26b..ec53929 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -274,7 +274,7 @@ public: static bool GetRunCommandOutput() { return s_DisableRunCommandOutput; } /** - * Come constants for different file formats. + * Some constants for different file formats. */ enum FileFormat { NO_FILE_FORMAT = 0, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7d25b91..b14db43 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1403,6 +1403,11 @@ void cmTarget::DefineProperties(cmake *cm) "Sets the \"RootNamespace\" attribute for a generated Visual Studio " "project. The attribute will be generated only if this is set."); cm->DefineProperty + ("VS_DOTNET_TARGET_FRAMEWORK_VERSION", cmProperty::TARGET, + "Specify the .NET target framework version.", + "Used to specify the .NET target framework version for C++/CLI. " + "For example, \"v4.5\"."); + cm->DefineProperty ("VS_DOTNET_REFERENCES", cmProperty::TARGET, "Visual Studio managed project .NET references", "Adds one or more semicolon-delimited .NET references to a " diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 6caa130..163756d 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -64,16 +64,16 @@ public: "Specify targetName to build a specific target instead of the 'all' or " "'ALL_BUILD' target." "\n" - " try_compile(RESULT_VAR <bindir> <srcfile>\n" + " try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...>\n" " [CMAKE_FLAGS flags...]\n" " [COMPILE_DEFINITIONS flags...]\n" " [LINK_LIBRARIES libs...]\n" " [OUTPUT_VARIABLE <var>]\n" " [COPY_FILE <fileName>])\n" - "Try building a source file into an executable. " - "In this form the user need only supply a source file that defines " - "a 'main'. " - "CMake will create a CMakeLists.txt file to build the source " + "Try building an executable from one or more source files. " + "In this form the user need only supply one or more source files " + "that include a definition for 'main'. " + "CMake will create a CMakeLists.txt file to build the source(s) " "as an executable. " "Specify COPY_FILE to get a copy of the linked executable at the " "given fileName." diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f8de3a8..7e3f444 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -280,6 +280,13 @@ void cmVisualStudio10TargetGenerator::Generate() } this->WriteString("<ProjectName>", 2); (*this->BuildFileStream) << projLabel << "</ProjectName>\n"; + if(const char* targetFrameworkVersion = this->Target->GetProperty( + "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) + { + this->WriteString("<TargetFrameworkVersion>", 2); + (*this->BuildFileStream) << targetFrameworkVersion + << "</TargetFrameworkVersion>\n"; + } this->WriteString("</PropertyGroup>\n", 1); this->WriteString("<Import Project=" "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n", @@ -1242,7 +1249,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if(!linkLanguage) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", this->Name.c_str()); return false; } @@ -1422,7 +1429,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) if(!linkLanguage) { cmSystemTools::Error - ("CMake can not determine linker language for target:", + ("CMake can not determine linker language for target: ", this->Name.c_str()); return false; } @@ -1504,7 +1511,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) if(!pcli) { cmSystemTools::Error - ("CMake can not compute cmComputeLinkInformation for target:", + ("CMake can not compute cmComputeLinkInformation for target: ", this->Name.c_str()); return false; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9352e33..29d9bb3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -549,7 +549,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args, } if (!lg->GetMakefile()->ReadListFile(0, path)) { - cmSystemTools::Error("Error processing file:", path); + cmSystemTools::Error("Error processing file: ", path); } } @@ -1168,9 +1168,8 @@ void CMakeCommandUsage(const char* program) << " remove_directory dir - remove a directory and its contents\n" << " rename oldname newname - rename a file or directory " "(on one volume)\n" - << " tar [cxt][vfz][cvfj] file.tar " - "file/dir1 file/dir2 ... - create a tar " - "archive\n" + << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n" + << " - create or extract a tar or zip archive\n" << " time command [args] ... - run command and return elapsed time\n" << " touch file - touch a file.\n" << " touch_nocreate file - touch a file but do not create it.\n" @@ -2643,7 +2642,8 @@ const char* cmake::GetCacheDefinition(const char* name) const void cmake::AddDefaultCommands() { std::list<cmCommand*> commands; - GetBootstrapCommands(commands); + GetBootstrapCommands1(commands); + GetBootstrapCommands2(commands); GetPredefinedCommands(commands); for(std::list<cmCommand*>::iterator i = commands.begin(); i != commands.end(); ++i) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b742dad..b660442 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -245,7 +245,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) set_tests_properties(EmptyLibrary PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") + PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") ADD_TEST_MACRO(CrossCompile CrossCompile) set_tests_properties(CrossCompile PROPERTIES PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") @@ -1640,7 +1640,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails # this test. (See #13371) # Apparently Visual Studio does not support it either. As the MakeClean diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake new file mode 100644 index 0000000..1655eb4 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(HOSTNAME) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake new file mode 100644 index 0000000..1f056d5 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT FQDN HOSTNAME) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake new file mode 100644 index 0000000..9c5a558 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT RESULT QUERY FOOBAR) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake new file mode 100644 index 0000000..1c3156d --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake @@ -0,0 +1,5 @@ +cmake_host_system_information(RESULT RESULT + QUERY NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES +) + +message("[${RESULT}]") diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in new file mode 100644 index 0000000..3294a2f --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in @@ -0,0 +1,33 @@ +set(BadArg1-RESULT 1) +set(BadArg1-STDERR "missing RESULT specification") +set(BadArg2-RESULT 1) +set(BadArg2-STDERR "missing QUERY specification") +set(BadArg3-RESULT 1) +set(BadArg3-STDERR "does not recognize <key> FOOBAR") +set(QueryList-RESULT 0) +set(QueryList-STDERR "\\[[0-9]+;[0-9]+\\]") + +function(try_and_print key) + cmake_host_system_information(RESULT RESULT QUERY ${key}) + message(STATUS "[${key}] [${RESULT}]") +endfunction() + +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +try_and_print(NUMBER_OF_LOGICAL_CORES) +try_and_print(NUMBER_OF_PHYSICAL_CORES) +try_and_print(HOSTNAME) +try_and_print(FQDN) +try_and_print(TOTAL_VIRTUAL_MEMORY) +try_and_print(AVAILABLE_VIRTUAL_MEMORY) +try_and_print(TOTAL_PHYSICAL_MEMORY) +try_and_print(AVAILABLE_PHYSICAL_MEMORY) + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + +check_cmake_test(CMakeHostSystemInformation + BadArg1 + BadArg2 + BadArg3 + QueryList +) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index b049995..344b772 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -32,6 +32,7 @@ AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "-DKWSYS_TEST_EXE=$<TARGET_FILE:cmsysTestsCxx>") AddCMakeTest(PushCheckState "") AddCMakeTest(While "") +AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY diff --git a/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt index 3f93cf8..983129a 100644 --- a/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt +++ b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt @@ -1 +1 @@ -CMake Error: CMake can not determine linker language for target:NoLang +CMake Error: CMake can not determine linker language for target: NoLang diff --git a/Tests/RunCMake/try_compile/BadSources1-result.txt b/Tests/RunCMake/try_compile/BadSources1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/BadSources1-stderr.txt b/Tests/RunCMake/try_compile/BadSources1-stderr.txt new file mode 100644 index 0000000..864a294 --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources1-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadSources1.cmake:1 \(try_compile\): + Unknown extension ".c" for file + + .*/Tests/RunCMake/try_compile/src.c + + try_compile\(\) works only for enabled languages. Currently these are: + + NONE + + See project\(\) command to enable other languages. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/BadSources1.cmake b/Tests/RunCMake/try_compile/BadSources1.cmake new file mode 100644 index 0000000..aa4dc5e --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources1.cmake @@ -0,0 +1 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c) diff --git a/Tests/RunCMake/try_compile/BadSources2-result.txt b/Tests/RunCMake/try_compile/BadSources2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/BadSources2-stderr.txt b/Tests/RunCMake/try_compile/BadSources2-stderr.txt new file mode 100644 index 0000000..3313f99 --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources2-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadSources2.cmake:2 \(try_compile\): + Unknown extension ".cxx" for file + + .*/Tests/RunCMake/try_compile/src.cxx + + try_compile\(\) works only for enabled languages. Currently these are: + + C NONE( RC)? + + See project\(\) command to enable other languages. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/BadSources2.cmake b/Tests/RunCMake/try_compile/BadSources2.cmake new file mode 100644 index 0000000..ed2b036 --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources2.cmake @@ -0,0 +1,5 @@ +enable_language(C) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ${CMAKE_CURRENT_SOURCE_DIR}/src.cxx + ) diff --git a/Tests/RunCMake/try_compile/NoSources-result.txt b/Tests/RunCMake/try_compile/NoSources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/NoSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/NoSources-stderr.txt b/Tests/RunCMake/try_compile/NoSources-stderr.txt new file mode 100644 index 0000000..023032b --- /dev/null +++ b/Tests/RunCMake/try_compile/NoSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoSources.cmake:1 \(try_compile\): + SOURCES must be followed by at least one source file +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/NoSources.cmake b/Tests/RunCMake/try_compile/NoSources.cmake new file mode 100644 index 0000000..8a73af4 --- /dev/null +++ b/Tests/RunCMake/try_compile/NoSources.cmake @@ -0,0 +1 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} SOURCES) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 31643cf..3494695 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -7,6 +7,9 @@ run_cmake(NoCopyFile) run_cmake(NoCopyFile2) run_cmake(NoOutputVariable) run_cmake(NoOutputVariable2) +run_cmake(NoSources) run_cmake(BadLinkLibraries) +run_cmake(BadSources1) +run_cmake(BadSources2) run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index b6b66d8..4540fd0 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -71,6 +71,24 @@ if(SHOULD_FAIL) message(SEND_ERROR "Should fail passed ${TRY_OUT}") endif() +# try to compile two files that should compile +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() + +# try to compile two files that should not compile +try_compile(SHOULD_FAIL + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c + OUTPUT_VARIABLE TRY_OUT) +if(SHOULD_FAIL) + message(SEND_ERROR "Should fail passed ${TRY_OUT}") +endif() + if(NOT SHOULD_FAIL) if(SHOULD_PASS) message("All Tests passed, ignore all previous output.") diff --git a/Tests/TryCompile/fail2a.c b/Tests/TryCompile/fail2a.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/TryCompile/fail2a.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/TryCompile/fail2b.c b/Tests/TryCompile/fail2b.c new file mode 100644 index 0000000..5ee809c --- /dev/null +++ b/Tests/TryCompile/fail2b.c @@ -0,0 +1 @@ +does_not_compile diff --git a/Tests/TryCompile/pass2a.c b/Tests/TryCompile/pass2a.c new file mode 100644 index 0000000..bbfe6d5 --- /dev/null +++ b/Tests/TryCompile/pass2a.c @@ -0,0 +1,2 @@ +extern int pass2b(void); +int main() { return pass2b(); } diff --git a/Tests/TryCompile/pass2b.cxx b/Tests/TryCompile/pass2b.cxx new file mode 100644 index 0000000..4c539e2 --- /dev/null +++ b/Tests/TryCompile/pass2b.cxx @@ -0,0 +1 @@ +extern "C" int pass2b(void) { return 0; } @@ -247,7 +247,8 @@ CMAKE_CXX_SOURCES="\ cmMakefileUtilityTargetGenerator \ cmOSXBundleGenerator \ cmNewLineStyle \ - cmBootstrapCommands \ + cmBootstrapCommands1 \ + cmBootstrapCommands2 \ cmCommands \ cmTarget \ cmTest \ @@ -1449,11 +1450,15 @@ for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_ objs="${objs} ${a}.o" done -# Generate dependencies for cmBootstrapCommands.cxx -for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do - cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`" +# Generate dependencies for cmBootstrapCommands1.cxx +for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands1.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do + cmBootstrapCommands1Deps="${cmBootstrapCommands1Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`" done -cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps` +cmBootstrapCommands1Deps=`echo $cmBootstrapCommands1Deps` +for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands2.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do + cmBootstrapCommands2Deps="${cmBootstrapCommands2Deps} `cmake_escape "${cmake_source_dir}/Source/$file"`" +done +cmBootstrapCommands2Deps=`echo $cmBootstrapCommands2Deps` if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}" @@ -1486,7 +1491,8 @@ for a in ${CMAKE_CXX_SOURCES}; do echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done -echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile" +echo "cmBootstrapCommands1.o : $cmBootstrapCommands1Deps" >> "${cmake_bootstrap_dir}/Makefile" +echo "cmBootstrapCommands2.o : $cmBootstrapCommands2Deps" >> "${cmake_bootstrap_dir}/Makefile" for a in ${CMAKE_C_SOURCES}; do src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"` echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" |