diff options
-rw-r--r-- | Modules/FindBLAS.cmake | 96 | ||||
-rw-r--r-- | Modules/Platform/Windows-GNU.cmake | 3 | ||||
-rw-r--r-- | Modules/ProcessorCount.cmake | 183 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 4 | ||||
-rw-r--r-- | Source/cmDocumentVariables.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 31 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 14 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 2 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 40 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 4 | ||||
-rw-r--r-- | Source/kwsys/kwsysDateStamp.cmake | 2 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 57 | ||||
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/ProcessorCountTest.cmake.in | 72 |
19 files changed, 479 insertions, 66 deletions
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d57513c..ae4a13f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -23,7 +23,7 @@ ########## ### List of vendors (BLA_VENDOR) valid in this module ## ATLAS, PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model), -## Intel( older versions of mkl 32 and 64 bit), ACML,Apple, NAS, Generic +## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,Apple, NAS, Generic # C/CXX should be enabled to use Intel mkl #============================================================================= @@ -39,12 +39,23 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) -if (NOT _LANGUAGES_ MATCHES Fortran) include(CheckFunctionExists) -else () include(CheckFortranFunctionExists) -endif() + +# Check the language being used +get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) +if( _LANGUAGES_ MATCHES Fortran ) + set( _CHECK_FORTRAN TRUE ) +elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) ) + set( _CHECK_FORTRAN FALSE ) +else() + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") + else(BLAS_FIND_REQUIRED) + message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)") + return() + endif(BLAS_FIND_REQUIRED) +endif( ) macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) # This macro checks for the existence of the combination of fortran libraries @@ -102,7 +113,7 @@ if(_libraries_work) # Test this combination of libraries. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads}) # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") - if (_LANGUAGES_ MATCHES Fortran) + if (_CHECK_FORTRAN) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) @@ -244,7 +255,76 @@ if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") #BLAS in acml library? -if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") +# the patch from Chuck Atkins: + if( ((_BLAS_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((_BLAS_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) ) + if( WIN32 ) + file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) + else() + file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) + endif() + if( _ACML_ROOT ) + get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) + if( SIZEOF_INTEGER EQUAL 8 ) + set( _ACML_PATH_SUFFIX "_int64" ) + else() + set( _ACML_PATH_SUFFIX "" ) + endif() + if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) + set( _ACML_COMPILER32 "ifort32" ) + set( _ACML_COMPILER64 "ifort64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) + set( _ACML_COMPILER32 "sun32" ) + set( _ACML_COMPILER64 "sun64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) + set( _ACML_COMPILER32 "pgi32" ) + if( WIN32 ) + set( _ACML_COMPILER64 "win64" ) + else() + set( _ACML_COMPILER64 "pgi64" ) + endif() + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) + # 32 bit builds not supported on Open64 but for code simplicity + # We'll just use the same directory twice + set( _ACML_COMPILER32 "open64_64" ) + set( _ACML_COMPILER64 "open64_64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) + set( _ACML_COMPILER32 "nag32" ) + set( _ACML_COMPILER64 "nag64" ) + else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" ) + set( _ACML_COMPILER32 "gfortran32" ) + set( _ACML_COMPILER64 "gfortran64" ) + endif() + + if( _BLAS_VENDOR STREQUAL "ACML_MP" ) + set(_ACML_MP_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) + else() #if( _BLAS_VENDOR STREQUAL "ACML" ) + set(_ACML_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) + endif() + endif() + endif() + + if( _BLAS_VENDOR STREQUAL "ACML_MP" ) + foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS} ) + _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml_mp;acml_mv" "" ) + if( BLAS_${_BLAS_VENDOR}_FOUND ) + break() + endif() + endforeach() + else() #if( _BLAS_VENDOR STREQUAL "ACML" ) + foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) + _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml;acml_mv" "" ) + if( BLAS_${_BLAS_VENDOR}_FOUND ) + break() + endif() + endforeach() + endif() + # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both if(NOT BLAS_LIBRARIES) check_fortran_libraries( @@ -266,7 +346,7 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") "" ) endif(NOT BLAS_LIBRARIES) -endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") +endif () # ACML # Apple BLAS library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 72b5d62..1d3e4b5 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -79,6 +79,7 @@ macro(__windows_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) # We prefer "@" for response files but it is not supported by gcc 3. execute_process(COMMAND ${CMAKE_${lang}_COMPILER} --version OUTPUT_VARIABLE _ver ERROR_VARIABLE _ver) @@ -92,6 +93,8 @@ macro(__windows_compiler_gnu lang) # Use "-Wl,@" to pass the response file to the linker. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@") endif() + # The GNU 3.x compilers do not support response files (only linkers). + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0) elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS) # Use "@" to pass the response file to the front-end. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake new file mode 100644 index 0000000..eff4766 --- /dev/null +++ b/Modules/ProcessorCount.cmake @@ -0,0 +1,183 @@ +# - ProcessorCount(var) +# Determine the number of processors/cores and save value in ${var} +# +# Sets the variable named ${var} to the number of physical cores available on +# the machine if the information can be determined. Otherwise it is set to 0. +# Currently this functionality is implemented for AIX, cygwin, FreeBSD, HPUX, +# IRIX, Linux, Mac OS X, QNX, Sun and Windows. +# +# This function is guaranteed to return a positive integer (>=1) if it +# succeeds. It returns 0 if there's a problem determining the processor count. +# +# Example use, in a ctest -S dashboard script: +# +# include(ProcessorCount) +# ProcessorCount(N) +# if(NOT N EQUAL 0) +# set(CTEST_BUILD_FLAGS -j${N}) +# set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +# endif() +# +# This function is intended to offer an approximation of the value of the +# number of compute cores available on the current machine, such that you +# may use that value for parallel building and parallel testing. It is meant +# to help utilize as much of the machine as seems reasonable. Of course, +# knowledge of what else might be running on the machine simultaneously +# should be used when deciding whether to request a machine's full capacity +# all for yourself. + +# A more reliable way might be to compile a small C program that uses the CPUID +# instruction, but that again requires compiler support or compiling assembler +# code. + +#============================================================================= +# Copyright 2010-2011 Kitware, Inc. +# +# 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. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(ProcessorCount var) + # Unknown: + set(count 0) + + if(WIN32) + # Windows: + set(count "$ENV{NUMBER_OF_PROCESSORS}") + #message("ProcessorCount: WIN32, trying environment variable") + endif() + + if(NOT count) + # Mac, FreeBSD, OpenBSD (systems with sysctl): + find_program(ProcessorCount_cmd_sysctl sysctl + PATHS /usr/sbin /sbin) + if(ProcessorCount_cmd_sysctl) + execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE count) + #message("ProcessorCount: trying sysctl '${ProcessorCount_cmd_sysctl}'") + endif() + endif() + + if(NOT count) + # Linux (systems with getconf): + find_program(ProcessorCount_cmd_getconf getconf) + if(ProcessorCount_cmd_getconf) + execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE count) + #message("ProcessorCount: trying getconf '${ProcessorCount_cmd_getconf}'") + endif() + endif() + + if(NOT count) + # HPUX (systems with machinfo): + find_program(ProcessorCount_cmd_machinfo machinfo + PATHS /usr/contrib/bin) + if(ProcessorCount_cmd_machinfo) + execute_process(COMMAND ${ProcessorCount_cmd_machinfo} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE machinfo_output) + string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'") + endif() + endif() + + if(NOT count) + # IRIX (systems with hinv): + find_program(ProcessorCount_cmd_hinv hinv + PATHS /sbin) + if(ProcessorCount_cmd_hinv) + execute_process(COMMAND ${ProcessorCount_cmd_hinv} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE hinv_output) + string(REGEX MATCHALL "([0-9]+) .* Processors" procs "${hinv_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying hinv '${ProcessorCount_cmd_hinv}'") + endif() + endif() + + if(NOT count) + # AIX (systems with lsconf): + find_program(ProcessorCount_cmd_lsconf lsconf + PATHS /usr/sbin) + if(ProcessorCount_cmd_lsconf) + execute_process(COMMAND ${ProcessorCount_cmd_lsconf} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE lsconf_output) + string(REGEX MATCHALL "Number Of Processors: ([0-9]+)" procs "${lsconf_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying lsconf '${ProcessorCount_cmd_lsconf}'") + endif() + endif() + + if(NOT count) + # QNX (systems with pidin): + find_program(ProcessorCount_cmd_pidin pidin) + if(ProcessorCount_cmd_pidin) + execute_process(COMMAND ${ProcessorCount_cmd_pidin} info + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE pidin_output) + string(REGEX MATCHALL "Processor[0-9]+: " procs "${pidin_output}") + list(LENGTH procs count) + #message("ProcessorCount: trying pidin '${ProcessorCount_cmd_pidin}'") + endif() + endif() + + if(NOT count) + # Sun (systems where uname -X emits "NumCPU" in its output): + find_program(ProcessorCount_cmd_uname uname) + if(ProcessorCount_cmd_uname) + execute_process(COMMAND ${ProcessorCount_cmd_uname} -X + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE uname_X_output) + string(REGEX MATCHALL "NumCPU = ([0-9]+)" procs "${uname_X_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying uname -X '${ProcessorCount_cmd_uname}'") + endif() + endif() + + # Execute this code when all previously attempted methods return empty + # output: + # + if(NOT count) + # Systems with /proc/cpuinfo: + set(cpuinfo_file /proc/cpuinfo) + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs count) + #message("ProcessorCount: trying cpuinfo '${cpuinfo_file}'") + endif() + endif() + + # Since cygwin builds of CMake do not define WIN32 anymore, but they still + # run on Windows, and will still have this env var defined: + # + if(NOT count) + set(count "$ENV{NUMBER_OF_PROCESSORS}") + #message("ProcessorCount: last fallback, trying environment variable") + endif() + + # Ensure an integer return (avoid inadvertently returning an empty string + # or an error string)... If it's not a decimal integer, return 0: + # + if(NOT count MATCHES "^[0-9]+$") + set(count 0) + endif() + + set(${var} ${count} PARENT_SCOPE) +endfunction() diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index d3320c0..ca2185c 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -96,6 +96,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake" << std::endl); retval = 0; + return retval; } cmsys::Glob gl; @@ -105,7 +106,7 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) if ( !gl.FindFiles(findExpr) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot find any files in the installed directory" << std::endl); + "Cannot find any files in the installed directory" << std::endl); return 0; } packageFiles = gl.GetFiles(); @@ -152,8 +153,8 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake" << std::endl); retval = 0; + return retval; } - cmsys::Glob gl; std::string findExpr(this->GetOption("WDIR")); findExpr += "/*"; @@ -230,6 +231,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(bool allComponent) cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake" << std::endl); retval = 0; + return retval; } cmsys::Glob gl; @@ -288,8 +290,11 @@ int cmCPackDebGenerator::PackageFiles() "Error while execution CPackDeb.cmake" << std::endl); retval = 0; } - packageFiles = files; - return createDeb(); + else + { + packageFiles = files; + return createDeb(); + } } return retval; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 5f314c6..c343acf 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -885,8 +885,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( //---------------------------------------------------------------------- bool cmCPackGenerator::ReadListFile(const char* moduleName) { + bool retval; std::string fullPath = this->MakefileMap->GetModulesFile(moduleName); - return this->MakefileMap->ReadListFile(0, fullPath.c_str()); + retval = this->MakefileMap->ReadListFile(0, fullPath.c_str()); + // include FATAL_ERROR and ERROR in the return status + retval = retval && (! cmSystemTools::GetErrorOccuredFlag()); + return retval; } //---------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 9678ac4..86bd85d 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -93,6 +93,7 @@ static const char* cmCTestErrorMatches[] = { ": No such file or directory", ": Invalid argument", "^The project cannot be built\\.", + "^\\[ERROR\\]", 0 }; @@ -119,7 +120,7 @@ static const char* cmCTestWarningMatches[] = { "^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)", "([^:]+): warning[ \\t]*[0-9]+[ \\t]*:", "^(Warning|Warnung) ([0-9]+):", - "^(Warning|Warnung) ", + "^(Warning|Warnung)[ :]", "WARNING: ", "([^ :]+) : warning", "([^:]+): warning", @@ -131,6 +132,7 @@ static const char* cmCTestWarningMatches[] = { "\".*\", line [0-9]+: remark\\([0-9]*\\):", "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", "^CMake Warning.*:", + "^\\[WARNING\\]", 0 }; diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index bb6dc3f..f2431e6 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1475,6 +1475,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES_INIT", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_INCLUDES", + cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_OBJECTS", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_EXECUTABLE_SUFFIX_<LANG>", diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index cd265c1..7b3fc86 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -575,6 +575,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, flags += this->Makefile->GetSafeDefinition(varString.c_str()); flags += " "; flags += this->GetIncludeFlags(lang); + flags += this->Makefile->GetDefineFlags(); // Construct the command lines. cmCustomCommandLines commandLines; @@ -1184,15 +1185,18 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, } //---------------------------------------------------------------------------- -const char* cmLocalGenerator::GetIncludeFlags(const char* lang) +const char* cmLocalGenerator::GetIncludeFlags(const char* lang, + bool forResponseFile) { if(!lang) { return ""; } - if(this->LanguageToIncludeFlags.count(lang)) + std::string key = lang; + key += forResponseFile? "@" : ""; + if(this->LanguageToIncludeFlags.count(key)) { - return this->LanguageToIncludeFlags[lang].c_str(); + return this->LanguageToIncludeFlags[key].c_str(); } cmOStringStream includeFlags; @@ -1250,10 +1254,10 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); if(emitted.insert(frameworkDir).second) { + OutputFormat format = forResponseFile? RESPONSE : SHELL; includeFlags << "-F" << this->Convert(frameworkDir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL, true) + START_OUTPUT, format, true) << " "; } continue; @@ -1273,7 +1277,16 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) } flagUsed = true; } - std::string includePath = this->ConvertToOutputForExisting(i->c_str()); + std::string includePath; + if(forResponseFile) + { + includePath = this->Convert(i->c_str(), START_OUTPUT, + RESPONSE, true); + } + else + { + includePath = this->ConvertToOutputForExisting(i->c_str()); + } if(quotePaths && includePath.size() && includePath[0] != '\"') { includeFlags << "\""; @@ -1291,13 +1304,11 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) { flags[flags.size()-1] = ' '; } - std::string defineFlags = this->Makefile->GetDefineFlags(); - flags += defineFlags; - this->LanguageToIncludeFlags[lang] = flags; + this->LanguageToIncludeFlags[key] = flags; // Use this temorary variable for the return value to work-around a // bogus GCC 2.95 warning. - const char* ret = this->LanguageToIncludeFlags[lang].c_str(); + const char* ret = this->LanguageToIncludeFlags[key].c_str(); return ret; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 35aab99..aebf9f3 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -143,7 +143,8 @@ public: const char* config); virtual void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language - const char* GetIncludeFlags(const char* lang); + const char* GetIncludeFlags(const char* lang, + bool forResponseFile = false); /** * Encode a list of preprocessor definitions for the compiler diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ff48009..d1214d2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -883,6 +883,20 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 +::AppendRuleDepends(std::vector<std::string>& depends, + std::vector<std::string> const& ruleFiles) +{ + // Add a dependency on the rule file itself unless an option to skip + // it is specifically enabled by the user or project. + if(!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY")) + { + depends.insert(depends.end(), ruleFiles.begin(), ruleFiles.end()); + } +} + +//---------------------------------------------------------------------------- +void +cmLocalUnixMakefileGenerator3 ::AppendCustomDepends(std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 790eff1..9ff6e5e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -320,6 +320,8 @@ protected: void AppendRuleDepend(std::vector<std::string>& depends, const char* ruleFileName); + void AppendRuleDepends(std::vector<std::string>& depends, + std::vector<std::string> const& ruleFiles); void AppendCustomDepends(std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs); void AppendCustomDepend(std::vector<std::string>& depends, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 4426241..cd75d79 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -47,12 +47,12 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write rules used to help build object files this->WriteCommonCodeRules(); - // write in rules for object files and custom commands - this->WriteTargetBuildRules(); - // write the per-target per-language flags this->WriteTargetLanguageFlags(); + // write in rules for object files and custom commands + this->WriteTargetBuildRules(); + // write the link rules this->WriteExecutableRule(false); if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 1e9a670..31f7be5 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -72,12 +72,12 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() // write rules used to help build object files this->WriteCommonCodeRules(); - // write in rules for object files and custom commands - this->WriteTargetBuildRules(); - // write the per-target per-language flags this->WriteTargetLanguageFlags(); + // write in rules for object files and custom commands + this->WriteTargetBuildRules(); + // write the link rules // Write the rule for this target type. switch(this->Target->GetType()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 9dcd8f1..69320da 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -310,8 +310,12 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() this->LocalGenerator->AddSharedFlags(flags, lang, shared); // Add include directory flags. + this->AddIncludeFlags(flags, lang); + + // Append old-style preprocessor definition flags. this->LocalGenerator-> - AppendFlags(flags, this->LocalGenerator->GetIncludeFlags(lang)); + AppendFlags(flags, this->Makefile->GetDefineFlags()); + // Add include directory flags. this->LocalGenerator-> AppendFlags(flags,this->GetFrameworkFlags().c_str()); @@ -482,6 +486,8 @@ cmMakefileTargetGenerator { this->LocalGenerator->AppendRuleDepend(depends, this->FlagFileNameFull.c_str()); + this->LocalGenerator->AppendRuleDepends(depends, + this->FlagFileDepends[lang]); // generate the depend scanning rule this->WriteObjectDependRules(source, depends); @@ -1720,6 +1726,38 @@ cmMakefileTargetGenerator } //---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, + const char* lang) +{ + std::string responseVar = "CMAKE_"; + responseVar += lang; + responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES"; + bool useResponseFile = this->Makefile->IsOn(responseVar.c_str()); + + std::string includeFlags = + this->LocalGenerator->GetIncludeFlags(lang, useResponseFile); + if(includeFlags.empty()) + { + return; + } + + if(useResponseFile) + { + std::string name = "includes_"; + name += lang; + name += ".rsp"; + std::string arg = "@" + + this->CreateResponseFile(name.c_str(), includeFlags, + this->FlagFileDepends[lang]); + this->LocalGenerator->AppendFlags(flags, arg.c_str()); + } + else + { + this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); + } +} + +//---------------------------------------------------------------------------- const char* cmMakefileTargetGenerator::GetFortranModuleDirectory() { // Compute the module directory. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index c9aede2..bd26795 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -146,6 +146,8 @@ protected: bool useResponseFile, std::string& buildObjs, std::vector<std::string>& makefile_depends); + void AddIncludeFlags(std::string& flags, const char* lang); + virtual void CloseFileStreams(); void RemoveForbiddenFlags(const char* flagVar, const char* linkLang, std::string& linkFlags); @@ -177,6 +179,8 @@ protected: // the stream for the flag file std::string FlagFileNameFull; cmGeneratedFileStream *FlagFileStream; + class StringList: public std::vector<std::string> {}; + std::map<cmStdString, StringList> FlagFileDepends; // the stream for the info file std::string InfoFileNameFull; diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index aef40fc..3ec53f7 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 03) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 18) +SET(KWSYS_DATE_STAMP_DAY 22) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6da06f6..77c5752 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1868,39 +1868,30 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF() ENDIF() - if(NOT DEFINED CTEST_RUN_Java) - if(APPLE) - set(CTEST_RUN_Java OFF) - else() - set(CTEST_RUN_Java ON) - endif() - endif() - - IF(CTEST_RUN_Java) - find_package(Java QUIET) - IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) - GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) - FIND_FILE(JNI_H jni.h - "${JNIPATH}/../include" - "${JNIPATH}/../java/include") - IF(JNI_H) - FILE(READ "${JNI_H}" JNI_FILE) - IF("${JNI_FILE}" MATCHES "JDK1_2") - ADD_TEST(Java ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/Java" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project hello - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" - --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") - ENDIF("${JNI_FILE}" MATCHES "JDK1_2") - ENDIF(JNI_H) - ENDIF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) - ENDIF(CTEST_RUN_Java) + find_package(Java QUIET) + IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW + AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode") + GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) + FIND_FILE(JNI_H jni.h + "${JNIPATH}/../include" + "${JNIPATH}/../java/include") + IF(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink + FILE(READ "${JNI_H}" JNI_FILE) + IF("${JNI_FILE}" MATCHES "JDK1_2") + ADD_TEST(Java ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/Java" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project hello + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") + ENDIF("${JNI_FILE}" MATCHES "JDK1_2") + ENDIF() + ENDIF() # add some cross compiler tests, for now only with makefile based generators IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index cceef3b..5cb50c9 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -27,6 +27,7 @@ AddCMakeTest(String "") AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") +AddCMakeTest(ProcessorCount "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in new file mode 100644 index 0000000..98f6ab1 --- /dev/null +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -0,0 +1,72 @@ +include(ProcessorCount) + +ProcessorCount(processor_count) + +message("### 1. This line should be the first line of text in the test output.") +message("### 2. If there was output from this test before line #1, then the") +message("### 3. ProcessorCount(...) function call is emitting output that it shouldn't...") + +message("processor_count='${processor_count}'") + +execute_process( + COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx" + testSystemInformation + OUTPUT_VARIABLE tsi_out + ERROR_VARIABLE tsi_err) +string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2" + system_info_processor_count "${tsi_out}") + +message("system_info_processor_count='${system_info_processor_count}'") + +if(system_info_processor_count EQUAL processor_count) + message("processor count matches system information") +endif() + +message("") +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message("") +message("tsi_out='${tsi_out}'") +message("tsi_err='${tsi_err}'") +message("") + +# Evaluate possible error conditions: +# +set(err 0) +set(fatal 0) + +if(processor_count EQUAL 0) + set(err 1) + set(fatal 1) + message("err 1") + message("could not determine number of processors +- Additional code for this platform needed in ProcessorCount.cmake?") + message("") +endif() + +if(NOT system_info_processor_count EQUAL processor_count) + set(err 2) + message("err 2") + message("SystemInformation and ProcessorCount.cmake disagree:\n" + "processor_count='${processor_count}'\n" + "SystemInformation processor_count='${system_info_processor_count}'") + message("") +endif() + +if(NOT processor_count MATCHES "^[0-9]+$") + set(err 3) + set(fatal 1) + message("err 3") + message("ProcessorCount function returned a non-integer") + message("") +endif() + +if(NOT system_info_processor_count MATCHES "^[0-9]+$") + set(err 4) + message("err 4") + message("SystemInformation ProcessorCount function returned a non-integer") + message("") +endif() + +if(fatal) + message(FATAL_ERROR "processor_count='${processor_count}' - see previous test output for more details - it is likely more/different code is needed in ProcessorCount.cmake to fix this test failure - processor_count should be a non-zero positive integer (>=1) for all supported CMake platforms") +endif() |