diff options
29 files changed, 294 insertions, 209 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 30b6da9..67c4cdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,10 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) # check for available C++ features include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake) + + if(NOT CMake_HAVE_CXX_UNIQUE_PTR) + message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g. std::unique_ptr).") + endif() endif() # set the internal encoding of CMake to UTF-8 diff --git a/Help/command/if.rst b/Help/command/if.rst index edd343d..f04f233 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -30,7 +30,7 @@ else and endif clause is optional. Long expressions can be used and there is a traditional order of precedence. Parenthetical expressions are evaluated first followed by unary tests such as ``EXISTS``, ``COMMAND``, and ``DEFINED``. Then any binary tests such as -``EQUAL``, ``LESS``, ``LESS_EQUAL, ``GREATER``, ``GREATER_EQUAL``, +``EQUAL``, ``LESS``, ``LESS_EQUAL``, ``GREATER``, ``GREATER_EQUAL``, ``STREQUAL``, ``STRLESS``, ``STRLESS_EQUAL``, ``STRGREATER``, ``STRGREATER_EQUAL``, ``VERSION_EQUAL``, ``VERSION_LESS``, ``VERSION_LESS_EQUAL``, ``VERSION_GREATER``, ``VERSION_GREATER_EQUAL``, diff --git a/Help/dev/source.rst b/Help/dev/source.rst index 16a9252..b40a884 100644 --- a/Help/dev/source.rst +++ b/Help/dev/source.rst @@ -23,20 +23,18 @@ format only a subset of files, such as those that are locally modified. C++ Subset Permitted ==================== -CMake supports compiling as C++98 in addition to C++11 and C++14. -In order to support building on older toolchains some constructs -need to be handled with care: +CMake requires compiling as C++11 or above. However, in order to support +building on older toolchains some constructs need to be handled with care: -* Use ``CM_AUTO_PTR`` instead of ``std::auto_ptr``. +* Do not use ``CM_AUTO_PTR`` or ``std::auto_ptr``. - The ``std::auto_ptr`` template is deprecated in C++11. We want to use it - so we can build on C++98 compilers but we do not want to turn off compiler - warnings about deprecated interfaces in general. Use the ``CM_AUTO_PTR`` - macro instead. + The ``std::auto_ptr`` template is deprecated in C++11. The ``CM_AUTO_PTR`` + macro remains leftover from C++98 support until its uses can be ported to + ``std::unique_ptr``. Do not add new uses of the macro. * Use ``CM_EQ_DELETE;`` instead of ``= delete;``. - Defining functions as *deleted* is not supported in C++98. Using + Older C++11 compilers do not support deleting functions. Using ``CM_EQ_DELETE`` will delete the functions if the compiler supports it and give them no implementation otherwise. Calling such a function will lead to compiler errors if the compiler supports *deleted* functions and linker diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index cc8c356..f1378c8 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -123,6 +123,7 @@ Properties on Targets /prop_tgt/AUTOGEN_BUILD_DIR /prop_tgt/AUTOGEN_TARGET_DEPENDS /prop_tgt/AUTOMOC_DEPEND_FILTERS + /prop_tgt/AUTOMOC_MACRO_NAMES /prop_tgt/AUTOMOC_MOC_OPTIONS /prop_tgt/AUTOMOC /prop_tgt/AUTOUIC diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst index e345cd2..55121df 100644 --- a/Help/manual/cmake-qt.7.rst +++ b/Help/manual/cmake-qt.7.rst @@ -95,6 +95,10 @@ following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS` variable may be populated to pre-set the options for all following targets. +The appearance of the strings ``Q_OBJECT`` or ``Q_GADGET`` in a source file +determines if it needs to be ``moc`` processed. To search for additional +strings, list them in :prop_tgt:`AUTOMOC_MACRO_NAMES`. + Additional ``moc`` dependency file names can be extracted from source code by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 363b90f..bef1171 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -270,6 +270,7 @@ Variables that Control the Build /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_AUTOMOC /variable/CMAKE_AUTOMOC_DEPEND_FILTERS + /variable/CMAKE_AUTOMOC_MACRO_NAMES /variable/CMAKE_AUTOMOC_MOC_OPTIONS /variable/CMAKE_AUTORCC /variable/CMAKE_AUTORCC_OPTIONS diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst index e70fe0d..61813be68 100644 --- a/Help/prop_tgt/AUTOMOC.rst +++ b/Help/prop_tgt/AUTOMOC.rst @@ -5,8 +5,8 @@ Should the target be processed with automoc (for Qt projects). AUTOMOC is a boolean specifying whether CMake will handle the Qt ``moc`` preprocessor automatically, i.e. without having to use the -:module:`QT4_WRAP_CPP() <FindQt4>` or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are -supported. +:module:`QT4_WRAP_CPP() <FindQt4>` or QT5_WRAP_CPP() macro. +Currently Qt4 and Qt5 are supported. When this property is set ``ON``, CMake will scan the header and source files at build time and invoke moc accordingly. @@ -37,7 +37,7 @@ source files at build time and invoke moc accordingly. which is compiled as part of the target. * The custom directories with checksum - based names help to avoid name collisions for moc files with the same + based names help to avoid name collisions for ``moc`` files with the same ``<basename>``. * See :prop_tgt:`AUTOGEN_BUILD_DIR`. @@ -56,11 +56,11 @@ source files at build time and invoke moc accordingly. This property is initialized by the value of the :variable:`CMAKE_AUTOMOC` variable if it is set when a target is created. -Additional command line options for moc can be set via the +Additional command line options for ``moc`` can be set via the :prop_tgt:`AUTOMOC_MOC_OPTIONS` property. By enabling the :variable:`CMAKE_AUTOMOC_RELAXED_MODE` variable the -rules for searching the files which will be processed by moc can be relaxed. +rules for searching the files which will be processed by ``moc`` can be relaxed. See the documentation for this variable for more details. The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the @@ -69,6 +69,10 @@ automoc targets together in an IDE, e.g. in MSVS. The global property :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used to group files generated by :prop_tgt:`AUTOMOC` together in an IDE, e.g. in MSVS. +The appearance of the strings ``Q_OBJECT`` or ``Q_GADGET`` in a source file +determines if it needs to be ``moc`` processed. To search for additional +strings, list them in :prop_tgt:`AUTOMOC_MACRO_NAMES`. + Additional ``moc`` dependency file names can be extracted from source code by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`. diff --git a/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst b/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst new file mode 100644 index 0000000..0639bc8 --- /dev/null +++ b/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst @@ -0,0 +1,28 @@ +AUTOMOC_MACRO_NAMES +------------------- + +Additional macro names used by :prop_tgt:`AUTOMOC` +to determine if a C++ file needs to be processed by ``moc``. + +This property is only used if the :prop_tgt:`AUTOMOC` property is ``ON`` +for this target. + +CMake searches for the strings ``Q_OBJECT`` and ``Q_GADGET`` to +determine if a file needs to be processed by ``moc``. +:prop_tgt:`AUTOMOC_MACRO_NAMES` allows to add additional strings to the +search list. This is useful for cases where the ``Q_OBJECT`` or ``Q_GADGET`` +macro is hidden inside another macro. + +By default :prop_tgt:`AUTOMOC_MACRO_NAMES` is initialized from +:variable:`CMAKE_AUTOMOC_MACRO_NAMES`, which is empty by default. + +See the :manual:`cmake-qt(7)` manual for more information on using CMake +with Qt. + +Example +------- +In this case the the ``Q_OBJECT`` macro is hidden inside an other macro +called ``CUSTOM_MACRO``. To let CMake know that source files, that contain +``CUSTOM_MACRO``, need to be ``moc`` processed, we call:: + + set_property(TARGET tgt PROPERTY AUTOMOC_MACRO_NAMES "CUSTOM_MACRO") diff --git a/Help/release/dev/autogen-macro-names.rst b/Help/release/dev/autogen-macro-names.rst new file mode 100644 index 0000000..736dd3a --- /dev/null +++ b/Help/release/dev/autogen-macro-names.rst @@ -0,0 +1,12 @@ +autogen-macro-names +------------------- + +* When using :prop_tgt:`AUTOMOC`, CMake searches for the strings ``Q_OBJECT`` + and ``Q_OBJECT`` in a source file to determine if it needs to be ``moc`` + processed. The new variable :variable:`CMAKE_AUTOMOC_MACRO_NAMES` allows to + register additional strings (macro names) so search for. + +* When using :prop_tgt:`AUTOMOC`, CMake searches for the strings ``Q_OBJECT`` + and ``Q_OBJECT`` in a source file to determine if it needs to be ``moc`` + processed. The new target property :prop_tgt:`AUTOMOC_MACRO_NAMES` allows to + register additional strings (macro names) so search for. diff --git a/Help/release/dev/require-c++11.rst b/Help/release/dev/require-c++11.rst new file mode 100644 index 0000000..7b849e7 --- /dev/null +++ b/Help/release/dev/require-c++11.rst @@ -0,0 +1,5 @@ +require-c++11 +------------- + +* Support for building CMake itself with C++98 compilers was dropped. + CMake is now implemented using C++11. diff --git a/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst b/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst new file mode 100644 index 0000000..7ed3445 --- /dev/null +++ b/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst @@ -0,0 +1,19 @@ +CMAKE_AUTOMOC_MACRO_NAMES +---------------------------- + +Additional macro names used by :variable:`CMAKE_AUTOMOC` +to determine if a C++ file needs to be processed by ``moc``. + +This variable is used to initialize the :prop_tgt:`AUTOMOC_MACRO_NAMES` +property on all the targets. See that target property for additional +information. + +By default it is empty. + +Example +------- +Let CMake know that source files that contain ``CUSTOM_MACRO`` must be ``moc`` +processed as well:: + + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTOMOC_MACRO_NAMES "CUSTOM_MACRO") diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index 4e85474..e1a9c39 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -18,6 +18,7 @@ set(AM_MOC_DEFINITIONS @_moc_compile_defs@) set(AM_MOC_INCLUDES @_moc_incs@) set(AM_MOC_OPTIONS @_moc_options@) set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@) +set(AM_MOC_MACRO_NAMES @_moc_macro_names@) set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@) set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@) # UIC settings diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 28cc1e9..ec5a099 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -74,7 +74,7 @@ set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list @CUDA_NVCC_FLAGS_CONFIG@ set(nvcc_flags @nvcc_flags@) # list set(CUDA_NVCC_INCLUDE_DIRS "@CUDA_NVCC_INCLUDE_DIRS@") # list (needs to be in quotes to handle spaces properly). -set(CUDA_NVCC_COMPILE_DEFINITIONS "@CUDA_NVCC_COMPILE_DEFINITIONS@") # list (needs to be in quotes to handle spaces properly). +set(CUDA_NVCC_COMPILE_DEFINITIONS [==[@CUDA_NVCC_COMPILE_DEFINITIONS@]==]) # list (needs to be in lua quotes see #16510 ). set(format_flag "@format_flag@") # string set(cuda_language_flag @cuda_language_flag@) # list @@ -51,7 +51,7 @@ Building CMake from Scratch UNIX/Mac OSX/MinGW/MSYS/Cygwin ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -You need to have a compiler and a make installed. +You need to have a C++ compiler (supporting C++11) and a ``make`` installed. Run the ``bootstrap`` script you find in the source directory of CMake. You can use the ``--help`` option to see the supported options. You may use the ``--prefix=<install_prefix>`` option to specify a custom diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8417db3..d0146db 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 9) -set(CMake_VERSION_PATCH 20170819) +set(CMake_VERSION_PATCH 20170821) #set(CMake_VERSION_RC 1) diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index c5ac1f1..6023c83 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -17,10 +17,6 @@ set( CURSES_SRCS CursesDialog/ccmake ) -if( NOT CMAKE_USE_SYSTEM_FORM ) - include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form - ${CMake_BINARY_DIR}/Source/CursesDialog/form) -endif() include_directories(${CURSES_INCLUDE_PATH}) diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index 0677043..b468f5b 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -3,12 +3,9 @@ project(CMAKE_FORM) -include_regular_expression("^.*$") -include_directories(${CURSES_INCLUDE_PATH} "${CMAKE_CURRENT_BINARY_DIR}") - configure_file(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h") -set( FORM_SRCS +add_library(cmForm fld_arg.c fld_attr.c fld_current.c @@ -49,10 +46,16 @@ set( FORM_SRCS fty_num.c fty_regex.c ) - -include_directories(${CMAKE_FORM_SOURCE_DIR}) -add_library(cmForm ${FORM_SRCS} ) + +target_include_directories(cmForm + PUBLIC + ${CURSES_INCLUDE_PATH} + ${CMAKE_FORM_BINARY_DIR} + ${CMAKE_FORM_SOURCE_DIR} + ) + target_link_libraries(cmForm ${CURSES_LIBRARY}) + if(CURSES_EXTRA_LIBRARY) target_link_libraries(cmForm ${CURSES_EXTRA_LIBRARY}) endif() diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 61239a9..8a7d9bd 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -68,7 +68,12 @@ #include "cmSiteNameCommand.h" #include "cmStringCommand.h" #include "cmSubdirCommand.h" +#include "cmTargetCompileDefinitionsCommand.h" +#include "cmTargetCompileFeaturesCommand.h" +#include "cmTargetCompileOptionsCommand.h" +#include "cmTargetIncludeDirectoriesCommand.h" #include "cmTargetLinkLibrariesCommand.h" +#include "cmTargetSourcesCommand.h" #include "cmTryCompileCommand.h" #include "cmTryRunCommand.h" #include "cmUnsetCommand.h" @@ -94,11 +99,6 @@ #include "cmRemoveDefinitionsCommand.h" #include "cmSourceGroupCommand.h" #include "cmSubdirDependsCommand.h" -#include "cmTargetCompileDefinitionsCommand.h" -#include "cmTargetCompileFeaturesCommand.h" -#include "cmTargetCompileOptionsCommand.h" -#include "cmTargetIncludeDirectoriesCommand.h" -#include "cmTargetSourcesCommand.h" #include "cmUseMangledMesaCommand.h" #include "cmUtilitySourceCommand.h" #include "cmVariableRequiresCommand.h" @@ -238,8 +238,17 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("set_tests_properties", new cmSetTestsPropertiesCommand); state->AddBuiltinCommand("subdirs", new cmSubdirCommand); + state->AddBuiltinCommand("target_compile_definitions", + new cmTargetCompileDefinitionsCommand); + state->AddBuiltinCommand("target_compile_features", + new cmTargetCompileFeaturesCommand); + state->AddBuiltinCommand("target_compile_options", + new cmTargetCompileOptionsCommand); + state->AddBuiltinCommand("target_include_directories", + new cmTargetIncludeDirectoriesCommand); state->AddBuiltinCommand("target_link_libraries", new cmTargetLinkLibrariesCommand); + state->AddBuiltinCommand("target_sources", new cmTargetSourcesCommand); state->AddBuiltinCommand("try_compile", new cmTryCompileCommand); state->AddBuiltinCommand("try_run", new cmTryRunCommand); @@ -260,15 +269,6 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("remove_definitions", new cmRemoveDefinitionsCommand); state->AddBuiltinCommand("source_group", new cmSourceGroupCommand); - state->AddBuiltinCommand("target_compile_definitions", - new cmTargetCompileDefinitionsCommand); - state->AddBuiltinCommand("target_compile_features", - new cmTargetCompileFeaturesCommand); - state->AddBuiltinCommand("target_compile_options", - new cmTargetCompileOptionsCommand); - state->AddBuiltinCommand("target_include_directories", - new cmTargetIncludeDirectoriesCommand); - state->AddBuiltinCommand("target_sources", new cmTargetSourcesCommand); state->AddDisallowedCommand( "export_library_dependencies", new cmExportLibraryDependenciesCommand, diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 7974977..6ae101f 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -380,6 +380,8 @@ static void MocSetupAutoTarget( AddDefinitionEscaped(makefile, "_moc_relaxed_mode", makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE" : "FALSE"); + AddDefinitionEscaped(makefile, "_moc_macro_names", + GetSafeProperty(target, "AUTOMOC_MACRO_NAMES")); AddDefinitionEscaped(makefile, "_moc_depend_filters", GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1fe07ce..65ea048 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -280,12 +280,10 @@ cmQtAutoGenerators::cmQtAutoGenerators() } // Moc macro filters - this->MocMacroFilters[0].first = "Q_OBJECT"; - this->MocMacroFilters[0].second.compile( - "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - this->MocMacroFilters[1].first = "Q_GADGET"; - this->MocMacroFilters[1].second.compile( - "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]"); + this->MocMacroFilters.push_back( + MocMacroFilter("Q_OBJECT", "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]")); + this->MocMacroFilters.push_back( + MocMacroFilter("Q_GADGET", "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]")); // Precompile regular expressions this->MocRegExpInclude.compile( @@ -402,7 +400,6 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable); InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable); - InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); // Check Qt version if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) { this->LogError("AutoGen: Error: Unsupported Qt version: " + @@ -427,6 +424,16 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_MOC_OPTIONS", this->MocOptions); InfoGet(makefile, "AM_MOC_RELAXED_MODE", this->MocRelaxedMode); { + std::vector<std::string> MocMacroNames; + InfoGet(makefile, "AM_MOC_MACRO_NAMES", MocMacroNames); + for (std::vector<std::string>::const_iterator dit = + MocMacroNames.begin(); + dit != MocMacroNames.end(); ++dit) { + this->MocMacroFilters.push_back( + MocMacroFilter(*dit, "[^a-zA-Z0-9_]" + *dit + "[^a-zA-Z0-9_]")); + } + } + { std::vector<std::string> mocDependFilters; InfoGet(makefile, "AM_MOC_DEPEND_FILTERS", mocDependFilters); // Insert Q_PLUGIN_METADATA dependency filter @@ -452,6 +459,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( return false; } } + InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); } // - Uic @@ -800,8 +808,10 @@ bool cmQtAutoGenerators::RunAutogen() bool cmQtAutoGenerators::MocRequired(const std::string& contentText, std::string* macroName) { - for (unsigned int ii = 0; ii != cmArraySize(this->MocMacroFilters); ++ii) { - MocMacroFilter& filter = this->MocMacroFilters[ii]; + for (std::vector<MocMacroFilter>::iterator fit = + this->MocMacroFilters.begin(); + fit != this->MocMacroFilters.end(); ++fit) { + MocMacroFilter& filter = *fit; // Run a simple find string operation before the expensive // regular expression check if (contentText.find(filter.first) != std::string::npos) { diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 337aa17..ce5db4a 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -201,7 +201,7 @@ private: std::vector<std::string> MocOptions; std::vector<std::string> MocPredefsCmd; std::vector<MocDependFilter> MocDependFilters; - MocMacroFilter MocMacroFilters[2]; + std::vector<MocMacroFilter> MocMacroFilters; cmsys::RegularExpression MocRegExpInclude; // -- Uic bool UicSettingsChanged; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c1b6f97..501aebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -248,6 +248,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("AUTOUIC", CM_NULLPTR); this->SetPropertyDefault("AUTORCC", CM_NULLPTR); this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR); + this->SetPropertyDefault("AUTOMOC_MACRO_NAMES", CM_NULLPTR); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", CM_NULLPTR); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5570593..e1a0c83 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -85,7 +85,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->LocalGenerator = (cmLocalVisualStudio7Generator*)this->GeneratorTarget->GetLocalGenerator(); this->Name = this->GeneratorTarget->GetName(); - this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); + this->GUID = this->GlobalGenerator->GetGUID(this->Name); this->Platform = gg->GetPlatformName(); this->NsightTegra = gg->IsNsightTegra(); for (int i = 0; i < 4; ++i) { @@ -411,7 +411,7 @@ void cmVisualStudio10TargetGenerator::Generate() globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") { continue; } - const char* value = this->GeneratorTarget->GetProperty(keyIt->c_str()); + const char* value = this->GeneratorTarget->GetProperty(*keyIt); if (!value) continue; this->WriteString("<", 2); @@ -744,7 +744,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - this->WritePlatformConfigTag("LogicalName", i->c_str(), 3); + this->WritePlatformConfigTag("LogicalName", *i, 3); if (this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE") || // Handle variant of VS_GLOBAL_<variable> for RootNamespace. this->GeneratorTarget->GetProperty("VS_GLOBAL_RootNamespace")) { @@ -806,7 +806,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); ++p) { static const std::string propNamePrefix = "VS_CSHARP_"; - if (p->first.find(propNamePrefix.c_str()) == 0) { + if (p->first.find(propNamePrefix) == 0) { std::string tagName = p->first.substr(propNamePrefix.length()); if (!tagName.empty()) { std::string value = props.GetPropertyValue(p->first); @@ -962,7 +962,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - this->WritePlatformConfigTag("PropertyGroup", i->c_str(), 1, + this->WritePlatformConfigTag("PropertyGroup", *i, 1, " Label=\"Configuration\"", "\n"); if (this->ProjectType != csproj) { @@ -1086,8 +1086,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( this->WriteString("<DefineDebug>true</DefineDebug>\n", 2); } - std::string outDir = - this->GeneratorTarget->GetDirectory(config.c_str()) + "/"; + std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/"; this->ConvertToWindowsSlash(outDir); this->WriteString("<OutputPath>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(outDir) << "</OutputPath>\n"; @@ -1258,8 +1257,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin(); d != ccg.GetDepends().end(); ++d) { std::string dep; - if (this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), - dep)) { + if (this->LocalGenerator->GetRealDependency(*d, *i, dep)) { this->ConvertToWindowsSlash(dep); inputs << ";" << cmVS10EscapeXML(dep); } @@ -1471,7 +1469,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guidName = "SG_Filter_"; guidName += name; this->WriteString("<UniqueIdentifier>", 3); - std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str()); + std::string guid = this->GlobalGenerator->GetGUID(guidName); (*this->BuildFileStream) << "{" << guid << "}" << "</UniqueIdentifier>\n"; this->WriteString("</Filter>\n", 2); @@ -1482,7 +1480,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("<Filter Include=\"Resource Files\">\n", 2); std::string guidName = "SG_Filter_Resource Files"; this->WriteString("<UniqueIdentifier>", 3); - std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str()); + std::string guid = this->GlobalGenerator->GetGUID(guidName); (*this->BuildFileStream) << "{" << guid << "}" << "</UniqueIdentifier>\n"; this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3); @@ -2050,7 +2048,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string configDefines = defines; std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += configUpper; - if (const char* ccdefs = sf.GetProperty(defPropName.c_str())) { + if (const char* ccdefs = sf.GetProperty(defPropName)) { if (!configDefines.empty()) { configDefines += ";"; } @@ -2177,7 +2175,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() this->Configurations.begin(); config != this->Configurations.end(); ++config) { if (ttype >= cmStateEnums::UTILITY) { - this->WritePlatformConfigTag("IntDir", config->c_str(), 2); + this->WritePlatformConfigTag("IntDir", *config, 2); *this->BuildFileStream << "$(Platform)\\$(Configuration)\\$(ProjectName)\\" << "</IntDir>\n"; @@ -2194,30 +2192,30 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() targetNameFull = this->GeneratorTarget->GetName(); targetNameFull += ".lib"; } else { - outDir = this->GeneratorTarget->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); + outDir = this->GeneratorTarget->GetDirectory(*config) + "/"; + targetNameFull = this->GeneratorTarget->GetFullName(*config); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); - this->WritePlatformConfigTag("OutDir", config->c_str(), 2); + this->WritePlatformConfigTag("OutDir", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n"; - this->WritePlatformConfigTag("IntDir", config->c_str(), 2); + this->WritePlatformConfigTag("IntDir", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(intermediateDir) << "</IntDir>\n"; if (const char* workingDir = this->GeneratorTarget->GetProperty( "VS_DEBUGGER_WORKING_DIRECTORY")) { - this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", - config->c_str(), 2); + this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", *config, + 2); *this->BuildFileStream << cmVS10EscapeXML(workingDir) << "</LocalDebuggerWorkingDirectory>\n"; } std::string name = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); - this->WritePlatformConfigTag("TargetName", config->c_str(), 2); + this->WritePlatformConfigTag("TargetName", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(name) << "</TargetName>\n"; std::string ext = @@ -2227,7 +2225,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() // A single "." appears to be treated as an empty extension. ext = "."; } - this->WritePlatformConfigTag("TargetExt", config->c_str(), 2); + this->WritePlatformConfigTag("TargetExt", *config, 2); *this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n"; this->OutputLinkIncremental(*config); @@ -2254,13 +2252,13 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( Options& linkOptions = *(this->LinkOptions[configName]); const char* incremental = linkOptions.GetFlag("LinkIncremental"); - this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 2); + this->WritePlatformConfigTag("LinkIncremental", configName, 2); *this->BuildFileStream << (incremental ? incremental : "true") << "</LinkIncremental>\n"; linkOptions.RemoveFlag("LinkIncremental"); const char* manifest = linkOptions.GetFlag("GenerateManifest"); - this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 2); + this->WritePlatformConfigTag("GenerateManifest", configName, 2); *this->BuildFileStream << (manifest ? manifest : "true") << "</GenerateManifest>\n"; linkOptions.RemoveFlag("GenerateManifest"); @@ -2271,7 +2269,7 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( for (const char** f = flags; *f; ++f) { const char* flag = *f; if (const char* value = linkOptions.GetFlag(flag)) { - this->WritePlatformConfigTag(flag, configName.c_str(), 2); + this->WritePlatformConfigTag(flag, configName, 2); *this->BuildFileStream << value << "</" << flag << ">\n"; linkOptions.RemoveFlag(flag); } @@ -2315,7 +2313,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName); if (linkLanguage.empty()) { cmSystemTools::Error( "CMake can not determine linker language for target: ", @@ -2346,13 +2344,13 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( baseFlagVar += "_FLAGS"; flags = this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - baseFlagVar.c_str()); + baseFlagVar); std::string flagVar = baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName); flags += " "; flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - flagVar.c_str()); + flagVar); this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, langForClCompile, configName); } @@ -2383,12 +2381,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::vector<std::string> targetDefines; switch (this->ProjectType) { case vcxproj: - this->GeneratorTarget->GetCompileDefinitions(targetDefines, - configName.c_str(), "CXX"); + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, + "CXX"); break; case csproj: - this->GeneratorTarget->GetCompileDefinitions( - targetDefines, configName.c_str(), "CSharp"); + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, + "CSharp"); break; } clOptions.AddDefines(targetDefines); @@ -2494,8 +2492,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = - this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); + std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName); if (!pdb.empty()) { this->ConvertToWindowsSlash(pdb); this->WriteString("<ProgramDataBaseFileName>", 3); @@ -2637,8 +2634,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.FixCudaCodeGeneration(); std::vector<std::string> targetDefines; - this->GeneratorTarget->GetCompileDefinitions(targetDefines, - configName.c_str(), "CUDA"); + this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName, + "CUDA"); cudaOptions.AddDefines(targetDefines); // Add a definition for the configuration name. @@ -3108,11 +3105,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkFlagVarBase += "_LINKER_FLAGS"; flags += " "; flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - linkFlagVarBase.c_str()); + linkFlagVarBase); std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG; flags += " "; flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition( - linkFlagVar.c_str()); + linkFlagVar); const char* targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { @@ -3122,13 +3119,13 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string flagsProp = "LINK_FLAGS_"; flagsProp += CONFIG; if (const char* flagsConfig = - this->GeneratorTarget->GetProperty(flagsProp.c_str())) { + this->GeneratorTarget->GetProperty(flagsProp)) { flags += " "; flags += flagsConfig; } cmComputeLinkInformation* pcli = - this->GeneratorTarget->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config); if (!pcli) { cmSystemTools::Error( "CMake can not compute cmComputeLinkInformation for target: ", @@ -3156,8 +3153,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string standardLibsVar = "CMAKE_"; standardLibsVar += linkLanguage; standardLibsVar += "_STANDARD_LIBRARIES"; - std::string const libs = - this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); + std::string const libs = this->Makefile->GetSafeDefinition(standardLibsVar); cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec); linkOptions.AddFlag("AdditionalDependencies", libVec); @@ -3185,13 +3181,12 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string targetNameImport; std::string targetNamePDB; if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { - this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, - targetNameImport, targetNamePDB, - config.c_str()); + this->GeneratorTarget->GetExecutableNames( + targetName, targetNameFull, targetNameImport, targetNamePDB, config); } else { this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, - targetNamePDB, config.c_str()); + targetNamePDB, config); } if (this->MSTools) { @@ -3232,11 +3227,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AddFlag("GenerateDebugInformation", "false"); - std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); + std::string pdb = this->GeneratorTarget->GetPDBDirectory(config); pdb += "/"; pdb += targetNamePDB; std::string imLib = this->GeneratorTarget->GetDirectory( - config.c_str(), cmStateEnums::ImportLibraryArtifact); + config, cmStateEnums::ImportLibraryArtifact); imLib += "/"; imLib += targetNameImport; @@ -3311,7 +3306,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( std::string const& config) { cmComputeLinkInformation* pcli = - this->GeneratorTarget->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config); if (!pcli) { cmSystemTools::Error( "CMake can not compute cmComputeLinkInformation for target: ", @@ -3326,8 +3321,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( this->LocalGenerator->GetCurrentBinaryDirectory(); for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { if (l->IsPath && cmVS10IsTargetsFile(l->Value)) { - std::string path = this->LocalGenerator->ConvertToRelativePath( - currentBinDir, l->Value.c_str()); + std::string path = + this->LocalGenerator->ConvertToRelativePath(currentBinDir, l->Value); this->ConvertToWindowsSlash(path); this->AddTargetsFileAndConfigPair(path, config); } @@ -3372,8 +3367,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries( this->LocalGenerator->GetCurrentBinaryDirectory(); for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { if (l->IsPath) { - std::string path = this->LocalGenerator->ConvertToRelativePath( - currentBinDir, l->Value.c_str()); + std::string path = + this->LocalGenerator->ConvertToRelativePath(currentBinDir, l->Value); this->ConvertToWindowsSlash(path); if (cmVS10IsTargetsFile(l->Value)) { vsTargetVec.push_back(path); @@ -3463,12 +3458,12 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() i != this->Configurations.end(); ++i) { std::vector<std::string> includes; this->LocalGenerator->GetIncludeDirectories( - includes, this->GeneratorTarget, "C", i->c_str()); + includes, this->GeneratorTarget, "C", *i); for (std::vector<std::string>::iterator ii = includes.begin(); ii != includes.end(); ++ii) { this->ConvertToWindowsSlash(*ii); } - this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1); + this->WritePlatformConfigTag("ItemDefinitionGroup", *i, 1); *this->BuildFileStream << "\n"; // output cl compile flags <ClCompile></ClCompile> if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { @@ -3606,8 +3601,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; this->WriteString("<Project>", 3); - (*this->BuildFileStream) - << "{" << this->GlobalGenerator->GetGUID(name.c_str()) << "}"; + (*this->BuildFileStream) << "{" << this->GlobalGenerator->GetGUID(name) + << "}"; (*this->BuildFileStream) << "</Project>\n"; this->WriteString("<Name>", 3); (*this->BuildFileStream) << name << "</Name>\n"; @@ -3880,7 +3875,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() this->WriteString("<XapOutputs>true</XapOutputs>\n", 2); this->WriteString("<XapFilename>", 2); (*this->BuildFileStream) - << cmVS10EscapeXML(this->Name.c_str()) + << cmVS10EscapeXML(this->Name) << "_$(Configuration)_$(Platform).xap</XapFilename>\n"; } } @@ -4407,7 +4402,7 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties( for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); ++p) { static const std::string propNamePrefix = "VS_CSHARP_"; - if (p->first.find(propNamePrefix.c_str()) == 0) { + if (p->first.find(propNamePrefix) == 0) { std::string tagName = p->first.substr(propNamePrefix.length()); if (!tagName.empty()) { const std::string val = props.GetPropertyValue(p->first); diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 198bf63..be864c3 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -66,6 +66,15 @@ set_property(TARGET mocOnly PROPERTY AUTOMOC ON) target_link_libraries(mocOnly ${QT_LIBRARIES}) # -- Test +# MOC AUTOMOC_MACRO_NAMES +if (NOT QT_TEST_VERSION STREQUAL 4) + add_executable(mocMacroName mocMacroName/main.cpp mocMacroName/MacroName.cpp) + set_property(TARGET mocMacroName PROPERTY AUTOMOC ON) + set_property(TARGET mocMacroName PROPERTY AUTOMOC_MACRO_NAMES "QO_ALIAS") + target_link_libraries(mocMacroName ${QT_LIBRARIES}) +endif() + +# -- Test # UIC only if(ALLOW_WRAP_CPP) qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h) diff --git a/Tests/QtAutogen/mocMacroName/MacroAlias.hpp b/Tests/QtAutogen/mocMacroName/MacroAlias.hpp new file mode 100644 index 0000000..cf06f2a --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/MacroAlias.hpp @@ -0,0 +1,7 @@ +#ifndef MACROALIAS_HPP +#define MACROALIAS_HPP + +#include <QObject> +#define QO_ALIAS Q_OBJECT + +#endif diff --git a/Tests/QtAutogen/mocMacroName/MacroName.cpp b/Tests/QtAutogen/mocMacroName/MacroName.cpp new file mode 100644 index 0000000..78d04a8 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/MacroName.cpp @@ -0,0 +1,9 @@ +#include "MacroName.hpp" + +MacroName::MacroName() +{ +} + +void MacroName::aSlot() +{ +} diff --git a/Tests/QtAutogen/mocMacroName/MacroName.hpp b/Tests/QtAutogen/mocMacroName/MacroName.hpp new file mode 100644 index 0000000..b6c7306 --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/MacroName.hpp @@ -0,0 +1,20 @@ +#ifndef MACRONAME_HPP +#define MACRONAME_HPP + +#include "MacroAlias.hpp" + +// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES) +class MacroName : public QObject +{ + QO_ALIAS +public: + MacroName(); + +signals: + void aSignal(); + +public slots: + void aSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/mocMacroName/main.cpp b/Tests/QtAutogen/mocMacroName/main.cpp new file mode 100644 index 0000000..67ee81f --- /dev/null +++ b/Tests/QtAutogen/mocMacroName/main.cpp @@ -0,0 +1,7 @@ +#include "MacroName.hpp" + +int main(int argv, char** args) +{ + MacroName macroName; + return 0; +} @@ -80,7 +80,7 @@ cmake_sphinx_build="" cmake_sphinx_flags="" # Determine whether this is a Cygwin environment. -if echo "${cmake_system}" | grep -q CYGWIN; then +if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then cmake_system_cygwin=true cmake_doc_dir_keyword="CYGWIN" cmake_man_dir_keyword="CYGWIN" @@ -89,21 +89,21 @@ else fi # Determine whether this is a MinGW environment. -if echo "${cmake_system}" | grep -q 'MINGW\|MSYS'; then +if echo "${cmake_system}" | grep 'MINGW\|MSYS' >/dev/null 2>&1; then cmake_system_mingw=true else cmake_system_mingw=false fi # Determine whether this is OS X -if echo "${cmake_system}" | grep -q Darwin; then +if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then cmake_system_darwin=true else cmake_system_darwin=false fi # Determine whether this is BeOS -if echo "${cmake_system}" | grep -q BeOS; then +if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then cmake_system_beos=true cmake_doc_dir_keyword="HAIKU" cmake_man_dir_keyword="HAIKU" @@ -112,7 +112,7 @@ else fi # Determine whether this is Haiku -if echo "${cmake_system}" | grep -q Haiku; then +if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then cmake_system_haiku=true cmake_doc_dir_keyword="HAIKU" cmake_man_dir_keyword="HAIKU" @@ -121,14 +121,14 @@ else fi # Determine whether this is OpenVMS -if echo "${cmake_system}" | grep -q OpenVMS; then +if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then cmake_system_openvms=true else cmake_system_openvms=false fi # Determine whether this is HP-UX -if echo "${cmake_system}" | grep -q HP-UX; then +if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then die 'CMake no longer compiles on HP-UX. See https://gitlab.kitware.com/cmake/cmake/issues/17137 @@ -140,7 +140,7 @@ else fi # Determine whether this is Linux -if echo "${cmake_system}" | grep -q Linux; then +if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then cmake_system_linux=true else cmake_system_linux=false @@ -151,11 +151,11 @@ else # may falsely detect parisc on HP-UX m68k cmake_machine_parisc=false if ${cmake_system_linux}; then - if uname -m | grep -q parisc; then + if uname -m | grep parisc >/dev/null 2>&1; then cmake_machine_parisc=true fi elif ${cmake_system_hpux}; then - if uname -m | grep -q ia64; then : ; else + if uname -m | grep ia64 >/dev/null 2>&1; then : ; else cmake_machine_parisc=true fi fi @@ -403,8 +403,14 @@ CMAKE_CXX_SOURCES="\ cmSubdirCommand \ cmSystemTools \ cmTarget \ + cmTargetCompileDefinitionsCommand \ + cmTargetCompileFeaturesCommand \ + cmTargetCompileOptionsCommand \ + cmTargetIncludeDirectoriesCommand \ cmTargetLinkLibrariesCommand \ + cmTargetPropCommandBase \ cmTargetPropertyComputer \ + cmTargetSourcesCommand \ cmTest \ cmTestGenerator \ cmTimestamp \ @@ -855,16 +861,6 @@ if ${cmake_system_haiku}; then cmake_ld_flags="${LDFLAGS} -lroot -lbe" fi -# Workaround for short jump tables on PA-RISC -if ${cmake_machine_parisc}; then - if ${cmake_c_compiler_is_gnu}; then - cmake_c_flags="${CFLAGS} -mlong-calls" - fi - if ${cmake_cxx_compiler_is_gnu}; then - cmake_cxx_flags="${CXXFLAGS} -mlong-calls" - fi -fi - #----------------------------------------------------------------------------- # Detect known toolchains on some platforms. cmake_toolchains='' @@ -945,35 +941,26 @@ echo ' # error "The CMAKE_C_COMPILER is set to a C++ compiler" #endif -#include<stdio.h> +#include <stdio.h> -#if defined(__CLASSIC_C__) -int main(argc, argv) - int argc; - char* argv[]; -#else int main(int argc, char* argv[]) -#endif { printf("%d%c", (argv != 0), (char)0x0a); - return argc-1; + return argc - 1; } ' > "${TMPFILE}.c" -for a in ${cmake_c_compilers}; do - if [ -z "${cmake_c_compiler}" ] && \ - cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then - cmake_c_compiler="${a}" - fi -done for std in 11 99 90; do try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`" - for flag in $try_flags; do - echo "Checking whether ${cmake_c_compiler} supports ${flag}" >> cmake_bootstrap.log 2>&1 - if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags} ${flag}" \ - "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then - cmake_c_flags="${cmake_c_flags} ${flag}" - break 2 - fi + for compiler in ${cmake_c_compilers}; do + for flag in '' $try_flags; do + echo "Checking whether '${compiler} ${cmake_c_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1 + if cmake_try_run "${compiler}" "${cmake_c_flags} ${flag}" \ + "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then + cmake_c_compiler="${compiler}" + cmake_c_flags="${cmake_c_flags} ${flag}" + break 3 + fi + done done done rm -f "${TMPFILE}.c" @@ -1004,58 +991,45 @@ fi # Check if C++ compiler works TMPFILE=`cmake_tmp_file` echo ' -#if defined(TEST1) -# include <iostream> -#else -# include <iostream.h> -#endif +#include <iostream> +#include <memory> #if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140 #error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics." #endif -class NeedCXX +class Class { public: - NeedCXX() { this->Foo = 1; } - int GetFoo() { return this->Foo; } + int Get() const { return this->Member; } private: - int Foo; + int Member = 1; }; int main() { - NeedCXX c; -#ifdef TEST3 - cout << c.GetFoo() << endl; -#else - std::cout << c.GetFoo() << std::endl; -#endif + auto const c = std::unique_ptr<Class>(new Class); + std::cout << c->Get() << std::endl; return 0; } ' > "${TMPFILE}.cxx" -for a in ${cmake_cxx_compilers}; do - for b in 1 2 3; do - if [ -z "${cmake_cxx_compiler}" ] && \ - cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then - cmake_cxx_compiler="${a}" - fi - done -done -for std in 14 11 98; do +for std in 17 14 11; do try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`" - for flag in $try_flags; do - echo "Checking for wheter ${cmake_cxx_flags} supports ${flag}" >> cmake_bootstrap.log 2>&1 - if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${flag} -DTEST1" \ - "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then - cmake_cxx_flags="${cmake_cxx_flags} ${flag} " - break 2 - fi + for compiler in ${cmake_cxx_compilers}; do + for flag in '' $try_flags; do + echo "Checking whether '${compiler} ${cmake_cxx_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1 + if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${flag}" \ + "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then + cmake_cxx_compiler="${compiler}" + cmake_cxx_flags="${cmake_cxx_flags} ${flag} " + break 3 + fi + done done done rm -f "${TMPFILE}.cxx" if [ -z "${cmake_cxx_compiler}" ]; then - cmake_error 7 "Cannot find appropriate C++ compiler on this system. +cmake_error 7 "Cannot find a C++ compiler supporting C++11 on this system. Please specify one using environment variable CXX. See cmake_bootstrap.log for compilers attempted." fi @@ -1120,31 +1094,6 @@ if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then echo "---------------------------------------------" fi -# Ok, we have CC, CXX, and MAKE. - -# Test C++ compiler features - -# Are we GCC? - -TMPFILE=`cmake_tmp_file` -echo ' -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) -#include <iostream> -int main() { std::cout << "This is GNU" << std::endl; return 0;} -#endif -' > ${TMPFILE}.cxx -cmake_cxx_compiler_is_gnu=0 -if cmake_try_run "${cmake_cxx_compiler}" \ - "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then - cmake_cxx_compiler_is_gnu=1 -fi -if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then - echo "${cmake_cxx_compiler} is GNU compiler" -else - echo "${cmake_cxx_compiler} is not GNU compiler" -fi -rm -f "${TMPFILE}.cxx" - # Test for kwsys features KWSYS_NAME_IS_KWSYS=0 KWSYS_BUILD_SHARED=0 |