From 0c14932ae6c678feb66f16fddf82e48ac1e6769d Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Sun, 7 May 2006 10:55:43 -0400 Subject: ENH: move changes from main tree and change version to 2.4.2 --- CMakeLists.txt | 3 +- ChangeLog.manual | 19 +++ Modules/CMakeDetermineCCompiler.cmake | 2 +- Modules/CPack.STGZ_Header.sh.in | 61 ++++++++-- Modules/FindQt4.cmake | 14 +-- Modules/Platform/CYGWIN.cmake | 2 +- Modules/Platform/SunOS.cmake | 12 +- Modules/Platform/Windows-cl.cmake | 12 +- Source/CMakeLists.txt | 2 + Source/CPack/cmCPackGenerators.cxx | 26 +++- Source/CPack/cmCPackGenerators.h | 6 + Source/CPack/cmCPackGenericGenerator.cxx | 69 +++++++++-- Source/CPack/cmCPackNSISGenerator.cxx | 10 +- Source/CPack/cmCPackPackageMakerGenerator.cxx | 4 +- Source/CPack/cmCPackSTGZGenerator.cxx | 13 +- Source/CPack/cmCPackTGZGenerator.cxx | 136 ++++++++++++--------- Source/CPack/cmCPackTGZGenerator.h | 2 + Source/CPack/cmCPackTarBZip2Generator.cxx | 169 ++++++++++++++++++++++++++ Source/CPack/cmCPackTarBZip2Generator.h | 47 +++++++ Source/CPack/cmCPackTarCompressGenerator.cxx | 168 +++++++++++++++++++++++++ Source/CPack/cmCPackTarCompressGenerator.h | 47 +++++++ Source/CPack/cmCPackZIPGenerator.cxx | 2 +- Source/CPack/cpack.cxx | 34 ++++-- Source/cmCommandArgumentParserHelper.cxx | 4 + Source/cmDepends.h | 9 +- Source/cmDependsC.cxx | 7 +- Source/cmFileCommand.cxx | 65 +++++++--- Source/cmGlobalGenerator.cxx | 29 +---- Source/cmGlobalUnixMakefileGenerator3.cxx | 105 ++++++++++++++-- Source/cmGlobalUnixMakefileGenerator3.h | 9 ++ Source/cmGlobalVisualStudio6Generator.cxx | 1 + Source/cmGlobalVisualStudio71Generator.cxx | 5 +- Source/cmGlobalVisualStudio71Generator.h | 1 + Source/cmGlobalVisualStudio7Generator.cxx | 7 ++ Source/cmGlobalVisualStudio7Generator.h | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 6 + Source/cmGlobalVisualStudio8Generator.h | 1 + Source/cmIncludeExternalMSProjectCommand.cxx | 5 +- Source/cmInstallCommand.cxx | 65 +++++++++- Source/cmInstallCommand.h | 5 + Source/cmInstallFilesGenerator.cxx | 5 +- Source/cmInstallFilesGenerator.h | 2 + Source/cmInstallGenerator.cxx | 16 ++- Source/cmInstallGenerator.h | 15 ++- Source/cmInstallTargetGenerator.cxx | 11 +- Source/cmInstallTargetGenerator.h | 10 +- Source/cmLocalGenerator.cxx | 34 +++++- Source/cmLocalUnixMakefileGenerator3.cxx | 10 ++ Source/cmLocalVisualStudio7Generator.cxx | 24 +++- Source/cmMakefile.cxx | 15 +++ Source/cmSourceFile.cxx | 29 +++-- Source/cmSourceFile.h | 5 +- Source/cmSourceGroupCommand.h | 7 +- Source/cmTarget.cxx | 2 +- Source/kwsys/SystemTools.cxx | 23 +++- Source/kwsys/SystemTools.hxx.in | 15 ++- Tests/COnly/conly.c | 3 +- Tests/SimpleInstall/CMakeLists.txt | 22 +++- Tests/SimpleInstallS2/CMakeLists.txt | 22 +++- Utilities/Release/cmake_release.sh.in | 2 +- 60 files changed, 1228 insertions(+), 229 deletions(-) create mode 100644 Source/CPack/cmCPackTarBZip2Generator.cxx create mode 100644 Source/CPack/cmCPackTarBZip2Generator.h create mode 100644 Source/CPack/cmCPackTarCompressGenerator.cxx create mode 100644 Source/CPack/cmCPackTarCompressGenerator.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 79a34e9..716546b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY) # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 4) -SET(CMake_VERSION_PATCH 1) +SET(CMake_VERSION_PATCH 2) SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}") @@ -269,6 +269,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") SET(CPACK_NSIS_CONTACT "cmake@cmake.org") SET(CPACK_NSIS_MODIFY_PATH ON) ELSE(WIN32 AND NOT UNIX) + SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest") SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") ENDIF(WIN32 AND NOT UNIX) INCLUDE(CPack) diff --git a/ChangeLog.manual b/ChangeLog.manual index 986cddd..0238301 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,22 @@ +Changes in CMake 2.4.2 +* Significant speedup in try-compile for nmake + +* CPack improvments including tar bzip2 + +* FindQt4 windows path fix + +* Sunos cc optimize flags are correct + +* Fix crash with ${} empty variable + +* Increase depend speed on Mac OS. + +* install command CONFIGURATIONS option. + +* Fix MSVC60, MSVC70, MSVC71, MSVC80 definitions for IDE builds + +* Fix for C++ compiler being used for c code in VS IDE + Changes in CMake 2.4.1 * Several ctest and cpack bug fixes diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 0c59db3..2cd31f9 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -91,7 +91,7 @@ ENDIF(NOT CMAKE_COMPILER_IS_GNUCC_RUN) # configure variables set in this file for fast reload later on CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in - ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCCompiler.cmake IMMEDIATE) + "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCCompiler.cmake" IMMEDIATE) MARK_AS_ADVANCED(CMAKE_AR) SET(CMAKE_C_COMPILER_ENV_VAR "CC") diff --git a/Modules/CPack.STGZ_Header.sh.in b/Modules/CPack.STGZ_Header.sh.in index 24f0428..1325239 100755 --- a/Modules/CPack.STGZ_Header.sh.in +++ b/Modules/CPack.STGZ_Header.sh.in @@ -14,6 +14,12 @@ EOF exit 1 } +cpack_echo_exit() +{ + echo $1 + exit 1 +} + # Display version cpack_version() { @@ -26,7 +32,9 @@ cpack_fix_slashes () echo "$1" | sed 's/\\/\//g' } - +interactive=TRUE +cpack_skip_license=FALSE +cpack_include_subdir="" for a in "$@CPACK_AT_SIGN@"; do if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then cpack_prefix_dir=`echo $a | sed "s/^--prefix=//"` @@ -45,8 +53,16 @@ for a in "$@CPACK_AT_SIGN@"; do if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then cpack_include_subdir=FALSE fi + if echo $a | grep "^--skip-license" > /dev/null 2> /dev/null; then + cpack_skip_license=TRUE + fi done +if [ "x${cpack_include_subdir}x" != "xx" -o "x${cpack_skip_license}x" == "xTRUEx" ] +then + interactive=FALSE +fi + cpack_version echo "This is a self-extracting archive." toplevel="`pwd`" @@ -56,16 +72,41 @@ then fi echo "The archive will be extracted to: ${toplevel}" -echo "" -if [ "x${cpack_include_subdir}x" == "xx" ] +if [ "x${interactive}x" == "xTRUEx" ] then + echo "" echo "If you want to stop extracting, please press ." - echo "Include the subdirectory @CPACK_PACKAGE_FILE_NAME@" [Yn]: - read line - if [ "x${line}x" != "xnx" -a "x${line}x" != "xNx" ] + + if [ "x${cpack_skip_license}x" != "xTRUEx" ] then + more << ____cpack__here_doc____ +@CPACK_RESOURCE_FILE_LICENSE_CONTENT@ +____cpack__here_doc____ + echo + echo "Do you accept the license? [Yn]: " + read line leftover + case ${line} in + y* | Y*) + cpack_license_accepted=TRUE;; + *) + echo "License not accepted. Exiting ..." + exit 1;; + esac + fi + + if [ "x${cpack_include_subdir}x" == "xx" ] + then + echo "By default the @CPACK_PACKAGE_NAME@ will be installed in:" + echo " \"${toplevel}/@CPACK_PACKAGE_FILE_NAME@\"" + echo "Do you want to include the subdirectory @CPACK_PACKAGE_FILE_NAME@?" + echo "Saying no will install in: \"${toplevel}\" [Yn]: " + read line leftover cpack_include_subdir=TRUE + case ${line} in + n* | N*) + cpack_include_subdir=FALSE + esac fi fi @@ -74,13 +115,17 @@ then toplevel="${toplevel}/@CPACK_PACKAGE_FILE_NAME@" mkdir -p "${toplevel}" fi -echo "Extracting... Please wait..." +echo +echo "Using target directory: ${toplevel}" +echo "Extracting, please wait..." echo "" # take the archive portion of this file and pipe it to tar # the NUMERIC parameter in this command should be one more # than the number of lines in this header file -tail -n +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && tar xf -) +tail -n +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && tar xf -) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@" + +echo "Unpacking finished successfully" exit 0 #----------------------------------------------------------- diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 7959bb3..f9040b2 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -212,9 +212,9 @@ IF (QT_QMAKE_EXECUTABLE) ENDIF (NOT req_qt_major_vers EQUAL 4) # and now the version string given by qmake - STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" found_qt_major_vers "${QTVERSION}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" found_qt_minor_vers "${QTVERSION}") - STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" found_qt_patch_vers "${QTVERSION}") + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" found_qt_major_vers "${qt_version_tmp}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" found_qt_minor_vers "${qt_version_tmp}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" found_qt_patch_vers "${qt_version_tmp}") # compute an overall version number which can be compared at once MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}") @@ -653,11 +653,11 @@ IF (QT4_QMAKE_FOUND) FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmpQmake") - STRING(REGEX REPLACE ".*MOC<([^>]+).*" "\\1" QT_MOC_EXECUTABLE "${_moc_OUTPUT}" ) - STRING(REGEX REPLACE ".*UIC<([^>]+).*" "\\1" QT_UIC_EXECUTABLE "${_moc_OUTPUT}" ) + STRING(REGEX REPLACE ".*MOC<([^>]+).*" "\\1" QT_MOC_EXECUTABLE_INTERNAL "${_moc_OUTPUT}" ) + STRING(REGEX REPLACE ".*UIC<([^>]+).*" "\\1" QT_UIC_EXECUTABLE_INTERNAL "${_moc_OUTPUT}" ) - SET(QT_MOC_EXECUTABLE ${QT_MOC_EXECUTABLE} CACHE FILEPATH "The moc executable") - SET(QT_UIC_EXECUTABLE ${QT_UIC_EXECUTABLE} CACHE FILEPATH "The uic executable") + SET(QT_MOC_EXECUTABLE ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable") + SET(QT_UIC_EXECUTABLE ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable") FIND_PROGRAM(QT_UIC3_EXECUTABLE diff --git a/Modules/Platform/CYGWIN.cmake b/Modules/Platform/CYGWIN.cmake index 5419527..c7ccd98 100644 --- a/Modules/Platform/CYGWIN.cmake +++ b/Modules/Platform/CYGWIN.cmake @@ -11,7 +11,7 @@ SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe - +SET(CMAKE_CREATE_WIN32_EXE "-mwindows") # Modules have a different default prefix that shared libs. SET(CMAKE_MODULE_EXISTS 1) diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index ab96476..0d3f183 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -27,9 +27,9 @@ IF(CMAKE_SYSTEM MATCHES "SunOS-5*.") ELSE(CMAKE_COMPILER_IS_GNUCC) SET (CMAKE_C_FLAGS_INIT "") SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") - SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-O3 -DNDEBUG") - SET (CMAKE_C_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-xO3 -DNDEBUG") + SET (CMAKE_C_FLAGS_RELEASE_INIT "-xO2 -DNDEBUG") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-xO2") ENDIF(CMAKE_COMPILER_IS_GNUCC) IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") @@ -40,9 +40,9 @@ IF(CMAKE_SYSTEM MATCHES "SunOS-5*.") ELSE(CMAKE_COMPILER_IS_GNUCXX) SET (CMAKE_CXX_FLAGS_INIT "") SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g") - SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2") + SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-xO3 -DNDEBUG") + SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-xO2 -DNDEBUG") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-xO2") ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_SYSTEM MATCHES "SunOS-5*.") diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index 5da4721..3c21bd0 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -1,7 +1,7 @@ # try to load any previously computed information for C on this platform -INCLUDE( ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake OPTIONAL) +INCLUDE( ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake OPTIONAL) # try to load any previously computed information for CXX on this platform -INCLUDE( ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake OPTIONAL) +INCLUDE( ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake OPTIONAL) SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:") SET(CMAKE_LINK_LIBRARY_FLAG "") @@ -273,14 +273,14 @@ SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELW # save computed information for this platform -IF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake") +IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake") CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake IMMEDIATE) -ENDIF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCPlatform.cmake") +ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake") -IF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake") +IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake") CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake IMMEDIATE) -ENDIF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeCXXPlatform.cmake") +ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake") INCLUDE(Platform/WindowsPaths) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 26b8668..dacc0e0 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -276,6 +276,8 @@ SET(CPACK_SRCS CPack/cmCPackNSISGenerator.cxx CPack/cmCPackPackageMakerGenerator.cxx CPack/cmCPackZIPGenerator.cxx + CPack/cmCPackTarBZip2Generator.cxx + CPack/cmCPackTarCompressGenerator.cxx CPack/cmCPackGenericGenerator.cxx CPack/cmCPackLog.cxx ) diff --git a/Source/CPack/cmCPackGenerators.cxx b/Source/CPack/cmCPackGenerators.cxx index e120c2b..3515e0e 100644 --- a/Source/CPack/cmCPackGenerators.cxx +++ b/Source/CPack/cmCPackGenerators.cxx @@ -19,6 +19,8 @@ #include "cmCPackGenericGenerator.h" #include "cmCPackTGZGenerator.h" +#include "cmCPackTarBZip2Generator.h" +#include "cmCPackTarCompressGenerator.h" #include "cmCPackZIPGenerator.h" #include "cmCPackSTGZGenerator.h" #include "cmCPackNSISGenerator.h" @@ -29,12 +31,24 @@ //---------------------------------------------------------------------- cmCPackGenerators::cmCPackGenerators() { - this->RegisterGenerator("TGZ", cmCPackTGZGenerator::CreateGenerator); - this->RegisterGenerator("STGZ", cmCPackSTGZGenerator::CreateGenerator); - this->RegisterGenerator("NSIS", cmCPackNSISGenerator::CreateGenerator); - this->RegisterGenerator("ZIP", cmCPackZIPGenerator::CreateGenerator); - this->RegisterGenerator("PackageMaker", + this->RegisterGenerator("TGZ", "Tar GZip compression", + cmCPackTGZGenerator::CreateGenerator); + this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", + cmCPackSTGZGenerator::CreateGenerator); +#ifdef _WIN32 + this->RegisterGenerator("NSIS", "Null Soft Installer", + cmCPackNSISGenerator::CreateGenerator); +#endif + this->RegisterGenerator("ZIP", "ZIP file format", + cmCPackZIPGenerator::CreateGenerator); + this->RegisterGenerator("TBZ2", "Tar BZip2 compression", + cmCPackTarBZip2Generator::CreateGenerator); + this->RegisterGenerator("TZ", "Tar Compress compression", + cmCPackTarCompressGenerator::CreateGenerator); +#ifdef __APPLE__ + this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker compression", cmCPackPackageMakerGenerator::CreateGenerator); +#endif } //---------------------------------------------------------------------- @@ -79,6 +93,7 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal( //---------------------------------------------------------------------- void cmCPackGenerators::RegisterGenerator(const char* name, + const char* generatorDescription, CreateGeneratorCall* createGenerator) { if ( !name || !createGenerator ) @@ -88,4 +103,5 @@ void cmCPackGenerators::RegisterGenerator(const char* name, return; } this->GeneratorCreators[name] = createGenerator; + this->GeneratorDescriptions[name] = generatorDescription; } diff --git a/Source/CPack/cmCPackGenerators.h b/Source/CPack/cmCPackGenerators.h index d100e9b..76a1697 100644 --- a/Source/CPack/cmCPackGenerators.h +++ b/Source/CPack/cmCPackGenerators.h @@ -42,16 +42,22 @@ public: typedef cmCPackGenericGenerator* CreateGeneratorCall(); void RegisterGenerator(const char* name, + const char* generatorDescription, CreateGeneratorCall* createGenerator); void SetLogger(cmCPackLog* logger) { this->Logger = logger; } + typedef std::map DescriptionsMap; + const DescriptionsMap& GetGeneratorsList() const + { return this->GeneratorDescriptions; } + private: cmCPackGenericGenerator* NewGeneratorInternal(const char* name); std::vector Generators; typedef std::map t_GeneratorCreatorsMap; t_GeneratorCreatorsMap GeneratorCreators; + DescriptionsMap GeneratorDescriptions; cmCPackLog* Logger; }; diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx index 6bf578e..8d5c832 100644 --- a/Source/CPack/cmCPackGenericGenerator.cxx +++ b/Source/CPack/cmCPackGenericGenerator.cxx @@ -68,15 +68,15 @@ int cmCPackGenericGenerator::PrepareNames() std::string outFile = topDirectory + "/" + outName; std::string installPrefix = tempDirectory + this->GetInstallPrefix(); - this->SetOption("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); - this->SetOption("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str()); - this->SetOption("CPACK_OUTPUT_FILE_NAME", outName.c_str()); - this->SetOption("CPACK_OUTPUT_FILE_PATH", destFile.c_str()); - this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", outFile.c_str()); - this->SetOption("CPACK_INSTALL_DIRECTORY", this->GetInstallPath()); - this->SetOption("CPACK_NATIVE_INSTALL_DIRECTORY", + this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); + this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str()); + this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", outName.c_str()); + this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PATH", destFile.c_str()); + this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME", outFile.c_str()); + this->SetOptionIfNotSet("CPACK_INSTALL_DIRECTORY", this->GetInstallPath()); + this->SetOptionIfNotSet("CPACK_NATIVE_INSTALL_DIRECTORY", cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str()); - this->SetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY", installPrefix.c_str()); + this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY", installPrefix.c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl); @@ -108,7 +108,7 @@ int cmCPackGenericGenerator::PrepareNames() { ostr << cmSystemTools::MakeXMLSafe(line.c_str()) << std::endl; } - this->SetOption("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str()); + this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str()); } if ( !this->GetOption("CPACK_PACKAGE_DESCRIPTION") ) { @@ -119,6 +119,13 @@ int cmCPackGenericGenerator::PrepareNames() return 0; } + std::vector path; + std::string pkgPath = cmSystemTools::FindProgram("strip", path, false); + if ( !pkgPath.empty() ) + { + this->SetOptionIfNotSet("CPACK_STRIP_COMMAND", pkgPath.c_str()); + } + return 1; } @@ -318,7 +325,11 @@ int cmCPackGenericGenerator::InstallProject() cmGlobalGenerator* globalGenerator = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( cmakeGenerator); - + // set the global flag for unix style paths on cmSystemTools as + // soon as the generator is set. This allows gmake to be used + // on windows. + cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths()); + // Does this generator require pre-install? if ( globalGenerator->GetPreinstallTargetName() ) { @@ -432,6 +443,44 @@ int cmCPackGenericGenerator::InstallProject() { cmSystemTools::PutEnv("DESTDIR="); } + + const char* stripExecutable = this->GetOption("CPACK_STRIP_COMMAND"); + const char* stripFiles + = this->GetOption("CPACK_STRIP_FILES"); + if ( stripFiles && *stripFiles && stripExecutable && *stripExecutable ) + { + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Strip files" << std::endl); + std::vector stripFilesVector; + cmSystemTools::ExpandListArgument(stripFiles, + stripFilesVector); + std::vector::iterator it; + for ( it = stripFilesVector.begin(); + it != stripFilesVector.end(); + ++it ) + { + std::string fileName = tempInstallDirectory; + fileName += "/" + *it; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + " Strip file: " << fileName.c_str() + << std::endl); + std::string stripCommand = stripExecutable; + stripCommand += " \""; + stripCommand += fileName + "\""; + int retVal = 1; + std::string output; + bool resB = cmSystemTools::RunSingleCommand(stripCommand.c_str(), &output, + &retVal, 0, this->GeneratorVerbose, 0); + if ( !resB || retVal ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running install command: " << stripCommand.c_str() + << std::endl + << "Error was: \"" << output.c_str() << "\"" + << std::endl); + return 0; + } + } + } return res; } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 31345f3..5f2541f 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -78,7 +78,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str().c_str() << std::endl); - this->SetOption("CPACK_NSIS_DELETE_FILES", str.str().c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector dirs; this->GetListOfSubdirectories(toplevel, dirs); std::vector::const_iterator sit; @@ -96,7 +96,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str().c_str() << std::endl); - this->SetOption("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName << " to " << nsisFileName << std::endl); @@ -193,7 +193,7 @@ int cmCPackNSISGenerator::InitializeInternal() return 0; } - this->SetOption("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); if ( cpackPackageExecutables ) @@ -226,8 +226,8 @@ int cmCPackNSISGenerator::InitializeInternal() deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName << ".lnk\"" << std::endl; } - this->SetOption("CPACK_NSIS_CREATE_ICONS", str.str().c_str()); - this->SetOption("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str()); } return this->Superclass::InitializeInternal(); diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 1d6cb35..dff1413 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -213,7 +213,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal() << std::endl); return 0; } - this->SetOption("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); pkgPath = cmSystemTools::FindProgram("hdiutil", path, false); if ( pkgPath.empty() ) { @@ -221,7 +221,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal() << std::endl); return 0; } - this->SetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", pkgPath.c_str()); + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", pkgPath.c_str()); return this->Superclass::InitializeInternal(); } diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 9346b3e..5044d3a 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -51,7 +51,7 @@ int cmCPackSTGZGenerator::InitializeInternal() return 0; } this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str()); - this->SetOption("CPACK_AT_SIGN", "@"); + this->SetOptionIfNotSet("CPACK_AT_SIGN", "@"); return this->Superclass::InitializeInternal(); } @@ -84,11 +84,20 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) cmsys_ios::ostringstream str; int counter = 0; + std::string inLicFile = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); + std::string line; + std::ifstream ilfs(inLicFile.c_str()); + std::string licenseText; + while ( cmSystemTools::GetLineFromStream(ilfs, line) ) + { + licenseText += line + "\n"; + } + this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT", licenseText.c_str()); + const char headerLengthTag[] = "###CPACK_HEADER_LENGTH###"; // Create the header std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE"); - std::string line; std::ifstream ifs(inFile.c_str()); std::string packageHeaderText; while ( cmSystemTools::GetLineFromStream(ifs, line) ) diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 1daaee9..d4663db 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -45,6 +45,7 @@ class cmCPackTGZGeneratorForward //---------------------------------------------------------------------- cmCPackTGZGenerator::cmCPackTGZGenerator() { + this->Compress = true; } //---------------------------------------------------------------------- @@ -58,15 +59,17 @@ static const size_t cmCPackTGZ_Data_BlockSize = 16384; class cmCPackTGZ_Data { public: - cmCPackTGZ_Data(cmCPackTGZGenerator* gen) : + cmCPackTGZ_Data(cmCPackTGZGenerator* gen, bool compress) : OutputStream(0), Generator(gen), - CompressionLevel(Z_DEFAULT_COMPRESSION) {} + CompressionLevel(Z_DEFAULT_COMPRESSION), + Compress(compress) {} std::ostream* OutputStream; cmCPackTGZGenerator* Generator; char CompressedBuffer[cmCPackTGZ_Data_BlockSize]; int CompressionLevel; z_stream ZLibStream; uLong CRC; + bool Compress; }; //---------------------------------------------------------------------- @@ -84,14 +87,17 @@ int cmCPackTGZ_Data_Open(void *client_data, const char* pathname, { cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data; - mydata->ZLibStream.zalloc = Z_NULL; - mydata->ZLibStream.zfree = Z_NULL; - mydata->ZLibStream.opaque = Z_NULL; - int strategy = Z_DEFAULT_STRATEGY; - if ( deflateInit2(&mydata->ZLibStream, mydata->CompressionLevel, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy) != Z_OK ) + if ( mydata->Compress ) { - return -1; + mydata->ZLibStream.zalloc = Z_NULL; + mydata->ZLibStream.zfree = Z_NULL; + mydata->ZLibStream.opaque = Z_NULL; + int strategy = Z_DEFAULT_STRATEGY; + if ( deflateInit2(&mydata->ZLibStream, mydata->CompressionLevel, + Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy) != Z_OK ) + { + return -1; + } } cmGeneratedFileStream* gf = new cmGeneratedFileStream; @@ -108,7 +114,10 @@ int cmCPackTGZ_Data_Open(void *client_data, const char* pathname, return -1; } - mydata->CRC = crc32(0L, Z_NULL, 0); + if ( mydata->Compress ) + { + mydata->CRC = crc32(0L, Z_NULL, 0); + } return 0; } @@ -118,35 +127,42 @@ ssize_t cmCPackTGZ_Data_Write(void *client_data, void *buff, size_t n) { cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data; - mydata->ZLibStream.avail_in = n; - mydata->ZLibStream.next_in = reinterpret_cast(buff); - - do { - mydata->ZLibStream.avail_out = cmCPackTGZ_Data_BlockSize; - mydata->ZLibStream.next_out - = reinterpret_cast(mydata->CompressedBuffer); - // no bad return value - int ret = deflate(&mydata->ZLibStream, (n?Z_NO_FLUSH:Z_FINISH)); - if(ret == Z_STREAM_ERROR) + if ( mydata->Compress ) + { + mydata->ZLibStream.avail_in = n; + mydata->ZLibStream.next_in = reinterpret_cast(buff); + + do { + mydata->ZLibStream.avail_out = cmCPackTGZ_Data_BlockSize; + mydata->ZLibStream.next_out + = reinterpret_cast(mydata->CompressedBuffer); + // no bad return value + int ret = deflate(&mydata->ZLibStream, (n?Z_NO_FLUSH:Z_FINISH)); + if(ret == Z_STREAM_ERROR) + { + return 0; + } + + size_t compressedSize + = cmCPackTGZ_Data_BlockSize - mydata->ZLibStream.avail_out; + + mydata->OutputStream->write( + reinterpret_cast(mydata->CompressedBuffer), + compressedSize); + } while ( mydata->ZLibStream.avail_out == 0 ); + + if ( !*mydata->OutputStream ) { return 0; } - - size_t compressedSize - = cmCPackTGZ_Data_BlockSize - mydata->ZLibStream.avail_out; - - mydata->OutputStream->write( - reinterpret_cast(mydata->CompressedBuffer), - compressedSize); - } while ( mydata->ZLibStream.avail_out == 0 ); - - if ( !*mydata->OutputStream ) - { - return 0; + if ( n ) + { + mydata->CRC = crc32(mydata->CRC, reinterpret_cast(buff), n); + } } - if ( n ) + else { - mydata->CRC = crc32(mydata->CRC, reinterpret_cast(buff), n); + mydata->OutputStream->write(reinterpret_cast(buff), n); } return n; } @@ -156,23 +172,26 @@ int cmCPackTGZ_Data_Close(void *client_data) { cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data; - cmCPackTGZ_Data_Write(client_data, 0, 0); - - char buffer[8]; - int n; - uLong x = mydata->CRC; - for (n = 0; n < 4; n++) { - buffer[n] = (int)(x & 0xff); - x >>= 8; - } - x = mydata->ZLibStream.total_in; - for (n = 0; n < 4; n++) { - buffer[n+4] = (int)(x & 0xff); - x >>= 8; - } - - mydata->OutputStream->write(buffer, 8); - (void)deflateEnd(&mydata->ZLibStream); + if ( mydata->Compress ) + { + cmCPackTGZ_Data_Write(client_data, 0, 0); + + char buffer[8]; + int n; + uLong x = mydata->CRC; + for (n = 0; n < 4; n++) { + buffer[n] = (int)(x & 0xff); + x >>= 8; + } + x = mydata->ZLibStream.total_in; + for (n = 0; n < 4; n++) { + buffer[n+4] = (int)(x & 0xff); + x >>= 8; + } + + mydata->OutputStream->write(buffer, 8); + (void)deflateEnd(&mydata->ZLibStream); + } delete mydata->OutputStream; mydata->OutputStream = 0; return (0); @@ -190,7 +209,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, const char* toplevel, const std::vector& files) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); - cmCPackTGZ_Data mydata(this); + cmCPackTGZ_Data mydata(this, this->Compress); TAR *t; char buf[TAR_MAXPATHLEN]; char pathname[TAR_MAXPATHLEN]; @@ -257,10 +276,13 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, //---------------------------------------------------------------------- int cmCPackTGZGenerator::GenerateHeader(std::ostream* os) { - const int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - char header[11]; - sprintf(header, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - os->write(header, 10); + if ( this->Compress ) + { + const int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ + char header[11]; + sprintf(header, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], + Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); + os->write(header, 10); + } return 1; } diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h index 7dd5875..4323a53 100644 --- a/Source/CPack/cmCPackTGZGenerator.h +++ b/Source/CPack/cmCPackTGZGenerator.h @@ -45,6 +45,8 @@ protected: int CompressFiles(const char* outFileName, const char* toplevel, const std::vector& files); virtual const char* GetOutputExtension() { return "tar.gz"; } + + bool Compress; }; #endif diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx new file mode 100644 index 0000000..f58dc0f --- /dev/null +++ b/Source/CPack/cmCPackTarBZip2Generator.cxx @@ -0,0 +1,169 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "cmCPackTarBZip2Generator.h" + +#include "cmake.h" +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmSystemTools.h" +#include "cmMakefile.h" +#include "cmGeneratedFileStream.h" +#include "cmCPackLog.h" + +#include + +// Includes needed for implementation of RenameFile. This is not in +// system tools because it is not implemented robustly enough to move +// files across directories. +#ifdef _WIN32 +# include +# include +#endif + +//---------------------------------------------------------------------- +cmCPackTarBZip2Generator::cmCPackTarBZip2Generator() +{ + this->Compress = false; +} + +//---------------------------------------------------------------------- +cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator() +{ +} + +//---------------------------------------------------------------------- +int cmCPackTarBZip2Generator::InitializeInternal() +{ + this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); + std::vector path; + std::string pkgPath = cmSystemTools::FindProgram("bzip2", path, false); + if ( pkgPath.empty() ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find BZip2" << std::endl); + return 0; + } + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found Compress program: " + << pkgPath.c_str() + << std::endl); + + return this->Superclass::InitializeInternal(); +} + +//---------------------------------------------------------------------- +int cmCPackTarBZip2Generator::CompressFiles(const char* outFileName, + const char* toplevel, const std::vector& files) +{ + std::string packageDirFileName + = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + packageDirFileName += ".tar"; + std::string output; + int retVal = -1; + if ( !this->Superclass::CompressFiles(packageDirFileName.c_str(), + toplevel, files) ) + { + return 0; + } + + cmOStringStream dmgCmd1; + dmgCmd1 << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") + << "\" \"" << packageDirFileName + << "\""; + retVal = -1; + int res = cmSystemTools::RunSingleCommand(dmgCmd1.str().c_str(), &output, + &retVal, toplevel, this->GeneratorVerbose, 0); + if ( !res || retVal ) + { + std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + tmpFile += "/CompressBZip2.log"; + cmGeneratedFileStream ofs(tmpFile.c_str()); + ofs << "# Run command: " << dmgCmd1.str().c_str() << std::endl + << "# Output:" << std::endl + << output.c_str() << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running BZip2 command: " + << dmgCmd1.str().c_str() << std::endl + << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + return 0; + } + + std::string compressOutFile = packageDirFileName + ".bz2"; + if ( !cmSystemTools::SameFile(compressOutFile.c_str(), outFileName ) ) + { + if ( !this->RenameFile(compressOutFile.c_str(), outFileName) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem renaming: \"" + << compressOutFile.c_str() << "\" to \"" + << outFileName << std::endl); + return 0; + } + } + + return 1; +} + +//---------------------------------------------------------------------------- +int cmCPackTarBZip2Generator::RenameFile(const char* oldname, + const char* newname) +{ +#ifdef _WIN32 + /* On Windows the move functions will not replace existing files. + Check if the destination exists. */ + struct stat newFile; + if(stat(newname, &newFile) == 0) + { + /* The destination exists. We have to replace it carefully. The + MoveFileEx function does what we need but is not available on + Win9x. */ + OSVERSIONINFO osv; + DWORD attrs; + + /* Make sure the destination is not read only. */ + attrs = GetFileAttributes(newname); + if(attrs & FILE_ATTRIBUTE_READONLY) + { + SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY); + } + + /* Check the windows version number. */ + osv.dwOSVersionInfoSize = sizeof(osv); + GetVersionEx(&osv); + if(osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + { + /* This is Win9x. There is no MoveFileEx implementation. We + cannot quite rename the file atomically. Just delete the + destination and then move the file. */ + DeleteFile(newname); + return MoveFile(oldname, newname); + } + else + { + /* This is not Win9x. Use the MoveFileEx implementation. */ + return MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING); + } + } + else + { + /* The destination does not exist. Just move the file. */ + return MoveFile(oldname, newname); + } +#else + /* On UNIX we have an OS-provided call to do this atomically. */ + return rename(oldname, newname) == 0; +#endif +} + diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h new file mode 100644 index 0000000..c5c404b --- /dev/null +++ b/Source/CPack/cmCPackTarBZip2Generator.h @@ -0,0 +1,47 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef cmCPackTarBZip2Generator_h +#define cmCPackTarBZip2Generator_h + +#include "cmCPackTGZGenerator.h" + +/** \class cmCPackTarBZip2Generator + * \brief A generator for TarBZip2 files + */ +class cmCPackTarBZip2Generator : public cmCPackTGZGenerator +{ +public: + friend class cmCPackTarBZip2GeneratorForward; + cmCPackTypeMacro(cmCPackTarBZip2Generator, cmCPackTGZGenerator); + + /** + * Construct generator + */ + cmCPackTarBZip2Generator(); + virtual ~cmCPackTarBZip2Generator(); + +protected: + virtual int InitializeInternal(); + int CompressFiles(const char* outFileName, const char* toplevel, + const std::vector& files); + virtual const char* GetOutputExtension() { return "tar.bz2"; } + + int RenameFile(const char* oldname, const char* newname); +}; + +#endif diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx new file mode 100644 index 0000000..59527cd --- /dev/null +++ b/Source/CPack/cmCPackTarCompressGenerator.cxx @@ -0,0 +1,168 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "cmCPackTarCompressGenerator.h" + +#include "cmake.h" +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmSystemTools.h" +#include "cmMakefile.h" +#include "cmGeneratedFileStream.h" +#include "cmCPackLog.h" + +#include + +// Includes needed for implementation of RenameFile. This is not in +// system tools because it is not implemented robustly enough to move +// files across directories. +#ifdef _WIN32 +# include +# include +#endif + +//---------------------------------------------------------------------- +cmCPackTarCompressGenerator::cmCPackTarCompressGenerator() +{ + this->Compress = false; +} + +//---------------------------------------------------------------------- +cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator() +{ +} + +//---------------------------------------------------------------------- +int cmCPackTarCompressGenerator::InitializeInternal() +{ + this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); + std::vector path; + std::string pkgPath = cmSystemTools::FindProgram("compress", path, false); + if ( pkgPath.empty() ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find Compress" << std::endl); + return 0; + } + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found Compress program: " + << pkgPath.c_str() + << std::endl); + + return this->Superclass::InitializeInternal(); +} + +//---------------------------------------------------------------------- +int cmCPackTarCompressGenerator::CompressFiles(const char* outFileName, + const char* toplevel, const std::vector& files) +{ + std::string packageDirFileName + = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + packageDirFileName += ".tar"; + std::string output; + int retVal = -1; + if ( !this->Superclass::CompressFiles(packageDirFileName.c_str(), toplevel, files) ) + { + return 0; + } + + cmOStringStream dmgCmd1; + dmgCmd1 << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") + << "\" \"" << packageDirFileName + << "\""; + retVal = -1; + int res = cmSystemTools::RunSingleCommand(dmgCmd1.str().c_str(), &output, + &retVal, toplevel, this->GeneratorVerbose, 0); + if ( !res || retVal ) + { + std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + tmpFile += "/CompressCompress.log"; + cmGeneratedFileStream ofs(tmpFile.c_str()); + ofs << "# Run command: " << dmgCmd1.str().c_str() << std::endl + << "# Output:" << std::endl + << output.c_str() << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running Compress command: " + << dmgCmd1.str().c_str() << std::endl + << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + return 0; + } + + std::string compressOutFile = packageDirFileName + ".Z"; + if ( !cmSystemTools::SameFile(compressOutFile.c_str(), outFileName ) ) + { + if ( !this->RenameFile(compressOutFile.c_str(), outFileName) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem renaming: \"" + << compressOutFile.c_str() << "\" to \"" + << outFileName << std::endl); + return 0; + } + } + + return 1; +} + +//---------------------------------------------------------------------------- +int cmCPackTarCompressGenerator::RenameFile(const char* oldname, + const char* newname) +{ +#ifdef _WIN32 + /* On Windows the move functions will not replace existing files. + Check if the destination exists. */ + struct stat newFile; + if(stat(newname, &newFile) == 0) + { + /* The destination exists. We have to replace it carefully. The + MoveFileEx function does what we need but is not available on + Win9x. */ + OSVERSIONINFO osv; + DWORD attrs; + + /* Make sure the destination is not read only. */ + attrs = GetFileAttributes(newname); + if(attrs & FILE_ATTRIBUTE_READONLY) + { + SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY); + } + + /* Check the windows version number. */ + osv.dwOSVersionInfoSize = sizeof(osv); + GetVersionEx(&osv); + if(osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + { + /* This is Win9x. There is no MoveFileEx implementation. We + cannot quite rename the file atomically. Just delete the + destination and then move the file. */ + DeleteFile(newname); + return MoveFile(oldname, newname); + } + else + { + /* This is not Win9x. Use the MoveFileEx implementation. */ + return MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING); + } + } + else + { + /* The destination does not exist. Just move the file. */ + return MoveFile(oldname, newname); + } +#else + /* On UNIX we have an OS-provided call to do this atomically. */ + return rename(oldname, newname) == 0; +#endif +} + diff --git a/Source/CPack/cmCPackTarCompressGenerator.h b/Source/CPack/cmCPackTarCompressGenerator.h new file mode 100644 index 0000000..efd5579 --- /dev/null +++ b/Source/CPack/cmCPackTarCompressGenerator.h @@ -0,0 +1,47 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef cmCPackTarCompressGenerator_h +#define cmCPackTarCompressGenerator_h + +#include "cmCPackTGZGenerator.h" + +/** \class cmCPackTarCompressGenerator + * \brief A generator for TarCompress files + */ +class cmCPackTarCompressGenerator : public cmCPackTGZGenerator +{ +public: + friend class cmCPackTarCompressGeneratorForward; + cmCPackTypeMacro(cmCPackTarCompressGenerator, cmCPackTGZGenerator); + + /** + * Construct generator + */ + cmCPackTarCompressGenerator(); + virtual ~cmCPackTarCompressGenerator(); + +protected: + virtual int InitializeInternal(); + int CompressFiles(const char* outFileName, const char* toplevel, + const std::vector& files); + virtual const char* GetOutputExtension() { return "tar.Z"; } + + int RenameFile(const char* oldname, const char* newname); +}; + +#endif diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx index 8297cc4..d8ad47f 100644 --- a/Source/CPack/cmCPackZIPGenerator.cxx +++ b/Source/CPack/cmCPackZIPGenerator.cxx @@ -79,7 +79,7 @@ int cmCPackZIPGenerator::InitializeInternal() << std::endl); return 0; } - this->SetOption("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found ZIP program: " << pkgPath.c_str() << std::endl); diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index fa4afb1..3143c2a 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -42,7 +42,7 @@ static const cmDocumentationEntry cmDocumentationName[] = static const cmDocumentationEntry cmDocumentationUsage[] = { {0, - " cpack -G -P -R [options]", + " cpack -G [options]", 0}, {0,0,0} }; @@ -67,23 +67,14 @@ static const cmDocumentationEntry cmDocumentationOptions[] = "platforms. A generator is responsible for generating input files for " "particular system and invoking that systems. Possible generator names " "are specified in the Generators section." }, - {"-P ", "Specify the project name.", - "This option specifies the project name that will be used to generate " - "the installer." }, {"-C ", "Specify the project configuration", "This option specifies the configuration that the project was build " "with, for example 'Debug', 'Release'." }, - {"-R ", "Specify the release version of the project.", - "This option specifies the release version of the project that will be " - "used by installer." }, {"-D =", "Set a CPack variable.", \ "Set a variable that can be used by the generator."}, \ - {"--patch ", "Specify the patch of the project.", - "This option specifies the patch of the project that will be " - "used by installer." }, - {"--vendor ", "Specify the vendor of the project.", - "This option specifies the vendor of the project that will be " - "used by installer." }, + {"--config ", "Specify the config file.", + "Specify the config file to use to create the package. By default " + "CPackConfig.cmake in the current directory will be used." }, {0,0,0} }; @@ -376,6 +367,23 @@ int main (int argc, char *argv[]) doc.SetUsageSection(cmDocumentationUsage); doc.SetDescriptionSection(cmDocumentationDescription); doc.SetOptionsSection(cmDocumentationOptions); + + std::vector v; + cmCPackGenerators::DescriptionsMap::const_iterator generatorIt; + for( generatorIt = generators.GetGeneratorsList().begin(); + generatorIt != generators.GetGeneratorsList().end(); + ++ generatorIt ) + { + cmDocumentationEntry e; + e.name = generatorIt->first.c_str(); + e.brief = generatorIt->second.c_str(); + e.full = ""; + v.push_back(e); + } + cmDocumentationEntry empty = {0,0,0}; + v.push_back(empty); + doc.SetGeneratorsSection(&v[0]); + doc.SetSeeAlsoList(cmDocumentationSeeAlso); #undef cout return doc.PrintRequestedDocumentation(std::cout)? 0:1; diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index f24cab6..570cc2d 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -91,6 +91,10 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, cons char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { + if(!var) + { + return 0; + } if(this->FileName && strcmp(var, "CMAKE_CURRENT_LIST_FILE") == 0) { return this->AddString(this->FileName); diff --git a/Source/cmDepends.h b/Source/cmDepends.h index a0b1b6b..e4278a6 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -38,6 +38,11 @@ public: /** at what level will the compile be done from */ void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}; + /** Set the full path to the top of the build tree. This is + the base path from which dependencies are referenced as + relative paths. */ + void SetHomeOutputDirectory(const char *dir) {this->HomeOutputDirectory = dir;}; + /** should this be verbose in its output */ void SetVerbose(bool verb) { this->Verbose = verb; } @@ -71,9 +76,11 @@ protected: virtual bool CheckDependencies(std::istream& internalDepends); // The directory in which the build rule for the target file is executed. - std::string Directory; std::string CompileDirectory; + // The full path to the top of the build tree. + std::string HomeOutputDirectory; + // Flag for verbose output. bool Verbose; cmFileTimeComparison* FileComparison; diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 2e198ee..13ebdcd 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -26,7 +26,6 @@ cmDependsC::cmDependsC(): IncludePath(0), GeneratedFiles(0) { } - //---------------------------------------------------------------------------- // yummy look at all those constructor arguments cmDependsC::cmDependsC(std::vector const& includes, @@ -85,6 +84,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, this->Encountered.insert(src); std::set dependencies; std::set scanned; + while(!this->Unscanned.empty()) { // Get the next file to scan. @@ -367,9 +367,10 @@ bool cmDependsC::FileExistsOrIsGenerated(const std::string& fname, else if(cmSystemTools::FileIsFullPath(fname.c_str())) { // The generated file may have been listed with a relative path. - std::string dir = cmSystemTools::CollapseFullPath(this->Directory.c_str()); + // Note that CMAKE_GENERATED_FILES is written with a conversion + // relative to the home output directory. std::string rname = - cmSystemTools::RelativePath(dir.c_str(), fname.c_str()); + cmSystemTools::RelativePath(this->HomeOutputDirectory.c_str(), fname.c_str()); if(this->FileIsGenerated(rname, scanned, dependencies)) { return true; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 9ca4f19..3139b5b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -323,19 +323,10 @@ bool cmFileCommand::HandleInstallCommand( std::string rename = ""; std::string destination = ""; std::string stype = "FILES"; - const char* build_type = this->Makefile->GetDefinition("BUILD_TYPE"); - if ( build_type && strcmp(build_type, ".") == 0 ) - { - build_type = 0; - } - if ( build_type && strncmp(build_type, ".\\", 2) == 0 ) - { - build_type += 2; - } - const char* destdir = cmSystemTools::GetEnv("DESTDIR"); std::set components; + std::set configurations; std::vector files; int itype = cmTarget::INSTALL_FILES; @@ -375,6 +366,7 @@ bool cmFileCommand::HandleInstallCommand( bool in_properties = false; bool in_permissions = false; bool in_components = false; + bool in_configurations = false; bool use_given_permissions = false; mode_t permissions = 0; bool optional = false; @@ -389,6 +381,7 @@ bool cmFileCommand::HandleInstallCommand( in_properties = false; in_permissions = false; in_components = false; + in_configurations = false; } else if ( *cstr == "TYPE" && i < args.size()-1 ) { @@ -403,6 +396,7 @@ bool cmFileCommand::HandleInstallCommand( in_files = false; in_permissions = false; in_components = false; + in_configurations = false; } else if ( *cstr == "RENAME" && i < args.size()-1 ) { @@ -412,6 +406,7 @@ bool cmFileCommand::HandleInstallCommand( in_files = false; in_permissions = false; in_components = false; + in_configurations = false; } else if ( *cstr == "PROPERTIES" ) { @@ -419,6 +414,7 @@ bool cmFileCommand::HandleInstallCommand( in_files = false; in_permissions = false; in_components = false; + in_configurations = false; } else if ( *cstr == "PERMISSIONS" ) { @@ -427,6 +423,7 @@ bool cmFileCommand::HandleInstallCommand( in_files = false; in_permissions = true; in_components = false; + in_configurations = false; } else if ( *cstr == "COMPONENTS" ) { @@ -434,6 +431,15 @@ bool cmFileCommand::HandleInstallCommand( in_files = false; in_permissions = false; in_components = true; + in_configurations = false; + } + else if ( *cstr == "CONFIGURATIONS" ) + { + in_properties = false; + in_files = false; + in_permissions = false; + in_components = false; + in_configurations = true; } else if ( *cstr == "FILES" && !in_files) { @@ -441,6 +447,7 @@ bool cmFileCommand::HandleInstallCommand( in_properties = false; in_permissions = false; in_components = false; + in_configurations = false; } else if ( in_properties && i < args.size()-1 ) { @@ -455,6 +462,10 @@ bool cmFileCommand::HandleInstallCommand( { components.insert(*cstr); } + else if ( in_configurations ) + { + configurations.insert(cmSystemTools::UpperCase(*cstr)); + } else if(in_permissions && args[i] == "OWNER_READ") { permissions |= mode_owner_read; @@ -526,6 +537,26 @@ bool cmFileCommand::HandleInstallCommand( } } + // Check for configuration-specific installation. + if(!configurations.empty()) + { + std::string cmake_install_configuration = + cmSystemTools::UpperCase( + this->Makefile->GetSafeDefinition("CMAKE_INSTALL_CONFIG_NAME")); + if(cmake_install_configuration.empty()) + { + // No configuration specified for installation but this install + // rule is configuration-specific. Skip it. + return true; + } + else if(configurations.find(cmake_install_configuration) == + configurations.end()) + { + // This rule is specific to a configuration not being installed. + return true; + } + } + int destDirLength = 0; if ( destdir && *destdir ) { @@ -696,6 +727,11 @@ bool cmFileCommand::HandleInstallCommand( smanifest_files = manifest_files; } + // Check whether files should be copied always or only if they have + // changed. + bool copy_always = + cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS")); + // Handle each file listed. for ( i = 0; i < files.size(); i ++ ) { @@ -825,7 +861,8 @@ bool cmFileCommand::HandleInstallCommand( message = "Installing "; message += toFile.c_str(); this->Makefile->DisplayStatus(message.c_str(), -1); - if(!cmSystemTools::CopyADirectory(fromFile.c_str(), toFile.c_str())) + if(!cmSystemTools::CopyADirectory(fromFile.c_str(), toFile.c_str(), + copy_always)) { cmOStringStream e; e << "INSTALL cannot copy directory \"" << fromFile @@ -841,9 +878,9 @@ bool cmFileCommand::HandleInstallCommand( message += toFile.c_str(); this->Makefile->DisplayStatus(message.c_str(), -1); - // Copy the file, but only if it has changed. - if(!cmSystemTools::CopyFileIfDifferent(fromFile.c_str(), - toFile.c_str())) + // Copy the file. + if(!cmSystemTools::CopyAFile(fromFile.c_str(), toFile.c_str(), + copy_always)) { cmOStringStream e; e << "INSTALL cannot copy file \"" << fromFile diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a18073f..0911f35 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -169,42 +169,21 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, // files from the parent cmake bin dir, into the try compile bin dir if(this->ConfiguredFilesPath.size()) { - std::string src = this->ConfiguredFilesPath; - src += "/CMakeSystem.cmake"; - std::string dst = rootBin; - dst += "/CMakeSystem.cmake"; - cmSystemTools::CopyFileIfDifferent(src.c_str(), dst.c_str()); for(std::vector::const_iterator l = languages.begin(); l != languages.end(); ++l) { if(*l == "NONE") { this->SetLanguageEnabled("NONE", mf); - continue; + break; } - const char* lang = l->c_str(); - std::string src2 = this->ConfiguredFilesPath; - src2 += "/CMake"; - src2 += lang; - src2 += "Compiler.cmake"; - std::string dst2 = rootBin; - dst2 += "/CMake"; - dst2 += lang; - dst2 += "Compiler.cmake"; - cmSystemTools::CopyFileIfDifferent(src2.c_str(), dst2.c_str()); - src2 = this->ConfiguredFilesPath; - src2 += "/CMake"; - src2 += lang; - src2 += "Platform.cmake"; - dst2 = rootBin; - dst2 += "/CMake"; - dst2 += lang; - dst2 += "Platform.cmake"; - cmSystemTools::CopyFileIfDifferent(src2.c_str(), dst2.c_str()); } rootBin = this->ConfiguredFilesPath; } + // set the dir for parent files so they can be used by modules + mf->AddDefinition("CMAKE_PLATFORM_ROOT_BIN",rootBin.c_str()); + // find and make sure CMAKE_MAKE_PROGRAM is defined this->FindMakeProgram(mf); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 1a92293..f1ee981 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -501,6 +501,67 @@ cmGlobalUnixMakefileGenerator3 this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", false, true); } + +std::string cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(const char* makeProgram, + const char *projectName, const char* additionalOptions, const char *targetName, + const char* config, bool ignoreErrors) +{ + // Project name and config are not used yet. + (void)projectName; + (void)config; + + std::string makeCommand = cmSystemTools::ConvertToUnixOutputPath(makeProgram); + + // Since we have full control over the invocation of nmake, let us + // make it quiet. + if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) + { + makeCommand += " /NOLOGO "; + } + if ( ignoreErrors ) + { + makeCommand += " -i"; + } + if ( additionalOptions ) + { + makeCommand += " "; + makeCommand += additionalOptions; + } + if ( targetName && strlen(targetName)) + { + cmLocalUnixMakefileGenerator3 *lg; + if (this->LocalGenerators.size()) + { + lg = static_cast(this->LocalGenerators[0]); + } + else + { + lg = static_cast(this->CreateLocalGenerator()); + // set the Start directories + lg->GetMakefile()->SetStartDirectory + (this->CMakeInstance->GetStartDirectory()); + lg->GetMakefile()->SetStartOutputDirectory + (this->CMakeInstance->GetStartOutputDirectory()); + lg->GetMakefile()->MakeStartDirectoriesCurrent(); + } + + lg->SetupPathConversions(); + makeCommand += " \""; + std::string tname = targetName; + tname += "/fast"; + tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + tname = lg->ConvertToMakeTarget(tname.c_str()); + makeCommand += tname.c_str(); + makeCommand += "\""; + if (!this->LocalGenerators.size()) + { + delete lg; + } + } + return makeCommand; +} + //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 @@ -550,7 +611,34 @@ cmGlobalUnixMakefileGenerator3 "Build rule for target.", t->second.GetName(), depends, commands, true); + + // Add a fast rule to build the target + std::string localName = lg->GetRelativeTargetDirectory(t->second); + std::string makefileName; + makefileName = localName; + makefileName += "/build.make"; + depends.clear(); + commands.clear(); + std::string makeTargetName = localName; + makeTargetName += "/build"; + localName = t->second.GetName(); + localName += "/fast"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(), makeTargetName.c_str())); + lg->WriteMakeRule(ruleFileStream, "fast build rule for target.", + localName.c_str(), depends, commands, true); } + } + else + { + // Add a fast rule to build the target + depends.clear(); + commands.clear(); + std::string localName = t->second.GetName(); + depends.push_back(localName); + localName += "/fast"; + lg->WriteMakeRule(ruleFileStream, "fast build rule for target.", + localName.c_str(), depends, commands, true); } } } @@ -578,20 +666,22 @@ cmGlobalUnixMakefileGenerator3 cmTargets& targets = lg->GetMakefile()->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { + if (t->second.GetName() && strlen(t->second.GetName())) + { + std::string makefileName; + // Add a rule to build the target by name. + localName = lg->GetRelativeTargetDirectory(t->second); + makefileName = localName; + makefileName += "/build.make"; + if (((t->second.GetType() == cmTarget::EXECUTABLE) || (t->second.GetType() == cmTarget::STATIC_LIBRARY) || (t->second.GetType() == cmTarget::SHARED_LIBRARY) || (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::UTILITY)) && - t->second.GetName() && - strlen(t->second.GetName())) + (t->second.GetType() == cmTarget::UTILITY))) { bool needRequiresStep = this->NeedRequiresStep(lg,t->second.GetName()); - // Add a rule to build the target by name. - localName = lg->GetRelativeTargetDirectory(t->second); - std::string makefileName = localName; - makefileName += "/build.make"; lg->WriteDivider(ruleFileStream); ruleFileStream @@ -689,6 +779,7 @@ cmGlobalUnixMakefileGenerator3 depends.push_back(makeTargetName); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", "clean", depends, commands, true); + } } } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 76bc011..72b6761 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -113,6 +113,15 @@ public: /** Get the command to use for a non-symbolic target file that has no rule. This is used for multiple output dependencies. */ std::string GetEmptyCommandHack() { return this->EmptyCommandsHack; } + + + // change the build command for speed + virtual std::string GenerateBuildCommand + (const char* makeProgram, + const char *projectName, const char* additionalOptions, + const char *targetName, + const char* config, bool ignoreErrors); + protected: void WriteMainMakefile2(); void WriteMainCMakefile(); diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index d2b5b6f..164727a 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -32,6 +32,7 @@ void cmGlobalVisualStudio6Generator::EnableLanguage(std::vectorcons mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); + mf->AddDefinition("MSVC60", "1"); this->GenerateConfigurations(mf); this->cmGlobalGenerator::EnableLanguage(lang, mf); } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index d25785b..f37ecf2 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -39,7 +39,10 @@ cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator() return lg; } - +void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + mf->AddDefinition("MSVC71", "1"); +} // Write a SLN file to the stream void cmGlobalVisualStudio71Generator::WriteSLNFile(std::ostream& fout, diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 976758c..dc51fe0 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -44,6 +44,7 @@ public: virtual cmLocalGenerator *CreateLocalGenerator(); protected: + virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index f1bf776..970e7ef 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -37,6 +37,8 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(std::vectorcons mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); + this->AddPlatformDefinitions(mf); + // Create list of configurations requested by user's cache, if any. this->cmGlobalGenerator::EnableLanguage(lang, mf); this->GenerateConfigurations(mf); @@ -58,6 +60,11 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(std::vectorcons } +void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + mf->AddDefinition("MSVC70", "1"); +} + std::string cmGlobalVisualStudio7Generator::GenerateBuildCommand(const char* makeProgram, const char *projectName, const char* additionalOptions, const char *targetName, const char* config, bool ignoreErrors) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 59588ce..1344c8a 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -107,6 +107,7 @@ protected: bool in_all); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); + virtual void AddPlatformDefinitions(cmMakefile* mf); void GenerateConfigurations(cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 051f718..f92d7bb 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -57,6 +57,12 @@ void cmGlobalVisualStudio8Generator::GetDocumentation(cmDocumentationEntry& entr } //---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + mf->AddDefinition("MSVC80", "1"); +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::Configure() { this->cmGlobalVisualStudio7Generator::Configure(); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index c4992e0..8fd1937 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -49,6 +49,7 @@ public: virtual void Configure(); virtual void Generate(); protected: + virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index 03fe69e..7a9248f 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -42,13 +42,14 @@ bool cmIncludeExternalMSProjectCommand::InitialPass(std::vector con std::string utility_name("INCLUDE_EXTERNAL_MSPROJECT"); utility_name += "_"; utility_name += args[0]; - + std::string path = args[1]; + cmSystemTools::ConvertToUnixSlashes(path); const char* no_output = 0; const char* no_working_directory = 0; this->Makefile->AddUtilityCommand(utility_name.c_str(), true, no_output, depends, no_working_directory, - args[0].c_str(), args[1].c_str()); + args[0].c_str(), path.c_str()); } #endif diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0669b7f..057f3e0 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -123,6 +123,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) bool doing_destination = false; bool doing_permissions = false; bool doing_component = false; + bool doing_configurations = false; bool archive_settings = true; bool library_settings = true; bool runtime_settings = true; @@ -136,6 +137,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) std::string archive_component; std::string library_component; std::string runtime_component; + std::vector archive_configurations; + std::vector library_configurations; + std::vector runtime_configurations; for(unsigned int i=1; i < args.size(); ++i) { if(args[i] == "DESTINATION") @@ -145,6 +149,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) doing_destination = true; doing_permissions = false; doing_component = false; + doing_configurations = false; } else if(args[i] == "PERMISSIONS") { @@ -153,6 +158,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) doing_destination = false; doing_permissions = true; doing_component = false; + doing_configurations = false; } else if(args[i] == "COMPONENT") { @@ -161,6 +167,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) doing_destination = false; doing_permissions = false; doing_component = true; + doing_configurations = false; + } + else if(args[i] == "CONFIGURATIONS") + { + // Switch to setting the configurations property. + doing_targets = false; + doing_destination = false; + doing_permissions = false; + doing_component = false; + doing_configurations = true; } else if(args[i] == "ARCHIVE") { @@ -169,6 +185,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) doing_destination = false; doing_permissions = false; doing_component = false; + doing_configurations = false; archive_settings = true; library_settings = false; runtime_settings = false; @@ -180,6 +197,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) doing_destination = false; doing_permissions = false; doing_component = false; + doing_configurations = false; archive_settings = false; library_settings = true; runtime_settings = false; @@ -191,6 +209,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) doing_destination = false; doing_permissions = false; doing_component = false; + doing_configurations = false; archive_settings = false; library_settings = false; runtime_settings = true; @@ -300,6 +319,22 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) } } } + else if(doing_configurations) + { + // Add the configuration in the active set(s) of properties. + if(archive_settings) + { + archive_configurations.push_back(args[i]); + } + if(library_settings) + { + library_configurations.push_back(args[i]); + } + if(runtime_settings) + { + runtime_configurations.push_back(args[i]); + } + } else { // Unknown argument. @@ -351,6 +386,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) this->Makefile->AddInstallGenerator( new cmInstallTargetGenerator(target, archive_dest.c_str(), true, archive_permissions.c_str(), + archive_configurations, archive_component.c_str())); } if(runtime_destination) @@ -359,6 +395,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) this->Makefile->AddInstallGenerator( new cmInstallTargetGenerator(target, runtime_dest.c_str(), false, runtime_permissions.c_str(), + runtime_configurations, runtime_component.c_str())); } #else @@ -369,6 +406,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) this->Makefile->AddInstallGenerator( new cmInstallTargetGenerator(target, library_dest.c_str(), false, library_permissions.c_str(), + library_configurations, library_component.c_str())); } else @@ -390,6 +428,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) this->Makefile->AddInstallGenerator( new cmInstallTargetGenerator(target, archive_dest.c_str(), false, archive_permissions.c_str(), + archive_configurations, archive_component.c_str())); } else @@ -410,6 +449,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) this->Makefile->AddInstallGenerator( new cmInstallTargetGenerator(target, library_dest.c_str(), false, library_permissions.c_str(), + library_configurations, library_component.c_str())); } else @@ -430,6 +470,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) this->Makefile->AddInstallGenerator( new cmInstallTargetGenerator(target, runtime_dest.c_str(), false, runtime_permissions.c_str(), + runtime_configurations, runtime_component.c_str())); } else @@ -469,12 +510,14 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) bool doing_files = true; bool doing_destination = false; bool doing_permissions = false; + bool doing_configurations = false; bool doing_component = false; bool doing_rename = false; std::vector files; const char* destination = 0; std::string rename; std::string permissions; + std::vector configurations; std::string component; for(unsigned int i=1; i < args.size(); ++i) { @@ -484,6 +527,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) doing_files = false; doing_destination = true; doing_permissions = false; + doing_configurations = false; doing_component = false; doing_rename = false; } @@ -493,6 +537,17 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) doing_files = false; doing_destination = false; doing_permissions = true; + doing_configurations = false; + doing_component = false; + doing_rename = false; + } + else if(args[i] == "CONFIGURATIONS") + { + // Switch to setting the configurations property. + doing_files = false; + doing_destination = false; + doing_permissions = false; + doing_configurations = true; doing_component = false; doing_rename = false; } @@ -502,6 +557,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) doing_files = false; doing_destination = false; doing_permissions = false; + doing_configurations = false; doing_component = true; doing_rename = false; } @@ -511,6 +567,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) doing_files = false; doing_destination = false; doing_permissions = false; + doing_configurations = false; doing_component = false; doing_rename = true; } @@ -537,6 +594,10 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) // Store the file for installation. files.push_back(file); } + else if(doing_configurations) + { + configurations.push_back(args[i]); + } else if(doing_destination) { destination = args[i].c_str(); @@ -603,8 +664,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) // Create the files install generator. this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(files, dest.c_str(), programs, - permissions.c_str(), component.c_str(), - rename.c_str())); + permissions.c_str(), configurations, + component.c_str(), rename.c_str())); // Tell the global generator about any installation component names // specified. diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 3c10e5a..f325f06 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -83,6 +83,8 @@ public: "SETUID, and SETGID. " "Permissions that do not make sense on certain platforms are ignored " "on those platforms. " + "The CONFIGURATIONS argument specifies a list of build configurations " + "for which the install rule applies (Debug, Release, etc.). " "The COMPONENT argument specifies an installation component name " "with which the install rule is associated, such as \"runtime\" or " "\"development\". During component-specific installation only " @@ -96,6 +98,7 @@ public: " INSTALL(TARGETS targets... [[ARCHIVE|LIBRARY|RUNTIME]\n" " [DESTINATION ]\n" " [PERMISSIONS permissions...]\n" + " [CONFIGURATIONS [Debug|Release|...]]\n" " [COMPONENT ]\n" " ] [...])\n" "The TARGETS form specifies rules for installing targets from a " @@ -138,6 +141,7 @@ public: "The FILES signature:\n" " INSTALL(FILES files... DESTINATION \n" " [PERMISSIONS permissions...]\n" + " [CONFIGURATIONS [Debug|Release|...]]\n" " [COMPONENT ]\n" " [RENAME ])\n" "The FILES form specifies rules for installing files for a " @@ -149,6 +153,7 @@ public: "The PROGRAMS signature:\n" " INSTALL(PROGRAMS files... DESTINATION \n" " [PERMISSIONS permissions...]\n" + " [CONFIGURATIONS [Debug|Release|...]]\n" " [COMPONENT ]\n" " [RENAME ])\n" "The PROGRAMS form is identical to the FILES form except that the " diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index bf0d830..7990b2a 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -23,10 +23,12 @@ cmInstallFilesGenerator ::cmInstallFilesGenerator(std::vector const& files, const char* dest, bool programs, const char* permissions, + std::vector const& configurations, const char* component, const char* rename): Files(files), Destination(dest), Programs(programs), - Permissions(permissions), Component(component), Rename(rename) + Permissions(permissions), Configurations(configurations), + Component(component), Rename(rename) { } @@ -51,6 +53,7 @@ void cmInstallFilesGenerator::GenerateScript(std::ostream& os) : cmTarget::INSTALL_FILES), fi->c_str(), not_optional, no_properties, this->Permissions.c_str(), + this->Configurations, this->Component.c_str(), this->Rename.c_str()); } diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 7732ff9..4589b1e 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -28,6 +28,7 @@ public: cmInstallFilesGenerator(std::vector const& files, const char* dest, bool programs, const char* permissions, + std::vector const& configurations, const char* component, const char* rename); virtual ~cmInstallFilesGenerator(); @@ -38,6 +39,7 @@ protected: std::string Destination; bool Programs; std::string Permissions; + std::vector Configurations; std::string Component; std::string Rename; }; diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 44b6936..f1154fb 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -47,15 +47,18 @@ cmInstallGenerator } //---------------------------------------------------------------------------- -void cmInstallGenerator::AddInstallRule(std::ostream& os, +void cmInstallGenerator::AddInstallRule( + std::ostream& os, const char* dest, int type, const char* file, bool optional /* = false */, const char* properties /* = 0 */, const char* permissions /* = 0 */, + std::vector const& configurations /* = std::vector() */, const char* component /* = 0 */, - const char* rename /* = 0 */) + const char* rename /* = 0 */ + ) { // Use the FILE command to install the file. std::string stype; @@ -87,6 +90,15 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os, { os << " RENAME \"" << rename << "\""; } + if(!configurations.empty()) + { + os << " CONFIGURATIONS"; + for(std::vector::const_iterator c = configurations.begin(); + c != configurations.end(); ++c) + { + os << " \"" << *c << "\""; + } + } if(component && *component) { os << " COMPONENTS \"" << component << "\""; diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index fee0d68..017c63a 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -34,12 +34,15 @@ public: void Generate(std::ostream& os, const char* config, std::vector const& configurationTypes); - static void AddInstallRule(std::ostream& os, const char* dest, int type, - const char* file, bool optional = false, - const char* properties = 0, - const char* permissions = 0, - const char* component = 0, - const char* rename = 0); + static void AddInstallRule( + std::ostream& os, const char* dest, int type, + const char* file, bool optional = false, + const char* properties = 0, + const char* permissions = 0, + std::vector const& configurations =std::vector(), + const char* component = 0, + const char* rename = 0 + ); protected: virtual void GenerateScript(std::ostream& os)=0; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 690904a..b5cf240 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -24,9 +24,12 @@ //---------------------------------------------------------------------------- cmInstallTargetGenerator ::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, - const char* permissions, const char* component): + const char* permissions, + std::vector const& configurations, + const char* component): Target(&t), Destination(dest), ImportLibrary(implib), - Permissions(permissions), Component(component) + Permissions(permissions), Configurations(configurations), + Component(component) { this->Target->SetHaveInstallRule(true); } @@ -145,7 +148,9 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) // Write code to install the target file. this->AddInstallRule(os, destination.c_str(), type, fromFile.c_str(), this->ImportLibrary, properties, - this->Permissions.c_str(), this->Component.c_str()); + this->Permissions.c_str(), + this->Configurations, + this->Component.c_str()); // Fix the install_name settings in installed binaries. if(type == cmTarget::SHARED_LIBRARY || diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 7d88bde..777b7af 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -27,9 +27,12 @@ class cmTarget; class cmInstallTargetGenerator: public cmInstallGenerator { public: - cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, - const char* permissions = "", - const char* component = ""); + cmInstallTargetGenerator( + cmTarget& t, const char* dest, bool implib, + const char* permissions = "", + std::vector const& configurations =std::vector(), + const char* component = "" + ); virtual ~cmInstallTargetGenerator(); protected: @@ -44,6 +47,7 @@ protected: std::string Destination; bool ImportLibrary; std::string Permissions; + std::vector Configurations; std::string Component; }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c0f029b..8a65684 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -289,6 +289,30 @@ void cmLocalGenerator::GenerateInstallRules() config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); } + // Choose a default install configuration. + const char* default_config = config; + const char* default_order[] = {"RELEASE", "MINSIZEREL", + "RELWITHDEBINFO", "DEBUG", 0}; + for(const char** c = default_order; *c && !default_config; ++c) + { + for(std::vector::iterator i = configurationTypes.begin(); + i != configurationTypes.end(); ++i) + { + if(cmSystemTools::UpperCase(*i) == *c) + { + default_config = i->c_str(); + } + } + } + if(!default_config && !configurationTypes.empty()) + { + default_config = configurationTypes[0].c_str(); + } + if(!default_config) + { + default_config = "Release"; + } + // Create the install script file. std::string file = this->Makefile->GetStartOutputDirectory(); std::string homedir = this->Makefile->GetHomeOutputDirectory(); @@ -323,7 +347,7 @@ void cmLocalGenerator::GenerateInstallRules() " STRING(REGEX REPLACE \"^[^A-Za-z0-9_]+\" \"\"\n" " CMAKE_INSTALL_CONFIG_NAME \"${BUILD_TYPE}\")\n" " ELSE(BUILD_TYPE)\n" - " SET(CMAKE_INSTALL_CONFIG_NAME Release)\n" + " SET(CMAKE_INSTALL_CONFIG_NAME \"" << default_config << "\")\n" " ENDIF(BUILD_TYPE)\n" " MESSAGE(STATUS \"Install configuration: \\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n" "ENDIF(NOT CMAKE_INSTALL_CONFIG_NAME)\n" @@ -1955,9 +1979,11 @@ cmLocalGenerator const char* no_permissions = ""; const char* no_rename = ""; const char* no_component = ""; + std::vector no_configurations; cmInstallFilesGenerator g(l->second.GetSourceLists(), destination.c_str(), false, - no_permissions, no_component, no_rename); + no_permissions, no_configurations, + no_component, no_rename); g.Generate(os, config, configurationTypes); } break; @@ -1967,9 +1993,11 @@ cmLocalGenerator const char* no_permissions = ""; const char* no_rename = ""; const char* no_component = ""; + std::vector no_configurations; cmInstallFilesGenerator g(l->second.GetSourceLists(), destination.c_str(), true, - no_permissions, no_component, no_rename); + no_permissions, no_configurations, + no_component, no_rename); g.Generate(os, config, configurationTypes); } break; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 051b478..ce26fac 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1275,6 +1275,7 @@ cmLocalUnixMakefileGenerator3 includeRegexScan.c_str(), includeRegexComplain.c_str(), generatedFiles, includeCacheFileName); + scanner->SetHomeOutputDirectory(mf->GetHomeOutputDirectory()); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") @@ -1418,6 +1419,11 @@ void cmLocalUnixMakefileGenerator3 this->Makefile->GetStartOutputDirectory()); this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands, true); + commands.clear(); + depends.clear(); + depends.push_back("clean"); + this->WriteMakeRule(ruleFileStream, "The main clean target", "clean/fast", + depends, commands, true); // Write the preinstall rule. dir = this->Makefile->GetStartOutputDirectory(); @@ -1444,6 +1450,10 @@ void cmLocalUnixMakefileGenerator3 this->Makefile->GetStartOutputDirectory()); this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", "preinstall", depends, commands, true); + commands.clear(); + depends.push_back("preinstall"); + this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", + "preinstall/fast", depends, commands, true); // write the depend rule, really a recompute depends rule depends.clear(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 96b609a..b95c72b 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -262,6 +262,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {"EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1"}, {"FavorSizeOrSpeed", "Ot", "Favor fast code", "1"}, {"FavorSizeOrSpeed", "Os", "Favor small code", "2"}, + {"CompileAs", "TC", "Compile as c code", "1"}, + {"CompileAs", "TP", "Compile as c++ code", "2"}, {"Optimization", "Od", "Non Debug", "0"}, {"Optimization", "O1", "Min Size", "1"}, {"Optimization", "O2", "Max Speed", "2"}, @@ -395,6 +397,15 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, flags += " "; flags += this->Makefile->GetRequiredDefinition(flagVar.c_str()); } + // set the correct language + if(strcmp(linkLanguage, "C") == 0) + { + flags += " /TC "; + } + if(strcmp(linkLanguage, "CXX") == 0) + { + flags += " /TP "; + } } // Add the target-specific flags. @@ -1035,10 +1046,21 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget } const char* lang = this->GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); - if(lang && strcmp(lang, "CXX") == 0) + const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); + // if the source file does not match the linker language + // then force c or c++ + if(linkLanguage && lang && strcmp(lang, linkLanguage) != 0) + { + if(strcmp(lang, "CXX") == 0) { // force a C++ file type compileFlags += " /TP "; + } + else if(strcmp(lang, "C") == 0) + { + // force to c + compileFlags += " /TC "; + } } // Check for extra object-file dependencies. const char* deps = (*sf)->GetProperty("OBJECT_DEPENDS"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2742206..940cd05 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -804,6 +804,21 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, cmTargets::iterator i = this->Targets.find(target); if ( i != this->Targets.end()) { + cmTarget* tgt = + this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0, lib); + if(tgt) + { + // if it is not a static or shared library then you can not link to it + if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) || + (tgt->GetType() == cmTarget::SHARED_LIBRARY))) + { + cmOStringStream e; + e << "Attempt to add link library " << lib + << " which is not a library target to target " << tgt->GetType() << " " << + target << "\n"; + cmSystemTools::Error(e.str().c_str()); + } + } i->second.AddLinkLibrary( *this, target, lib, llt ); } else diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 303ff78..7ab15ba 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -23,9 +23,10 @@ // The class must be found in dir and end in name.cxx, name.txx, // name.c or it will be considered a header file only class // and not included in the build process -void cmSourceFile::SetName(const char* name, const char* dir, +bool cmSourceFile::SetName(const char* name, const char* dir, const std::vector& sourceExts, - const std::vector& headerExts) + const std::vector& headerExts, + const char* target) { this->SetProperty("HEADER_FILE_ONLY","1"); @@ -79,7 +80,7 @@ void cmSourceFile::SetName(const char* name, const char* dir, { this->SetProperty("EXTERNAL_OBJECT", "1"); } - return; + return true; } // Next, try the various source extensions @@ -94,7 +95,7 @@ void cmSourceFile::SetName(const char* name, const char* dir, this->SourceExtension = *ext; this->SetProperty("HEADER_FILE_ONLY","0"); this->FullPath = hname; - return; + return true; } } @@ -109,25 +110,29 @@ void cmSourceFile::SetName(const char* name, const char* dir, { this->SourceExtension = *ext; this->FullPath = hname; - return; + return true; } } - std::string errorMsg = "\n\nTried"; + cmOStringStream e; + e << "Cannot find source file \"" << pathname << "\""; + if(target) + { + e << " for target \"" << target << "\""; + } + e << "\n\nTried extensions"; for( std::vector::const_iterator ext = sourceExts.begin(); ext != sourceExts.end(); ++ext ) { - errorMsg += " ."; - errorMsg += *ext; + e << " ." << *ext; } for( std::vector::const_iterator ext = headerExts.begin(); ext != headerExts.end(); ++ext ) { - errorMsg += " ."; - errorMsg += *ext; + e << " ." << *ext; } - cmSystemTools::Error("can not find file ", pathname.c_str(), - errorMsg.c_str()); + cmSystemTools::Error(e.str().c_str()); + return false; } void cmSourceFile::SetName(const char* name, const char* dir, const char *ext, diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 656d5f0..3f81ea7 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -46,9 +46,10 @@ public: * in. The various extensions provided are tried on the name * (e.g., cxx, cpp) in the directory to find the actual file. */ - void SetName(const char* name, const char* dir, + bool SetName(const char* name, const char* dir, const std::vector& sourceExts, - const std::vector& headerExts); + const std::vector& headerExts, + const char* target = 0); /** * Get the list of the custom commands for this source file diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index b32f3da..c202d24 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -68,8 +68,11 @@ public: "be placed in this group. If a file matches multiple groups, the LAST " "group that explicitly lists the file will be favored, if any. If no " "group explicitly lists the file, the LAST group whose regular " - "expression matches the file will be favored. For backwards " - "compatibility, this command is also supports the format:\n" + "expression matches the file will be favored.\n" + "The name of the group may contain backslashes to specify subgroups:\n" + " SOURCE_GROUP(outer\\\\inner ...)\n" + "For backwards compatibility, this command is also supports the " + "format:\n" " SOURCE_GROUP(name regex)"; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index efa20f8..f0132e3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -299,7 +299,7 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf) file.SetProperty("ABSTRACT","0"); file.SetName(temps.c_str(), mf.GetCurrentDirectory(), mf.GetSourceExtensions(), - mf.GetHeaderExtensions()); + mf.GetHeaderExtensions(), this->Name.c_str()); this->SourceFiles.push_back(mf.AddSource(file)); } } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 89ccd6d..1a878d5 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1637,11 +1637,26 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) return true; } +//---------------------------------------------------------------------------- +bool SystemTools::CopyAFile(const char* source, const char* destination, + bool always) +{ + if(always) + { + return SystemTools::CopyFileAlways(source, destination); + } + else + { + return SystemTools::CopyFileIfDifferent(source, destination); + } +} + /** * Copy a directory content from "source" directory to the directory named by * "destination". */ -bool SystemTools::CopyADirectory(const char* source, const char* destination) +bool SystemTools::CopyADirectory(const char* source, const char* destination, + bool always) { Directory dir; dir.Load(source); @@ -1663,14 +1678,16 @@ bool SystemTools::CopyADirectory(const char* source, const char* destination) kwsys_stl::string fullDestPath = destination; fullDestPath += "/"; fullDestPath += dir.GetFile(static_cast(fileNum)); - if (!SystemTools::CopyADirectory(fullPath.c_str(), fullDestPath.c_str())) + if (!SystemTools::CopyADirectory(fullPath.c_str(), + fullDestPath.c_str(), + always)) { return false; } } else { - if(!SystemTools::CopyFileAlways(fullPath.c_str(), destination)) + if(!SystemTools::CopyAFile(fullPath.c_str(), destination, always)) { return false; } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index af26444..9e3e68d 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -469,10 +469,21 @@ public: static bool CopyFileAlways(const char* source, const char* destination); /** + * Copy a file. If the "always" argument is true the file is always + * copied. If it is false, the file is copied only if it is new or + * has changed. + */ + static bool CopyAFile(const char* source, const char* destination, + bool always = true); + + /** * Copy content directory to another directory with all files and - * subdirectories + * subdirectories. If the "always" argument is true all files are + * always copied. If it is false, only files that have changed or + * are new are copied. */ - static bool CopyADirectory(const char* source, const char* destination); + static bool CopyADirectory(const char* source, const char* destination, + bool always = true); /** * Remove a file diff --git a/Tests/COnly/conly.c b/Tests/COnly/conly.c index e8280ec..7214fe1 100644 --- a/Tests/COnly/conly.c +++ b/Tests/COnly/conly.c @@ -7,6 +7,7 @@ int main () { + int class = 0; if ( LibC1Func() != 2.0 ) { printf("Problem with libc1\n"); @@ -17,6 +18,6 @@ int main () printf("Problem with libc2\n"); return 1; } - printf("Foo: %s\n", foo); + printf("Foo: %s %d\n", foo, class); return 0; } diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index aa9dfe4..c2de5b1 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -72,6 +72,14 @@ IF(STAGE2) MESSAGE(SEND_ERROR "test1 not found in lib/static!") ENDIF("${TEST1_LIBRARY}" MATCHES "static") + # Check for failure of configuration-specific installation. + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + MESSAGE(FATAL_ERROR "Debug-configuration file installed for Release!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + MESSAGE(FATAL_ERROR "Release-configuration file installed for Debug!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -105,9 +113,9 @@ ELSE(STAGE2) ADD_DEPENDENCIES(test4 test2) INSTALL(TARGETS SimpleInstall test1 test2 test3 - RUNTIME DESTINATION MyTest/bin # .exe, .dll - LIBRARY DESTINATION MyTest/lib # .so, module.dll, ... - ARCHIVE DESTINATION MyTest/lib/static # .a, .lib + RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll + LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll + ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib ) INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE RUNTIME DESTINATION MyTest/bin @@ -122,6 +130,14 @@ ELSE(STAGE2) ) INSTALL_FILES(/MyTest/include FILES lib3.h) + # Test configuration-specific installation. + INSTALL(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release + DESTINATION MyTest/include/Release + ) + INSTALL(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug + DESTINATION MyTest/include/Debug + ) + # Test user-specified install scripts. INSTALL( SCRIPT InstallScript1.cmake diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index aa9dfe4..c2de5b1 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -72,6 +72,14 @@ IF(STAGE2) MESSAGE(SEND_ERROR "test1 not found in lib/static!") ENDIF("${TEST1_LIBRARY}" MATCHES "static") + # Check for failure of configuration-specific installation. + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + MESSAGE(FATAL_ERROR "Debug-configuration file installed for Release!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + MESSAGE(FATAL_ERROR "Release-configuration file installed for Debug!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -105,9 +113,9 @@ ELSE(STAGE2) ADD_DEPENDENCIES(test4 test2) INSTALL(TARGETS SimpleInstall test1 test2 test3 - RUNTIME DESTINATION MyTest/bin # .exe, .dll - LIBRARY DESTINATION MyTest/lib # .so, module.dll, ... - ARCHIVE DESTINATION MyTest/lib/static # .a, .lib + RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll + LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll + ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib ) INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE RUNTIME DESTINATION MyTest/bin @@ -122,6 +130,14 @@ ELSE(STAGE2) ) INSTALL_FILES(/MyTest/include FILES lib3.h) + # Test configuration-specific installation. + INSTALL(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release + DESTINATION MyTest/include/Release + ) + INSTALL(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug + DESTINATION MyTest/include/Debug + ) + # Test user-specified install scripts. INSTALL( SCRIPT InstallScript1.cmake diff --git a/Utilities/Release/cmake_release.sh.in b/Utilities/Release/cmake_release.sh.in index a4f0b51..7cfc32c 100755 --- a/Utilities/Release/cmake_release.sh.in +++ b/Utilities/Release/cmake_release.sh.in @@ -27,7 +27,7 @@ TAG="CMake-@CMake_VERSION_MAJOR@-@CMake_VERSION_MINOR@-@CMake_VERSION_PATCH@" VERSION="@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@.@CMake_VERSION_PATCH@" CMAKE_VERSION="@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@" RELEASE="1" -PREVIOUS_VERSION="2.0.6" +PREVIOUS_VERSION="2.2.3" PREVIOUS_RELEASE="1" # CVSROOT setting used to check out CMake. -- cgit v0.12