diff options
38 files changed, 536 insertions, 160 deletions
diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in index 8542ff6..2c7c724 100644 --- a/Modules/AutomocInfo.cmake.in +++ b/Modules/AutomocInfo.cmake.in @@ -11,5 +11,5 @@ set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" ) -set(AM_Qt5SrcTools_VERSION_MAJOR "@Qt5SrcTools_VERSION_MAJOR@" ) +set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" ) set(AM_TARGET_NAME "@_moc_target_name@") diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index c91553a..4cc690a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -48,6 +48,9 @@ #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" +#elif defined(__TINYC__) +# define COMPILER_ID "TinyCC" + #elif defined(__SCO_VERSION__) # define COMPILER_ID "SCO" diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake new file mode 100644 index 0000000..4a48c0a --- /dev/null +++ b/Modules/Compiler/TinyCC-C.cmake @@ -0,0 +1,8 @@ +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") + +# no optimization in tcc: +SET (CMAKE_C_FLAGS_INIT "") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") +SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") +SET (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g") diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d5ef430..4b176f1 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -443,7 +443,10 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR) # Search in the CUDA_BIN_PATH first. find_path(CUDA_TOOLKIT_ROOT_DIR NAMES nvcc nvcc.exe - PATHS ENV CUDA_BIN_PATH + PATHS + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 DOC "Toolkit location." NO_DEFAULT_PATH ) @@ -472,9 +475,10 @@ endif (NOT CUDA_TOOLKIT_ROOT_DIR) # CUDA_NVCC_EXECUTABLE find_program(CUDA_NVCC_EXECUTABLE NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}/bin" - "${CUDA_TOOLKIT_ROOT_DIR}/bin64" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. @@ -500,8 +504,10 @@ set(CUDA_VERSION_STRING "${CUDA_VERSION}") # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit - PATHS "${CUDA_TOOLKIT_ROOT_DIR}/include" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_INC_PATH + PATH_SUFFIXES include NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. @@ -516,19 +522,16 @@ macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) if(CMAKE_SIZEOF_VOID_P EQUAL 8) # CUDA 3.2+ on Windows moved the library directoryies, so we need the new # and old paths. - set(_cuda_64bit_lib_dir - "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" - "${CUDA_TOOLKIT_ROOT_DIR}/lib64" - ) + set(_cuda_64bit_lib_dir "lib/x64" "lib64" ) endif() # CUDA 3.2+ on Windows moved the library directories, so we need to new # (lib/Win32) and the old path (lib). find_library(${_var} NAMES ${_names} - PATHS ${_cuda_64bit_lib_dir} - "${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32" - "${CUDA_TOOLKIT_ROOT_DIR}/lib" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "lib/Win32" "lib" DOC ${_doc} NO_DEFAULT_PATH ) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index bccf789..f88eed0 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -106,7 +106,7 @@ endforeach(_library ${_list}) if(_libraries_work) # Test this combination of libraries. if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group ${${LIBRARIES}} ${_blas};-Wl,--end-group" ${_threads}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads}) else(UNIX AND BLA_STATIC) set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) endif(UNIX AND BLA_STATIC) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 77f9fda..166e291 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -17,9 +17,12 @@ # ZLIB_MAJOR_VERSION - The major version of zlib # ZLIB_MINOR_VERSION - The minor version of zlib # ZLIB_PATCH_VERSION - The patch version of zlib +# +# An includer may set ZLIB_ROOT to a zlib installation root to tell +# this module where to look. #============================================================================= -# Copyright 2001-2009 Kitware, Inc. +# Copyright 2001-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -31,17 +34,29 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PATH(ZLIB_INCLUDE_DIR zlib.h - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include" -) +SET(_ZLIB_SEARCHES) + +# Search ZLIB_ROOT first if it is set. +IF(ZLIB_ROOT) + SET(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH) + LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT) +ENDIF() + +# Normal search. +SET(_ZLIB_SEARCH_NORMAL + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" + "$ENV{PROGRAMFILES}/zlib" + ) +LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1) -FIND_LIBRARY(ZLIB_LIBRARY - NAMES - ${ZLIB_NAMES} - PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib" -) + +# Try each search configuration. +FOREACH(search ${_ZLIB_SEARCHES}) + FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include) + FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib) +ENDFOREACH() + MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") diff --git a/Modules/Platform/Linux-TinyCC-C.cmake b/Modules/Platform/Linux-TinyCC-C.cmake new file mode 100644 index 0000000..b753268 --- /dev/null +++ b/Modules/Platform/Linux-TinyCC-C.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") +SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "") +SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ") diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 630a0ba..4da1a3f 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -118,7 +118,7 @@ MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} - DEPENDS ${infile}) + DEPENDS ${infile} VERBATIM) ENDIF (WIN32) ENDMACRO (QT4_CREATE_MOC_COMMAND) @@ -165,7 +165,7 @@ MACRO (QT4_WRAP_UI outfiles ) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_UIC_EXECUTABLE} ARGS ${ui_options} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) + MAIN_DEPENDENCY ${infile} VERBATIM) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH (it) @@ -203,7 +203,7 @@ MACRO (QT4_ADD_RESOURCES outfiles ) COMMAND ${QT_RCC_EXECUTABLE} ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} - DEPENDS ${_RC_DEPENDS} "${out_depends}") + DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH (it) @@ -235,7 +235,7 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} - DEPENDS ${_infile}) + DEPENDS ${_infile} VERBATIM) SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) @@ -280,7 +280,7 @@ MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ADD_CUSTOM_COMMAND(OUTPUT ${_target} COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} - DEPENDS ${_in_file} + DEPENDS ${_in_file} VERBATIM ) ENDMACRO(QT4_GENERATE_DBUS_INTERFACE) @@ -304,12 +304,12 @@ MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional IF(_optionalClassName) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} + DEPENDS ${_infile} VERBATIM ) ELSE(_optionalClassName) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} + DEPENDS ${_infile} VERBATIM ) ENDIF(_optionalClassName) @@ -398,7 +398,7 @@ MACRO(QT4_CREATE_TRANSLATION _qm_files) ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file} COMMAND ${QT_LUPDATE_EXECUTABLE} ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} - DEPENDS ${_my_sources} ${_ts_pro}) + DEPENDS ${_my_sources} ${_ts_pro} VERBATIM) ENDFOREACH(_ts_file) QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) ENDMACRO(QT4_CREATE_TRANSLATION) @@ -419,7 +419,7 @@ MACRO(QT4_ADD_TRANSLATION _qm_files) ADD_CUSTOM_COMMAND(OUTPUT ${qm} COMMAND ${QT_LRELEASE_EXECUTABLE} ARGS ${_abs_FILE} -qm ${qm} - DEPENDS ${_abs_FILE} + DEPENDS ${_abs_FILE} VERBATIM ) SET(${_qm_files} ${${_qm_files}} ${qm}) ENDFOREACH (_current_FILE) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index b824392..027504f 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -68,7 +68,7 @@ SET(QT_QAXCONTAINER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE) -SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTWEBKIT QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTXML QTOPENGL QTGUI QTNETWORK QTCORE) +SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTGUI QTCORE) SET(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPT_MODULE_DEPENDS QTCORE) @@ -81,8 +81,8 @@ SET(QT_QTNETWORK_MODULE_DEPENDS QTCORE) # Qt modules (in order of dependence) FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP - QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST QTDBUS QTXML QTSQL - QTXMLPATTERNS QTNETWORK QTCORE) + QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTXMLPATTERNS QTGUI QTTEST + QTDBUS QTXML QTSQL QTNETWORK QTCORE) IF (QT_USE_${module} OR QT_USE_${module}_DEPENDS) IF (QT_${module}_FOUND) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 5205738..b5115b7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -162,6 +162,7 @@ SET(SRCS cmDocumentationSection.cxx cmDocumentCompileDefinitions.h cmDocumentGeneratorExpressions.h + cmDocumentLocationUndefined.h cmDocumentVariables.cxx cmDynamicLoader.cxx cmDynamicLoader.h @@ -216,6 +217,8 @@ SET(SRCS cmMakefileExecutableTargetGenerator.cxx cmMakefileLibraryTargetGenerator.cxx cmMakefileUtilityTargetGenerator.cxx + cmNewLineStyle.h + cmNewLineStyle.cxx cmOrderDirectories.cxx cmOrderDirectories.h cmPolicies.h diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index b4d9191..00aaf69 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -12,15 +12,16 @@ #include "AddCacheEntry.h" #include <QMetaProperty> +#include <QCompleter> static const int NumTypes = 4; -static const QString TypeStrings[NumTypes] = +static const QString TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; -static const QCMakeProperty::PropertyType Types[NumTypes] = - { QCMakeProperty::BOOL, QCMakeProperty::PATH, - QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; +static const QCMakeProperty::PropertyType Types[NumTypes] = + { QCMakeProperty::BOOL, QCMakeProperty::PATH, + QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) : QWidget(p) { this->setupUi(this); @@ -42,6 +43,7 @@ AddCacheEntry::AddCacheEntry(QWidget* p) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); + this->Name->setCompleter(new QCompleter(completions, this)); } QString AddCacheEntry::name() const diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index db6baf9..e219d4e 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -15,6 +15,7 @@ #include <QWidget> #include <QCheckBox> +#include <QStringList> #include "QCMake.h" #include "ui_AddCacheEntry.h" @@ -23,7 +24,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry { Q_OBJECT public: - AddCacheEntry(QWidget* p); + AddCacheEntry(QWidget* p, const QStringList& completions); QString name() const; QVariant value() const; diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index c8c4bfa..1c058d3 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -68,6 +68,9 @@ CMakeSetupDialog::CMakeSetupDialog() int w = settings.value("Width", 700).toInt(); this->resize(w, h); + this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + QWidget* cont = new QWidget(this); this->setupUi(cont); this->Splitter->setStretchFactor(0, 3); @@ -1008,7 +1011,7 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1021,6 +1024,26 @@ void CMakeSetupDialog::addCacheEntry() { QCMakeCacheModel* m = this->CacheValues->cacheModel(); m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); + + // only add variable names to the completion which are new + if (!this->AddVariableCompletions.contains(w->name())) + { + this->AddVariableCompletions << w->name(); + // limit to at most 100 completion items + if (this->AddVariableCompletions.size() > 100) + { + this->AddVariableCompletions.removeFirst(); + } + // make sure CMAKE_INSTALL_PREFIX is always there + if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + { + this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + } + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("AddVariableCompletionEntries", + this->AddVariableCompletions); + } } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 5121759..2599675 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -36,7 +36,7 @@ public slots: void setBinaryDirectory(const QString& dir); void setSourceDirectory(const QString& dir); -protected slots: +protected slots: void initialize(); void doConfigure(); void doGenerate(); @@ -46,7 +46,7 @@ protected slots: void doInterrupt(); void error(const QString& message); void message(const QString& message); - + void doSourceBrowse(); void doBinaryBrowse(); void doReloadCache(); @@ -105,6 +105,8 @@ protected: QTextCharFormat ErrorFormat; QTextCharFormat MessageFormat; + QStringList AddVariableCompletions; + QEventLoop LocalLoop; float ProgressOffset; @@ -118,8 +120,8 @@ class QCMakeThread : public QThread public: QCMakeThread(QObject* p); QCMake* cmakeInstance() const; - -signals: + +signals: void cmakeInitialized(); protected: diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index c1327fb..ea98326 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -65,6 +65,12 @@ bool cmConfigureFileCommand cmSystemTools::SetFatalErrorOccured(); return false; } + std::string errorMessage; + if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) + { + this->SetError(errorMessage.c_str()); + return false; + } this->CopyOnly = false; this->EscapeQuotes = false; @@ -78,6 +84,12 @@ bool cmConfigureFileCommand if(args[i] == "COPYONLY") { this->CopyOnly = true; + if (this->NewLineStyle.IsValid()) + { + this->SetError("COPYONLY could not be used in combination " + "with NEWLINE_STYLE"); + return false; + } } else if(args[i] == "ESCAPE_QUOTES") { @@ -122,7 +134,8 @@ int cmConfigureFileCommand::ConfigureFile() this->OutputFile.c_str(), this->CopyOnly, this->AtOnly, - this->EscapeQuotes); + this->EscapeQuotes, + this->NewLineStyle); } diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 844a23c..be33569 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -56,7 +56,8 @@ public: { return " configure_file(<input> <output>\n" - " [COPYONLY] [ESCAPE_QUOTES] [@ONLY])\n" + " [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n" + " [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n" "Copies a file <input> to file <output> and substitutes variable " "values referenced in the file content. " "If <input> is a relative path it is evaluated with respect to " @@ -81,14 +82,20 @@ public: "either #define VAR or /* #undef VAR */ depending on " "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR " "will be replaced with either #define VAR 1 or #define VAR 0 " - "depending on whether VAR evaluates to TRUE or FALSE in CMake"; + "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n" + "With NEWLINE_STYLE the line ending could be adjusted: \n" + " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" + "COPYONLY must not be used with NEWLINE_STYLE.\n"; } virtual void FinalPass(); virtual bool HasFinalPass() const { return !this->Immediate; } + private: int ConfigureFile(); + cmNewLineStyle NewLineStyle; + std::string InputFile; std::string OutputFile; bool CopyOnly; diff --git a/Source/cmDocumentLocationUndefined.h b/Source/cmDocumentLocationUndefined.h new file mode 100644 index 0000000..d1be77a --- /dev/null +++ b/Source/cmDocumentLocationUndefined.h @@ -0,0 +1,24 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmDocumentLocationUndefined_h +#define cmDocumentLocationUndefined_h + +#define CM_LOCATION_UNDEFINED_BEHAVIOR(action) \ + "\n" \ + "Do not set properties that affect the location of a target after " \ + action ". These include properties whose names match " \ + "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\" " \ + "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ + "Failure to follow this rule is not diagnosed and leaves the location " \ + "of the target undefined." + +#endif diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index f33e9e2..eb19d2e 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -13,6 +13,7 @@ #define cmExportCommand_h #include "cmCommand.h" +#include "cmDocumentLocationUndefined.h" class cmExportBuildFileGenerator; @@ -80,6 +81,7 @@ public: "should never be installed. " "See the install(EXPORT) command to export targets from an " "installation tree." + CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command") "\n" " export(PACKAGE <name>)\n" "Store the current build directory in the CMake user package registry " diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 65d6fa6..ffbeb48 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -96,14 +96,14 @@ void cmLocalGenerator::Configure() std::string filesDir = this->Makefile->GetStartOutputDirectory(); filesDir += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(filesDir.c_str()); - + // find & read the list file this->ReadInputFile(); // at the end of the ReadListFile handle any old style subdirs // first get all the subdirectories std::vector<cmLocalGenerator *> subdirs = this->GetChildren(); - + // for each subdir recurse std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) @@ -112,7 +112,7 @@ void cmLocalGenerator::Configure() { this->Makefile->ConfigureSubDirectory(*sdi); } - } + } // Check whether relative paths should be used for optionally // relative paths. @@ -212,10 +212,10 @@ void cmLocalGenerator::ReadInputFile() } void cmLocalGenerator::SetupPathConversions() -{ +{ // Setup the current output directory components for use by // Convert - std::string outdir; + std::string outdir; outdir = cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents); @@ -225,12 +225,12 @@ void cmLocalGenerator::SetupPathConversions() outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetHomeOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->HomeOutputDirectoryComponents); outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetStartOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->StartOutputDirectoryComponents); } @@ -289,17 +289,17 @@ void cmLocalGenerator::GenerateTestFiles() fout.SetCopyIfDifferent(true); fout << "# CMake generated Testfile for " << std::endl - << "# Source directory: " + << "# Source directory: " << this->Makefile->GetStartDirectory() << std::endl - << "# Build directory: " + << "# Build directory: " << this->Makefile->GetStartOutputDirectory() << std::endl << "# " << std::endl << "# This file includes the relevent testing commands " << "required for " << std::endl << "# testing this directory and lists subdirectories to " << "be tested as well." << std::endl; - - const char* testIncludeFile = + + const char* testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); if ( testIncludeFile ) { @@ -320,7 +320,7 @@ void cmLocalGenerator::GenerateTestFiles() for(i = 0; i < this->Children.size(); ++i) { fout << "SUBDIRS("; - std::string outP = + std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); fout << this->Convert(outP.c_str(),START_OUTPUT); fout << ")" << std::endl; @@ -472,7 +472,7 @@ void cmLocalGenerator::GenerateInstallRules() // Ask each install generator to write its code. std::vector<cmInstallGenerator*> const& installers = this->Makefile->GetInstallGenerators(); - for(std::vector<cmInstallGenerator*>::const_iterator + for(std::vector<cmInstallGenerator*>::const_iterator gi = installers.begin(); gi != installers.end(); ++gi) { @@ -553,15 +553,15 @@ void cmLocalGenerator::GenerateTargetManifest() } } -void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, +void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, + const char* lang, cmSourceFile& source, cmTarget& ) -{ +{ std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); - std::string sourceFile = + std::string sourceFile = this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true); std::string varString = "CMAKE_"; varString += lang; @@ -655,7 +655,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) ofname += "/"; ofname += obj; objVector.push_back(ofname); - this->AddCustomCommandToCreateObject(ofname.c_str(), + this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); objs += " "; @@ -672,7 +672,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) // Shared Module: std::string linkLibs; // should be set std::string flags; // should be set - std::string linkFlags; // should be set + std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, flags, linkFlags, target); cmLocalGenerator::RuleVariables vars; vars.Language = llang; @@ -682,17 +682,17 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); - + std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); this->AddArchitectureFlags(langFlags, &target, llang, 0); vars.LanguageCompileFlags = langFlags.c_str(); - + cmCustomCommandLines commandLines; std::vector<std::string> rules; rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str())); std::vector<std::string> commands; - cmSystemTools::ExpandList(rules, commands); + cmSystemTools::ExpandList(rules, commands); for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { @@ -728,21 +728,21 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) (this->Makefile->GetSource(targetFullPath.c_str())); } - + void cmLocalGenerator ::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang) -{ +{ cmTargets &tgts = this->Makefile->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; switch(target.GetType()) - { + { case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: + case cmTarget::EXECUTABLE: { const char* llang = target.GetLinkerLanguage(); if(!llang) @@ -759,7 +759,7 @@ void cmLocalGenerator this->AddBuildTargetRule(llang, target); } } - break; + break; default: break; } @@ -769,14 +769,14 @@ void cmLocalGenerator // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form <var> with GetSafeDefinition(var). -// ${LANG} is replaced in the variable first with all enabled +// ${LANG} is replaced in the variable first with all enabled // languages. static const char* ruleReplaceVars[] = { "CMAKE_${LANG}_COMPILER", "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS", "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS", - "CMAKE_SHARED_MODULE_${LANG}_FLAGS", + "CMAKE_SHARED_MODULE_${LANG}_FLAGS", "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS", "CMAKE_${LANG}_LINK_FLAGS", "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG", @@ -807,7 +807,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.Flags; } } - + if(replaceValues.Source) { if(variable == "SOURCE") @@ -870,7 +870,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(replaceValues.Target) - { + { if(variable == "TARGET_QUOTED") { std::string targetQuoted = replaceValues.Target; @@ -1018,13 +1018,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, int pos = 0; while(ruleReplaceVars[pos]) { - for(std::vector<std::string>::iterator i = enabledLanguages.begin(); - i != enabledLanguages.end(); ++i) - { + for(std::vector<std::string>::iterator i = enabledLanguages.begin(); + i != enabledLanguages.end(); ++i) + { const char* lang = i->c_str(); std::string actualReplace = ruleReplaceVars[pos]; // If this is the compiler then look for the extra variable - // _COMPILER_ARG1 which must be the first argument to the compiler + // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { @@ -1038,7 +1038,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(actualReplace == variable) { - std::string replace = + std::string replace = this->Makefile->GetSafeDefinition(variable.c_str()); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) @@ -1062,7 +1062,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } -void +void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { @@ -1213,7 +1213,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; - const char* includeFlag = + const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; @@ -1223,7 +1223,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, { quotePaths = true; } - bool repeatFlag = true; + bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB if(!sep) { @@ -1354,15 +1354,15 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, this->Makefile->GetDefinition("VTK_SOURCE_DIR"); if(vtkSourceDir) { - const char* vtk_major = + const char* vtk_major = this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = + const char* vtk_minor = this->Makefile->GetDefinition("VTK_MINOR_VERSION"); vtk_major = vtk_major? vtk_major : "4"; vtk_minor = vtk_minor? vtk_minor : "4"; int vmajor = 0; int vminor = 0; - if(sscanf(vtk_major, "%d", &vmajor) && + if(sscanf(vtk_major, "%d", &vmajor) && sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4) { includeSourceDir = true; @@ -1403,7 +1403,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } // Get the project-specified include directories. - std::vector<std::string>& includes = + std::vector<std::string>& includes = this->Makefile->GetIncludeDirectories(); // Support putting all the in-project include directories first if @@ -1446,17 +1446,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string& linkFlags, cmTarget& target) { - std::string buildType = + std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - buildType = cmSystemTools::UpperCase(buildType); - const char* libraryLinkVariable = + buildType = cmSystemTools::UpperCase(buildType); + const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library - + switch(target.GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmTarget::STATIC_LIBRARY: { - const char* targetLinkFlags = + const char* targetLinkFlags = target.GetProperty("STATIC_LIBRARY_FLAGS"); if(targetLinkFlags) { @@ -1475,11 +1475,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } } - break; + break; case cmTarget::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; case cmTarget::SHARED_LIBRARY: - { + { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; if(!buildType.empty()) @@ -1489,8 +1489,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } - if(this->Makefile->IsOn("WIN32") && + } + if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { const std::vector<cmSourceFile*>& sources = target.GetSourceFiles(); @@ -1500,14 +1500,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, cmSourceFile* sf = *i; if(sf->GetExtension() == "def") { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->Convert(sf->GetFullPath().c_str(), START_OUTPUT, SHELL); linkFlags += " "; } } - } + } const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); if(targetLinkFlags) { @@ -1520,11 +1520,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } - } + } cmOStringStream linklibsStr; this->OutputLinkLibraries(linklibsStr, target, false); linkLibs = linklibsStr.str(); @@ -1532,7 +1532,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, break; case cmTarget::EXECUTABLE: { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; if(!buildType.empty()) @@ -1541,7 +1541,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } + } const char* linkLanguage = target.GetLinkerLanguage(); if(!linkLanguage) { @@ -1566,7 +1566,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { - std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += " "; @@ -1579,7 +1579,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } else { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } @@ -1595,13 +1595,13 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } } } - break; + break; default: break; } @@ -1661,9 +1661,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, const char* linkLanguage = cli.GetLinkLanguage(); - std::string libPathFlag = + std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libPathTerminator = + std::string libPathTerminator = this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. @@ -1786,11 +1786,11 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, { std::vector<std::string> archs; target->GetAppleArchs(config, archs); - const char* sysroot = + const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* sysrootDefault = + const char* sysrootDefault = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); - const char* deploymentTarget = + const char* deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT"; bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str()); @@ -1876,7 +1876,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, if(cmSystemTools::FileIsFullPath(inName)) { std::string tLocation; - if(target->GetType() >= cmTarget::EXECUTABLE && + if(target->GetType() >= cmTarget::EXECUTABLE && target->GetType() <= cmTarget::MODULE_LIBRARY) { tLocation = target->GetLocation(config); @@ -2904,7 +2904,7 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, else { cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); - } + } return std::string(&arg[0]); } @@ -2976,9 +2976,9 @@ cmLocalGenerator::GetTargetDirectory(cmTarget const&) const //---------------------------------------------------------------------------- -void +void cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* , - std::vector<std::string>& + std::vector<std::string>& ) { cmSystemTools::Error("GetTargetObjectFileDirectories" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 573c430..7939d73 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3213,7 +3213,8 @@ void cmMakefile::ConfigureString(const std::string& input, } int cmMakefile::ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes) + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& newLine) { int res = 1; if ( !this->CanIWriteThisFile(outfile) ) @@ -3250,9 +3251,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } else { + std::string newLineCharacters; + std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc; + if (newLine.IsValid()) + { + newLineCharacters = newLine.GetCharacters(); + omode |= std::ios::binary; + } + else + { + newLineCharacters = "\n"; + } std::string tempOutputFile = soutfile; tempOutputFile += ".tmp"; - std::ofstream fout(tempOutputFile.c_str()); + std::ofstream fout(tempOutputFile.c_str(), omode); if(!fout) { cmSystemTools::Error( @@ -3277,7 +3289,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, { outLine = ""; this->ConfigureString(inLine, outLine, atOnly, escapeQuotes); - fout << outLine.c_str() << "\n"; + fout << outLine.c_str() << newLineCharacters; } // close the files before attempting to copy fin.close(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7c3e4ee..1236787 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -19,6 +19,7 @@ #include "cmPropertyMap.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmNewLineStyle.h" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -703,7 +704,9 @@ public: * Copy file but change lines acording to ConfigureString */ int ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes); + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& = cmNewLineStyle()); + #if defined(CMAKE_BUILD_WITH_CMAKE) /** diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx new file mode 100644 index 0000000..6f7b6a9 --- /dev/null +++ b/Source/cmNewLineStyle.cxx @@ -0,0 +1,95 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNewLineStyle.h" + + + +cmNewLineStyle::cmNewLineStyle() : NewLineStyle(Invalid) +{ +} + + +bool cmNewLineStyle::IsValid() const +{ + return NewLineStyle != Invalid; +} + + +bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args, + std::string& errorString) +{ + NewLineStyle = Invalid; + + for (size_t i = 0; i< args.size(); i++) + { + if (args[i] == "NEWLINE_STYLE") + { + size_t const styleIndex = i + 1; + if (args.size() > styleIndex) + { + const std::string eol = args[styleIndex]; + if (eol == "LF" || eol == "UNIX") + { + NewLineStyle = LF; + return true; + } + else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") + { + NewLineStyle = CRLF; + return true; + } + else + { + errorString = "NEWLINE_STYLE sets an unknown style, only LF, " + "CRLF, UNIX, DOS, and WIN32 are supported"; + return false; + } + } + else + { + errorString = "NEWLINE_STYLE must set a style: " + "LF, CRLF, UNIX, DOS, or WIN32"; + return false; + } + } + } + return true; +} + + +const std::string cmNewLineStyle::GetCharacters() const +{ + switch (NewLineStyle) + { + case Invalid: + return ""; + case LF: + return "\n"; + case CRLF: + return "\r\n"; + default: + ; + }; + return ""; +} + + +void cmNewLineStyle::SetStyle(Style style) +{ + NewLineStyle = style; +} + + +cmNewLineStyle::Style cmNewLineStyle::GetStyle() const +{ + return NewLineStyle; +} diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h new file mode 100644 index 0000000..cae1106 --- /dev/null +++ b/Source/cmNewLineStyle.h @@ -0,0 +1,46 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNewLineStyle_h +#define cmNewLineStyle_h + +#include "cmStandardIncludes.h" + +class cmNewLineStyle +{ +public: + + cmNewLineStyle(); + + enum Style + { + Invalid, + // LF = '\n', 0x0A, 10 + // CR = '\r', 0x0D, 13 + LF, // Unix + CRLF // Dos + }; + + void SetStyle(Style); + Style GetStyle() const; + + bool IsValid() const; + + bool ReadFromArguments(const std::vector<std::string>& args, + std::string &errorString); + + const std::string GetCharacters() const; + +private: + Style NewLineStyle; +}; + +#endif diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7a80f28..d07f84b 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -49,11 +49,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); const char* targetName = target->GetName(); - // don't do anything if there is no Qt4 or Qt5SrcTools (which contains moc): + // don't do anything if there is no Qt4 or Qt5Core (which contains moc): std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { - qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); } if (qtMajorVersion != "4" && qtMajorVersion != "5") { @@ -229,7 +229,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, if (this->QtMajorVersion == "") { this->QtMajorVersion = makefile->GetSafeDefinition( - "AM_Qt5SrcTools_VERSION_MAJOR"); + "AM_Qt5Core_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index e8decbb..ea299ca 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -161,6 +161,11 @@ extern int putenv (char *__string) __THROW; #define for if(false) {} else for #endif +// Provide std::ios_base on ancient GCC 2.9x +#if defined(__GNUC__) && __GNUC__ < 3 +namespace std { typedef ios ios_base; } +#endif + // check for the 720 compiler on the SGI // which has some strange properties that I don't think are worth // checking for in a general way in configure diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 48368de..87f8c5e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -17,6 +17,7 @@ #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" #include "cmDocumentCompileDefinitions.h" +#include "cmDocumentLocationUndefined.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" #include <cmsys/RegularExpression.hxx> @@ -584,15 +585,6 @@ void cmTarget::DefineProperties(cmake *cm) "value is the default. " "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables."); -#define CM_LOCATION_UNDEFINED_BEHAVIOR \ - "\n" \ - "Do not set properties that affect the location of the target after " \ - "reading this property. These include properties whose names match " \ - "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\" " \ - "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ - "Failure to follow this rule is not diagnosed and leaves the location " \ - "of the target undefined." - cm->DefineProperty ("LOCATION", cmProperty::TARGET, "Read-only location of a target on disk.", @@ -612,7 +604,7 @@ void cmTarget::DefineProperties(cmake *cm) "In CMake 2.8.4 and above add_custom_command recognizes generator " "expressions to refer to target locations anywhere in the command. " "Therefore this property is not needed for creating custom commands." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LOCATION_<CONFIG>", cmProperty::TARGET, @@ -626,7 +618,7 @@ void cmTarget::DefineProperties(cmake *cm) "arbitrary available configuration. " "Use the MAP_IMPORTED_CONFIG_<CONFIG> property to map imported " "configurations explicitly." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LINK_DEPENDS", cmProperty::TARGET, @@ -1055,6 +1047,29 @@ void cmTarget::DefineProperties(cmake *cm) "Can be set to change the visual studio source code control " "auxpath property."); cm->DefineProperty + ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET, + "Visual Studio project type(s).", + "Can be set to one or more UUIDs recognized by Visual Studio " + "to indicate the type of project. This value is copied " + "verbatim into the generated project file. Example for a " + "managed C++ unit testing project: \"" + "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};" + "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\". UUIDs are " + "semicolon-delimited."); + cm->DefineProperty + ("VS_GLOBAL_KEYWORD", cmProperty::TARGET, + "Visual Studio project keyword.", + "Sets the \"keyword\" attribute for a generated Visual Studio " + "project. Defaults to \"Win32Proj\". You may wish to override " + "this value with \"ManagedCProj\", for example, in a Visual " + "Studio managed C++ unit test project."); + cm->DefineProperty + ("VS_DOTNET_REFERENCES", cmProperty::TARGET, + "Visual Studio managed project .NET references", + "Adds one or more semicolon-delimited .NET references to a " + "generated Visual Studio project. For example, \"System;" + "System.Windows.Forms\"."); + cm->DefineProperty ("VS_GLOBAL_<variable>", cmProperty::TARGET, "Visual Studio project-specific global variable.", "Tell the Visual Studio generator to set the global variable " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index fcb668a..a219ae9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -178,6 +178,15 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<ProjectGUID>", 2); (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n"; + const char* vsProjectTypes = + this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES"); + if(vsProjectTypes) + { + this->WriteString("<ProjectTypes>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) << + "</ProjectTypes>\n"; + } + const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME"); const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); @@ -203,7 +212,19 @@ void cmVisualStudio10TargetGenerator::Generate() } } - this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); + const char* vsGlobalKeyword = + this->Target->GetProperty("VS_GLOBAL_KEYWORD"); + if(!vsGlobalKeyword) + { + this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); + } + else + { + this->WriteString("<Keyword>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) << + "</Keyword>\n"; + } + this->WriteString("<Platform>", 2); (*this->BuildFileStream) << this->Platform << "</Platform>\n"; const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); @@ -233,6 +254,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteCustomCommands(); this->WriteObjSources(); this->WriteCLSources(); + this->WriteDotNetReferences(); this->WriteProjectReferences(); this->WriteString( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\"" @@ -244,6 +266,39 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteGroups(); } +void cmVisualStudio10TargetGenerator::WriteDotNetReferences() +{ + const char* vsDotNetReferences + = this->Target->GetProperty("VS_DOTNET_REFERENCES"); + if(vsDotNetReferences) + { + std::string references(vsDotNetReferences); + std::string::size_type position = 0; + + this->WriteString("<ItemGroup>\n", 1); + while(references.length() > 0) + { + if((position = references.find(";")) == std::string::npos) + { + position = references.length() + 1; + } + + this->WriteString("<Reference Include=\"", 2); + (*this->BuildFileStream) << + cmVS10EscapeXML(references.substr(0, position)) << "\">\n"; + this->WriteString("<CopyLocalSatelliteAssemblies>true" + "</CopyLocalSatelliteAssemblies>\n", 3); + this->WriteString("<ReferenceOutputAssembly>true" + "</ReferenceOutputAssembly>\n", 3); + this->WriteString("</Reference>\n", 2); + + references.erase(0, position + 1); + } + + this->WriteString("</ItemGroup>\n", 1); + } +} + // ConfigurationType Application, Utility StaticLibrary DynamicLibrary void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index c3c27f4..6702509 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -47,6 +47,7 @@ private: void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); void WriteCLSources(); + void WriteDotNetReferences(); void WriteObjSources(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 082aaba..280d3f3 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 11) +SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 29) +SET(KWSYS_DATE_STAMP_DAY 06) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake new file mode 100644 index 0000000..3b09eb0 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out COPYONLY NEWLINE_STYLE DOS) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake new file mode 100644 index 0000000..133a67a --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake new file mode 100644 index 0000000..b7e619c --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake @@ -0,0 +1,17 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) + +function(test_eol style in out) + file(WRITE ${file_name} "${in}") + configure_file(${file_name} ${file_name}.out NEWLINE_STYLE ${style}) + file(READ ${file_name}.out new HEX) + if(NOT "${new}" STREQUAL "${out}") + message(FATAL_ERROR "No ${style} line endings") + endif() +endfunction() + +test_eol(DOS "a\n" "610d0a") +test_eol(WIN32 "b\n" "620d0a") +test_eol(CRLF "c\n" "630d0a") + +test_eol(UNIX "d\n" "640a") +test_eol(LF "e\n" "650a") diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake new file mode 100644 index 0000000..e8887c1 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE FOO) diff --git a/Tests/CMakeTests/ConfigureFileTest.cmake.in b/Tests/CMakeTests/ConfigureFileTest.cmake.in index c78a470..6cc61d9 100644 --- a/Tests/CMakeTests/ConfigureFileTest.cmake.in +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -6,6 +6,14 @@ set(Relative-RESULT 0) set(Relative-STDERR "Relative test file") set(BadArg-RESULT 1) set(BadArg-STDERR "called with incorrect number of arguments") +set(NewLineStyle-NoArg-RESULT 1) +set(NewLineStyle-NoArg-STDERR "NEWLINE_STYLE must set a style:") +set(NewLineStyle-WrongArg-RESULT 1) +set(NewLineStyle-WrongArg-STDERR "NEWLINE_STYLE sets an unknown style") +set(NewLineStyle-ValidArg-RESULT 0) +set(NewLineStyle-ValidArg-STDERR ) +set(NewLineStyle-COPYONLY-RESULT 1) +set(NewLineStyle-COPYONLY-STDERR "COPYONLY could not be used in combination") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(ConfigureFile @@ -13,4 +21,8 @@ check_cmake_test(ConfigureFile DirOutput Relative BadArg + NewLineStyle-NoArg + NewLineStyle-WrongArg + NewLineStyle-ValidArg + NewLineStyle-COPYONLY ) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 4a542d7..ac70129 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -343,13 +343,6 @@ endif() # Only do svn tests with svn >= version 1.2 # if(do_svn_tests) - execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} --version - OUTPUT_VARIABLE Subversion_VERSION_SVN - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" - "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") - message(STATUS "Subversion_VERSION_SVN='${Subversion_VERSION_SVN}'") - if(Subversion_VERSION_SVN VERSION_LESS 1.2) message(STATUS "No ExternalProject svn tests with svn client less than version 1.2") set(do_svn_tests 0) diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 564db9f..378b529 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -173,6 +173,12 @@ ELSE(STAGE2) TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) SET(install_target SimpleInstall) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -293,11 +299,6 @@ ELSE(STAGE2) ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - IF(NOT XCODE) - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) - ENDIF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 564db9f..378b529 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -173,6 +173,12 @@ ELSE(STAGE2) TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) SET(install_target SimpleInstall) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -293,11 +299,6 @@ ELSE(STAGE2) ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - IF(NOT XCODE) - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) - ENDIF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT @@ -215,6 +215,7 @@ CMAKE_CXX_SOURCES="\ cmMakefileLibraryTargetGenerator \ cmMakefileTargetGenerator \ cmMakefileUtilityTargetGenerator \ + cmNewLineStyle \ cmBootstrapCommands \ cmCommands \ cmTarget \ |