diff options
95 files changed, 1076 insertions, 883 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/3.9.rst b/Help/release/3.9.rst index ae55105..5087b43 100644 --- a/Help/release/3.9.rst +++ b/Help/release/3.9.rst @@ -310,9 +310,6 @@ Other Changes in dependent targets may now compile without waiting for their targets' dependencies to link. -* On macOS, the default application bundle ``Info.plist`` file now enables - Hi-DPI support. - * On macOS, ``RPATH`` settings such as :prop_tgt:`BUILD_WITH_INSTALL_RPATH` no longer affect the ``install_name`` field. See policy :policy:`CMP0068`. @@ -333,3 +330,10 @@ Changes made since CMake 3.9.0 include the following. CMake 3.9.0 has been removed for the 3.9 series due to regressions caused by new use of ``<PackageName>_ROOT`` variables. The behavior may be re-introduced in the future in a more-compatible way. + +3.9.2 +----- + +* On macOS, the default application bundle ``Info.plist`` file no longer + enables Hi-DPI support as it did in 3.9.0 and 3.9.1. The change had + to be reverted because it broke iOS applications. diff --git a/Help/release/dev/FindCurses-wide.rst b/Help/release/dev/FindCurses-wide.rst new file mode 100644 index 0000000..63fb671 --- /dev/null +++ b/Help/release/dev/FindCurses-wide.rst @@ -0,0 +1,5 @@ +FindCurses-wide +--------------- + +* The :module:`FindCurses` module gained a ``CURSES_NEED_WIDE`` option + to request the wide-character variant. 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..60ceebc 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -4,7 +4,7 @@ set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") -set(AM_BUILD_DIR @_autogen_build_dir@) +set(AM_BUILD_DIR @_build_dir@) set(AM_SOURCES @_sources@) set(AM_HEADERS @_headers@) # Qt environment @@ -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 diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 8d58d03..4f59d2c 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -29,6 +29,8 @@ # # Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the # ``find_package(Curses)`` call if NCurses functionality is required. +# Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the +# ``find_package(Curses)`` call if unicode functionality is required. # # Backward Compatibility # ^^^^^^^^^^^^^^^^^^^^^^ @@ -42,9 +44,20 @@ include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) +# we don't know anything about cursesw, so only ncurses +# may be ncursesw +if(NOT CURSES_NEED_WIDE) + set(NCURSES_LIBRARY_NAME "ncurses") +else() + set(NCURSES_LIBRARY_NAME "ncursesw") + # Also, if we are searchig fo wide curses - we are actually searching + # for ncurses, we don't know about any other unicode version. + set(CURSES_NEED_NCURSES TRUE) +endif() + find_library(CURSES_CURSES_LIBRARY NAMES curses ) -find_library(CURSES_NCURSES_LIBRARY NAMES ncurses ) +find_library(CURSES_NCURSES_LIBRARY NAMES "${NCURSES_LIBRARY_NAME}" ) set(CURSES_USE_NCURSES FALSE) if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES)) @@ -55,8 +68,14 @@ endif() # message. Cygwin is an ncurses package, so force ncurses on # cygwin if the curses.h is missing if(CYGWIN) - if(NOT EXISTS /usr/include/curses.h) - set(CURSES_USE_NCURSES TRUE) + if (CURSES_NEED_WIDE) + if(NOT EXISTS /usr/include/ncursesw/curses.h) + set(CURSES_USE_NCURSES TRUE) + endif() + else() + if(NOT EXISTS /usr/include/curses.h) + set(CURSES_USE_NCURSES TRUE) + endif() endif() endif() @@ -96,17 +115,32 @@ if(CURSES_USE_NCURSES) # Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility. if(CURSES_NCURSES_INCLUDE_PATH) + if (CURSES_NEED_WIDE) + find_path(CURSES_INCLUDE_PATH + NAMES ncursesw/ncurses.h ncursesw/curses.h + PATHS ${CURSES_NCURSES_INCLUDE_PATH} + NO_DEFAULT_PATH + ) + else() + find_path(CURSES_INCLUDE_PATH + NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h + PATHS ${CURSES_NCURSES_INCLUDE_PATH} + NO_DEFAULT_PATH + ) + endif() + endif() + + if (CURSES_NEED_WIDE) + find_path(CURSES_INCLUDE_PATH + NAMES ncursesw/ncurses.h ncursesw/curses.h + HINTS "${_cursesParentDir}/include" + ) + else() find_path(CURSES_INCLUDE_PATH NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h - PATHS ${CURSES_NCURSES_INCLUDE_PATH} - NO_DEFAULT_PATH + HINTS "${_cursesParentDir}/include" ) - endif() - - find_path(CURSES_INCLUDE_PATH - NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h - HINTS "${_cursesParentDir}/include" - ) + endif() # Previous versions of FindCurses provided these values. if(NOT DEFINED CURSES_LIBRARY) @@ -123,10 +157,14 @@ else() get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH) - find_path(CURSES_INCLUDE_PATH - NAMES curses.h - HINTS "${_cursesParentDir}/include" - ) + #We can't find anything with CURSES_NEED_WIDE because we know + #only about ncursesw unicode curses version + if(NOT CURSES_NEED_WIDE) + find_path(CURSES_INCLUDE_PATH + NAMES curses.h + HINTS "${_cursesParentDir}/include" + ) + endif() # Previous versions of FindCurses provided these values. if(NOT DEFINED CURSES_CURSES_H_PATH) @@ -139,31 +177,44 @@ endif() # Report whether each possible header name exists in the include directory. if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") + if(CURSES_NEED_WIDE) + if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h") + set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h") + endif() + elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") - else() + endif() + if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H) set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND") endif() endif() if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h") + if(CURSES_NEED_WIDE) + if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h") + set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h") + endif() + elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h") set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h") - else() + endif() + if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H) set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND") endif() endif() -if(NOT DEFINED CURSES_HAVE_NCURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h") - set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h") - else() - set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND") +if(NOT CURSES_NEED_WIDE) + #ncursesw can't be found for this paths + if(NOT DEFINED CURSES_HAVE_NCURSES_H) + if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h") + set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h") + else() + set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND") + endif() endif() -endif() -if(NOT DEFINED CURSES_HAVE_CURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h") - set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h") - else() - set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND") + if(NOT DEFINED CURSES_HAVE_CURSES_H) + if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h") + set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h") + else() + set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND") + endif() endif() endif() diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index a8133da..b37f796 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -304,6 +304,7 @@ function(_Ice_FIND) foreach(ice_version ${ice_versions}) foreach(vcver IN LISTS vcvers) list(APPEND ice_nuget_dirs "zeroc.ice.v${vcver}.${ice_version}") + list(APPEND freeze_nuget_dirs "zeroc.freeze.v${vcver}.${ice_version}") endforeach() endforeach() find_path(Ice_NUGET_DIR @@ -313,6 +314,13 @@ function(_Ice_FIND) if(Ice_NUGET_DIR) list(APPEND ice_roots "${Ice_NUGET_DIR}") endif() + find_path(Freeze_NUGET_DIR + NAMES "tools/slice2freeze.exe" + PATH_SUFFIXES ${freeze_nuget_dirs} + DOC "Freeze NuGet directory") + if(Freeze_NUGET_DIR) + list(APPEND ice_roots "${Freeze_NUGET_DIR}") + endif() foreach(ice_version ${ice_versions}) # Ice 3.3 releases use a Visual Studio year suffix and value is # enclosed in double quotes, though only the leading quote is @@ -390,6 +398,13 @@ function(_Ice_FIND) DOC "Ice include directory") set(Ice_INCLUDE_DIR "${Ice_INCLUDE_DIR}" PARENT_SCOPE) + find_path(Freeze_INCLUDE_DIR + NAMES "Freeze/Freeze.h" + HINTS ${ice_roots} + PATH_SUFFIXES ${ice_include_suffixes} + DOC "Freeze include directory") + set(Freeze_INCLUDE_DIR "${Freeze_INCLUDE_DIR}" PARENT_SCOPE) + # In common use on Linux, MacOS X (homebrew) and FreeBSD; prefer # version-specific dir list(APPEND ice_slice_paths @@ -527,6 +542,9 @@ unset(_Ice_REQUIRED_LIBS_FOUND) if(Ice_FOUND) set(Ice_INCLUDE_DIRS "${Ice_INCLUDE_DIR}") + if (Freeze_INCLUDE_DIR) + list(APPEND Ice_INCLUDE_DIRS "${Freeze_INCLUDE_DIR}") + endif() set(Ice_SLICE_DIRS "${Ice_SLICE_DIR}") set(Ice_LIBRARIES "${Ice_LIBRARY}") foreach(_Ice_component ${Ice_FIND_COMPONENTS}) @@ -541,10 +559,8 @@ if(Ice_FOUND) set("${_Ice_component_lib}" "${${_Ice_component_cache}}") if(NOT TARGET ${_Ice_imported_target}) add_library(${_Ice_imported_target} UNKNOWN IMPORTED) - if() - set_target_properties(${_Ice_imported_target} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIR}") - endif() + set_target_properties(${_Ice_imported_target} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIRS}") if(EXISTS "${${_Ice_component_cache}}") set_target_properties(${_Ice_imported_target} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" @@ -581,6 +597,8 @@ if(Ice_DEBUG) message(STATUS "Ice_INCLUDE_DIR directory: ${Ice_INCLUDE_DIR}") message(STATUS "Ice_SLICE_DIR directory: ${Ice_SLICE_DIR}") message(STATUS "Ice_LIBRARIES: ${Ice_LIBRARIES}") + message(STATUS "Freeze_INCLUDE_DIR directory: ${Freeze_INCLUDE_DIR}") + message(STATUS "Ice_INCLUDE_DIRS directory: ${Ice_INCLUDE_DIRS}") foreach(program ${_Ice_db_programs} ${_Ice_programs} ${_Ice_slice_programs}) string(TOUPPER "${program}" program_upcase) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 6d33fc6..1a4e268 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -89,6 +89,8 @@ if(MSVC) endif() if(MSVC_VERSION EQUAL 1400) + set(MSVC_REDIST_NAME VC80) + # Find the runtime library redistribution directory. get_filename_component(msvc_install_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE) @@ -129,6 +131,8 @@ if(MSVC) endif() if(MSVC_VERSION EQUAL 1500) + set(MSVC_REDIST_NAME VC90) + # Find the runtime library redistribution directory. get_filename_component(msvc_install_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE) @@ -171,22 +175,32 @@ if(MSVC) endif() endif() - if(MSVC_VERSION EQUAL 1910) + if(MSVC_VERSION EQUAL 1911) + set(MSVC_REDIST_NAME VC141) + set(_MSVCRT_DLL_VERSION 140) + set(_MSVCRT_IDE_VERSION 15) + elseif(MSVC_VERSION EQUAL 1910) + set(MSVC_REDIST_NAME VC150) set(_MSVCRT_DLL_VERSION 140) set(_MSVCRT_IDE_VERSION 15) elseif(MSVC_VERSION EQUAL 1900) + set(MSVC_REDIST_NAME VC140) set(_MSVCRT_DLL_VERSION 140) set(_MSVCRT_IDE_VERSION 14) elseif(MSVC_VERSION EQUAL 1800) + set(MSVC_REDIST_NAME VC120) set(_MSVCRT_DLL_VERSION 120) set(_MSVCRT_IDE_VERSION 12) elseif(MSVC_VERSION EQUAL 1700) + set(MSVC_REDIST_NAME VC110) set(_MSVCRT_DLL_VERSION 110) set(_MSVCRT_IDE_VERSION 11) elseif(MSVC_VERSION EQUAL 1600) + set(MSVC_REDIST_NAME VC100) set(_MSVCRT_DLL_VERSION 100) set(_MSVCRT_IDE_VERSION 10) else() + set(MSVC_REDIST_NAME "") set(_MSVCRT_DLL_VERSION "") set(_MSVCRT_IDE_VERSION "") endif() @@ -219,10 +233,10 @@ if(MSVC) unset(_vs_dir) unset(programfilesx86) endif() - find_path(MSVC_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.CRT PATHS ${_vs_redist_paths}) + find_path(MSVC_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.CRT PATHS ${_vs_redist_paths}) unset(_vs_redist_paths) mark_as_advanced(MSVC_REDIST_DIR) - set(MSVC_CRT_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.CRT") + set(MSVC_CRT_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.CRT") if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) set(__install__libs @@ -242,7 +256,7 @@ if(MSVC) if(CMAKE_INSTALL_DEBUG_LIBRARIES) set(MSVC_CRT_DIR - "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.DebugCRT") + "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.DebugCRT") set(__install__libs ${__install__libs} "${MSVC_CRT_DIR}/msvcp${v}d.dll" ) @@ -383,7 +397,10 @@ if(MSVC) ) endif() - if(MSVC_VERSION EQUAL 1910) + if(MSVC_VERSION EQUAL 1911) + set(_MFC_DLL_VERSION 140) + set(_MFC_IDE_VERSION 15) + elseif(MSVC_VERSION EQUAL 1910) set(_MFC_DLL_VERSION 140) set(_MFC_IDE_VERSION 15) elseif(MSVC_VERSION EQUAL 1900) @@ -410,7 +427,7 @@ if(MSVC) # Starting with VS 15 the MFC DLLs may be in a different directory. if (NOT vs VERSION_LESS 15) file(GLOB _MSVC_REDIST_DIRS "${MSVC_REDIST_DIR}/../*") - find_path(MSVC_REDIST_MFC_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.MFC + find_path(MSVC_REDIST_MFC_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC PATHS ${_MSVC_REDIST_DIRS} NO_DEFAULT_PATH) mark_as_advanced(MSVC_REDIST_MFC_DIR) unset(_MSVC_REDIST_DIRS) @@ -424,7 +441,7 @@ if(MSVC) if(CMAKE_INSTALL_DEBUG_LIBRARIES) set(MSVC_MFC_DIR - "${MSVC_REDIST_MFC_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.DebugMFC") + "${MSVC_REDIST_MFC_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.DebugMFC") set(__install__libs ${__install__libs} "${MSVC_MFC_DIR}/mfc${v}ud.dll" "${MSVC_MFC_DIR}/mfcm${v}ud.dll" @@ -437,7 +454,7 @@ if(MSVC) endif() endif() - set(MSVC_MFC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.MFC") + set(MSVC_MFC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC") if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) set(__install__libs ${__install__libs} "${MSVC_MFC_DIR}/mfc${v}u.dll" @@ -452,7 +469,7 @@ if(MSVC) endif() # include the language dll's as well as the actuall dll's - set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.MFCLOC") + set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC") set(__install__libs ${__install__libs} "${MSVC_MFCLOC_DIR}/mfc${v}chs.dll" "${MSVC_MFCLOC_DIR}/mfc${v}cht.dll" @@ -471,7 +488,10 @@ if(MSVC) # MSVC 8 was the first version with OpenMP # Furthermore, there is no debug version of this if(CMAKE_INSTALL_OPENMP_LIBRARIES) - if(MSVC_VERSION EQUAL 1910) + if(MSVC_VERSION EQUAL 1911) + set(_MSOMP_DLL_VERSION 140) + set(_MSOMP_IDE_VERSION 15) + elseif(MSVC_VERSION EQUAL 1910) set(_MSOMP_DLL_VERSION 140) set(_MSOMP_IDE_VERSION 15) elseif(MSVC_VERSION EQUAL 1900) @@ -500,7 +520,7 @@ if(MSVC) if(_MSOMP_DLL_VERSION) set(v "${_MSOMP_DLL_VERSION}") set(vs "${_MSOMP_IDE_VERSION}") - set(MSVC_OPENMP_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${vs}0.OPENMP") + set(MSVC_OPENMP_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.OPENMP") if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) set(__install__libs ${__install__libs} diff --git a/Modules/MacOSXBundleInfo.plist.in b/Modules/MacOSXBundleInfo.plist.in index e06b17e..a4009bc 100644 --- a/Modules/MacOSXBundleInfo.plist.in +++ b/Modules/MacOSXBundleInfo.plist.in @@ -30,9 +30,5 @@ <true/> <key>NSHumanReadableCopyright</key> <string>${MACOSX_BUNDLE_COPYRIGHT}</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> - <key>NSHighResolutionCapable</key> - <string>True</string> </dict> </plist> @@ -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 5d85ef0..fdfb7a8 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 20170816) +set(CMake_VERSION_PATCH 20170824) #set(CMake_VERSION_RC 1) diff --git a/Source/Checks/cm_cxx_attribute_fallthrough.cxx b/Source/Checks/cm_cxx_attribute_fallthrough.cxx index df43625..50605b7 100644 --- a/Source/Checks/cm_cxx_attribute_fallthrough.cxx +++ b/Source/Checks/cm_cxx_attribute_fallthrough.cxx @@ -1,4 +1,4 @@ -int main(int argc, char* argv[]) +int main(int argc, char* []) { int i = 3; switch (argc) { diff --git a/Source/Checks/cm_cxx_fallthrough.cxx b/Source/Checks/cm_cxx_fallthrough.cxx index 7b35a5f..2825bed 100644 --- a/Source/Checks/cm_cxx_fallthrough.cxx +++ b/Source/Checks/cm_cxx_fallthrough.cxx @@ -1,4 +1,4 @@ -int main(int argc, char* argv[]) +int main(int argc, char* []) { int i = 3; switch (argc) { diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index 3b08025..e75a7ef 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -54,5 +54,3 @@ endif() cm_check_cxx_feature(nullptr) cm_check_cxx_feature(override) cm_check_cxx_feature(unique_ptr) -cm_check_cxx_feature(unordered_map) -cm_check_cxx_feature(unordered_set) diff --git a/Source/Checks/cm_cxx_gnu_fallthrough.cxx b/Source/Checks/cm_cxx_gnu_fallthrough.cxx index 6021094..ebc15f4 100644 --- a/Source/Checks/cm_cxx_gnu_fallthrough.cxx +++ b/Source/Checks/cm_cxx_gnu_fallthrough.cxx @@ -1,4 +1,4 @@ -int main(int argc, char* argv[]) +int main(int argc, char* []) { int i = 3; switch (argc) { diff --git a/Source/Checks/cm_cxx_unordered_map.cxx b/Source/Checks/cm_cxx_unordered_map.cxx deleted file mode 100644 index be3de25..0000000 --- a/Source/Checks/cm_cxx_unordered_map.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#include <unordered_map> -int main() -{ - std::unordered_map<int, int> map; - map[0] = 0; - return 0; -} diff --git a/Source/Checks/cm_cxx_unordered_set.cxx b/Source/Checks/cm_cxx_unordered_set.cxx deleted file mode 100644 index de4bb77..0000000 --- a/Source/Checks/cm_cxx_unordered_set.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#include <unordered_set> -int main() -{ - std::unordered_set<int> set; - set.insert(0); - return 0; -} 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/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ff19eac..8a3a671 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -161,7 +161,7 @@ void cmComputeTargetDepends::CollectTargets() std::vector<cmLocalGenerator*> const& lgens = this->GlobalGenerator->GetLocalGenerators(); for (unsigned int i = 0; i < lgens.size(); ++i) { - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = lgens[i]->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 302000a..a920bf2 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -28,8 +28,6 @@ #cmakedefine CMake_HAVE_CXX_NULLPTR #cmakedefine CMake_HAVE_CXX_OVERRIDE #cmakedefine CMake_HAVE_CXX_UNIQUE_PTR -#cmakedefine CMake_HAVE_CXX_UNORDERED_MAP -#cmakedefine CMake_HAVE_CXX_UNORDERED_SET #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 67213ec..ef46b17 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -24,7 +24,6 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, , OldStyle(cc.GetEscapeOldStyle()) , MakeVars(cc.GetEscapeAllowMakeVars()) , GE(new cmGeneratorExpression(cc.GetBacktrace())) - , DependsDone(false) { const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines(); for (cmCustomCommandLines::const_iterator cmdline = cmdlines.begin(); @@ -44,6 +43,22 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, } this->CommandLines.push_back(argv); } + + std::vector<std::string> depends = this->CC.GetDepends(); + for (std::vector<std::string>::const_iterator i = depends.begin(); + i != depends.end(); ++i) { + CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i); + std::vector<std::string> result; + cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config), + result); + for (std::vector<std::string>::iterator it = result.begin(); + it != result.end(); ++it) { + if (cmSystemTools::FileIsFullPath(it->c_str())) { + *it = cmSystemTools::CollapseFullPath(*it); + } + } + this->Depends.insert(this->Depends.end(), result.begin(), result.end()); + } } cmCustomCommandGenerator::~cmCustomCommandGenerator() @@ -171,23 +186,5 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const { - if (!this->DependsDone) { - this->DependsDone = true; - std::vector<std::string> depends = this->CC.GetDepends(); - for (std::vector<std::string>::const_iterator i = depends.begin(); - i != depends.end(); ++i) { - CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i); - std::vector<std::string> result; - cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config), - result); - for (std::vector<std::string>::iterator it = result.begin(); - it != result.end(); ++it) { - if (cmSystemTools::FileIsFullPath(it->c_str())) { - *it = cmSystemTools::CollapseFullPath(*it); - } - } - this->Depends.insert(this->Depends.end(), result.begin(), result.end()); - } - } return this->Depends; } diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 0a2adb5..ea33b51 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -21,9 +21,8 @@ class cmCustomCommandGenerator bool OldStyle; bool MakeVars; cmGeneratorExpression* GE; - mutable bool DependsDone; - mutable std::vector<std::string> Depends; cmCustomCommandLines CommandLines; + std::vector<std::string> Depends; const char* GetCrossCompilingEmulator(unsigned int c) const; const char* GetArgv0Location(unsigned int c) const; diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index ddb8918..528b157 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -6,10 +6,10 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <string> +#include <unordered_map> #include <vector> #include "cmLinkedTree.h" -#include "cm_unordered_map.hxx" /** \class cmDefinitions * \brief Store a scope of variable definitions for CMake language. @@ -70,7 +70,7 @@ private: }; static Def NoDef; - typedef CM_UNORDERED_MAP<std::string, Def> MapType; + typedef std::unordered_map<std::string, Def> MapType; MapType Map; static Def const& GetInternal(const std::string& key, StackIter begin, diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 69150ae..a1fdeae 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -4,6 +4,7 @@ #include "cmsys/FStream.hxx" #include <map> +#include <unordered_map> #include <utility> #include "cmGeneratedFileStream.h" @@ -14,7 +15,6 @@ #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cm_auto_ptr.hxx" -#include "cm_unordered_map.hxx" #include "cmake.h" class cmExecutionStatus; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 5b7b827..e7a8975 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -296,8 +296,9 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // and UTILITY targets for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { @@ -359,8 +360,9 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { switch ((*ti)->GetType()) { case cmStateEnums::EXECUTABLE: diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index b478f34..96502d5 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -292,8 +292,9 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile( for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { projectType = CollectSourceFiles(makefile, *ti, cFiles, otherFiles); } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 2a6ce98..473af37 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -475,7 +475,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) this->GlobalGenerator->GetLocalGenerators().begin(); lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) { cmMakefile* makefile = (*lgIt)->GetMakefile(); - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = (*lgIt)->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); @@ -853,8 +853,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (std::vector<cmLocalGenerator*>::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*it)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin(); l != targets.end(); ++l) { std::vector<std::string> includeDirs; std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -910,7 +911,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (std::vector<cmLocalGenerator*>::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = (*it)->GetGeneratorTargets(); std::string subdir = (*it)->ConvertToRelativePath( this->HomeOutputDirectory, (*it)->GetCurrentBinaryDirectory()); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 3730433..e366774 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -115,7 +115,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, for (std::vector<cmLocalGenerator*>::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector<cmGeneratorTarget*> targets = + const std::vector<cmGeneratorTarget*>& targets = (*it)->GetGeneratorTargets(); std::string currentDir = (*it)->GetCurrentBinaryDirectory(); bool topLevel = (currentDir == (*it)->GetBinaryDirectory()); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 1fd1418..a62a546 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -185,8 +185,9 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index f591a8d..61e419c 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -4,10 +4,9 @@ #include <string> #include <time.h> +#include <unordered_map> #include <utility> -#include "cm_unordered_map.hxx" - // Use a platform-specific API to get file times efficiently. #if !defined(_WIN32) || defined(__CYGWIN__) #include "cm_sys_stat.h" @@ -27,7 +26,7 @@ public: bool FileTimesDiffer(const char* f1, const char* f2); private: - typedef CM_UNORDERED_MAP<std::string, cmFileTimeComparison_Type> + typedef std::unordered_map<std::string, cmFileTimeComparison_Type> FileStatsMap; FileStatsMap Files; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f4543..05f94dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -12,6 +12,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unordered_set> #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" @@ -32,7 +33,6 @@ #include "cmTargetLinkLibraryType.h" #include "cmTargetPropertyComputer.h" #include "cm_auto_ptr.hxx" -#include "cm_unordered_set.hxx" #include "cmake.h" class cmMessenger; @@ -823,7 +823,7 @@ static void AddInterfaceEntries( static bool processSources( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, - std::vector<std::string>& srcs, CM_UNORDERED_SET<std::string>& uniqueSrcs, + std::vector<std::string>& srcs, std::unordered_set<std::string>& uniqueSrcs, cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config, bool debugSources) { @@ -950,7 +950,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files, cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES", CM_NULLPTR, CM_NULLPTR); - CM_UNORDERED_SET<std::string> uniqueSrcs; + std::unordered_set<std::string> uniqueSrcs; bool contextDependentDirectSources = processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker, config, debugSources); @@ -1728,7 +1728,7 @@ class cmTargetCollectLinkLanguages public: cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, const std::string& config, - CM_UNORDERED_SET<std::string>& languages, + std::unordered_set<std::string>& languages, cmGeneratorTarget const* head) : Config(config) , Languages(languages) @@ -1795,7 +1795,7 @@ public: private: std::string Config; - CM_UNORDERED_SET<std::string>& Languages; + std::unordered_set<std::string>& Languages; cmGeneratorTarget const* HeadTarget; const cmGeneratorTarget* Target; std::set<cmGeneratorTarget const*> Visited; @@ -1867,7 +1867,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc) const { // Get languages built in this target. - CM_UNORDERED_SET<std::string> languages; + std::unordered_set<std::string> languages; cmLinkImplementation const* impl = this->GetLinkImplementation(config); assert(impl); for (std::vector<std::string>::const_iterator li = impl->Languages.begin(); @@ -1884,7 +1884,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } // Store the transitive closure of languages. - for (CM_UNORDERED_SET<std::string>::const_iterator li = languages.begin(); + for (std::unordered_set<std::string>::const_iterator li = languages.begin(); li != languages.end(); ++li) { lc.Languages.push_back(*li); } @@ -1905,7 +1905,8 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } // Now consider languages that propagate from linked targets. - for (CM_UNORDERED_SET<std::string>::const_iterator sit = languages.begin(); + for (std::unordered_set<std::string>::const_iterator sit = + languages.begin(); sit != languages.end(); ++sit) { std::string propagates = "CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES"; @@ -2477,7 +2478,7 @@ static void processIncludeDirectories( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& includes, - CM_UNORDERED_SET<std::string>& uniqueIncludes, + std::unordered_set<std::string>& uniqueIncludes, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugIncludes, const std::string& language) { @@ -2591,7 +2592,7 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( const std::string& config, const std::string& lang) const { std::vector<std::string> includes; - CM_UNORDERED_SET<std::string> uniqueIncludes; + std::unordered_set<std::string> uniqueIncludes; cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR); @@ -2657,7 +2658,7 @@ static void processCompileOptionsInternal( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions, const char* logName, std::string const& language) { @@ -2695,7 +2696,7 @@ static void processCompileOptions( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions, std::string const& language) { @@ -2708,7 +2709,7 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result, const std::string& config, const std::string& language) const { - CM_UNORDERED_SET<std::string> uniqueOptions; + std::unordered_set<std::string> uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "COMPILE_OPTIONS", CM_NULLPTR, CM_NULLPTR); @@ -2749,7 +2750,7 @@ static void processCompileFeatures( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions) { @@ -2761,7 +2762,7 @@ static void processCompileFeatures( void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result, const std::string& config) const { - CM_UNORDERED_SET<std::string> uniqueFeatures; + std::unordered_set<std::string> uniqueFeatures; cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "COMPILE_FEATURES", CM_NULLPTR, CM_NULLPTR); @@ -2799,7 +2800,7 @@ static void processCompileDefinitions( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, - CM_UNORDERED_SET<std::string>& uniqueOptions, + std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, bool debugOptions, std::string const& language) { @@ -2812,7 +2813,7 @@ void cmGeneratorTarget::GetCompileDefinitions( std::vector<std::string>& list, const std::string& config, const std::string& language) const { - CM_UNORDERED_SET<std::string> uniqueOptions; + std::unordered_set<std::string> uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "COMPILE_DEFINITIONS", CM_NULLPTR, CM_NULLPTR); @@ -4363,7 +4364,7 @@ void cmGeneratorTarget::ComputeLinkInterface( this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. - CM_UNORDERED_SET<std::string> emitted; + std::unordered_set<std::string> emitted; for (std::vector<cmLinkItem>::const_iterator li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 18d10c5..85ba5ee 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2594,9 +2594,9 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, continue; } // Get the targets in the makefile - std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = (*i)->GetGeneratorTargets(); // loop over all the targets - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { cmGeneratorTarget* target = *l; if (this->IsRootOnlyTarget(target) && @@ -2789,9 +2789,9 @@ void cmGlobalGenerator::WriteSummary() cmGeneratedFileStream fout(fname.c_str()); for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin(); it != tgts.end(); ++it) { if ((*it)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 23c6218..aad6725 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -9,6 +9,7 @@ #include <map> #include <set> #include <string> +#include <unordered_map> #include <utility> #include <vector> @@ -19,7 +20,6 @@ #include "cmTarget.h" #include "cmTargetDepend.h" #include "cm_codecvt.hxx" -#include "cm_unordered_map.hxx" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmFileLockPool.h" @@ -488,9 +488,10 @@ protected: const char* GetPredefinedTargetsFolder(); private: - typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap; - typedef CM_UNORDERED_MAP<std::string, cmGeneratorTarget*> GeneratorTargetMap; - typedef CM_UNORDERED_MAP<std::string, cmMakefile*> MakefileMap; + typedef std::unordered_map<std::string, cmTarget*> TargetMap; + typedef std::unordered_map<std::string, cmGeneratorTarget*> + GeneratorTargetMap; + typedef std::unordered_map<std::string, cmMakefile*> MakefileMap; // Map efficiently from target name to cmTarget instance. // Do not use this structure for looping over all targets. // It contains both normal and globally visible imported targets. diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 42ab4d9..788a179 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -260,7 +260,7 @@ void cmGlobalGhsMultiGenerator::Generate() for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { cmLocalGhsMultiGenerator* lg = static_cast<cmLocalGhsMultiGenerator*>(this->LocalGenerators[i]); - std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); this->UpdateBuildFiles(tgts); } } @@ -436,9 +436,9 @@ std::string cmGlobalGhsMultiGenerator::GetFileNameFromPath( } void cmGlobalGhsMultiGenerator::UpdateBuildFiles( - std::vector<cmGeneratorTarget*> tgts) + const std::vector<cmGeneratorTarget*>& tgts) { - for (std::vector<cmGeneratorTarget*>::iterator tgtsI = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator tgtsI = tgts.begin(); tgtsI != tgts.end(); ++tgtsI) { const cmGeneratorTarget* tgt = *tgtsI; if (IsTgtForBuild(tgt)) { diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 7b3eebb..05a3a3c 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -116,7 +116,7 @@ private: std::vector<cmsys::String>::const_iterator end, GhsMultiGpj::Types projType); static std::string GetFileNameFromPath(std::string const& path); - void UpdateBuildFiles(std::vector<cmGeneratorTarget*> tgts); + void UpdateBuildFiles(const std::vector<cmGeneratorTarget*>& tgts); bool IsTgtForBuild(const cmGeneratorTarget* tgt); std::vector<cmGeneratedFileStream*> TargetSubProjects; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index e72c6e3..85a1417 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -128,8 +128,9 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile( } // get all sources - std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*it)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::vector<cmSourceFile*> sources; cmGeneratorTarget* gt = *ti; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 23b3718..e42bf20 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -382,8 +382,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules( for (unsigned int i = 0; i < lGenerators.size(); ++i) { lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]); // for all of out targets - std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if (((*l)->GetType() == cmStateEnums::EXECUTABLE) || ((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) || @@ -414,8 +414,8 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector<std::string> depends; - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin(); l != targets.end(); ++l) { cmGeneratorTarget* gtarget = *l; int type = gtarget->GetType(); @@ -547,8 +547,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( for (i = 0; i < this->LocalGenerators.size(); ++i) { lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]); // for each target Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = *t; // Don't emit the same rule twice (e.g. two targets with the same @@ -629,8 +629,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = *t; int type = gtarget->GetType(); @@ -807,7 +807,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() this->LocalGenerators.begin(); lgi != this->LocalGenerators.end(); ++lgi) { cmLocalGenerator* lg = *lgi; - std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gt = *t; @@ -952,8 +952,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule( // the targets if (lg2 == lg || lg->IsRootMakefile()) { // for each target Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + lg2->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; cmStateEnums::TargetType type = target->GetType(); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 7a42b72..ed1ef1b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -320,10 +320,10 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets() cmGlobalVisualStudio7Generator::AddExtraIDETargets(); if (this->AddCheckTarget()) { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. - for (std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin(); ti != tgts.end(); ++ti) { if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 87a22d1..f85e409 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -82,8 +82,10 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() // Now make all targets depend on the ALL_BUILD target for (std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { - std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*i)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = + targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* tgt = *t; if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET || @@ -298,8 +300,10 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() std::vector<cmLocalGenerator*>& gen = it->second; for (std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { - std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = + (*i)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = + targets.begin(); ti != targets.end(); ++ti) { this->ComputeVSTargetDepends(*ti); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 071d49c..8f260ec 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -440,8 +440,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( continue; } - std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { cmGeneratorTarget* target = *l; @@ -925,12 +925,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets) { this->SetCurrentLocalGenerator(gen); - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->CurrentLocalGenerator->GetGeneratorTargets(); typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets> cmSortedTargets; cmSortedTargets sortedTargets; - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { sortedTargets[(*l)->GetName()] = *l; } @@ -1210,7 +1210,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( void cmGlobalXCodeGenerator::ForceLinkerLanguages() { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector<cmGeneratorTarget*> tgts = + const std::vector<cmGeneratorTarget*>& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); // All targets depend on the build-system check target. for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin(); @@ -2706,8 +2706,8 @@ bool cmGlobalXCodeGenerator::CreateGroups( i != generators.end(); ++i) { cmMakefile* mf = (*i)->GetMakefile(); std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups(); - std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = (*i)->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { cmGeneratorTarget* gtgt = *l; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7e953ce..015f887 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -420,7 +420,8 @@ int cmGraphVizWriter::CollectAllTargets() for (std::vector<cmLocalGenerator*>::const_iterator lit = this->LocalGenerators.begin(); lit != this->LocalGenerators.end(); ++lit) { - std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = + (*lit)->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin(); it != targets.end(); ++it) { const char* realTargetName = (*it)->GetName().c_str(); @@ -445,7 +446,8 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) for (std::vector<cmLocalGenerator*>::const_iterator lit = this->LocalGenerators.begin(); lit != this->LocalGenerators.end(); ++lit) { - std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = + (*lit)->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin(); it != targets.end(); ++it) { const char* realTargetName = (*it)->GetName().c_str(); diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index e00eba0..d721ca0 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -2,12 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallTargetsCommand.h" +#include <unordered_map> #include <utility> #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmTarget.h" -#include "cm_unordered_map.hxx" class cmExecutionStatus; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2c5db10..2c8157e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -214,8 +214,8 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -548,6 +548,8 @@ void cmLocalGenerator::GenerateInstallRules() void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt) { this->GeneratorTargets.push_back(gt); + this->GeneratorTargetSearchIndex.insert( + std::pair<std::string, cmGeneratorTarget*>(gt->GetName(), gt)); this->GlobalGenerator->IndexGeneratorTarget(gt); } @@ -581,11 +583,10 @@ private: cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget( const std::string& name) const { - std::vector<cmGeneratorTarget*>::const_iterator ti = - std::find_if(this->GeneratorTargets.begin(), this->GeneratorTargets.end(), - NamedGeneratorTargetFinder(name)); - if (ti != this->GeneratorTargets.end()) { - return *ti; + GeneratorTargetMap::const_iterator ti = + this->GeneratorTargetSearchIndex.find(name); + if (ti != this->GeneratorTargetSearchIndex.end()) { + return ti->second; } return CM_NULLPTR; } @@ -600,8 +601,8 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -625,8 +626,8 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures() } // Process compile features of all targets. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; for (std::vector<std::string>::iterator ci = configNames.begin(); @@ -2121,8 +2122,8 @@ void cmLocalGenerator::GenerateTargetInstallRules( { // Convert the old-style install specification from each target to // an install generator and run it. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9f78be4..aaf7d71 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -10,6 +10,7 @@ #include <map> #include <set> #include <string> +#include <unordered_map> #include <vector> #include "cmListFileCache.h" @@ -353,8 +354,12 @@ protected: std::string::size_type ObjectPathMax; std::set<std::string> ObjectMaxPathViolations; - std::set<cmGeneratorTarget const*> WarnCMP0063; + typedef std::unordered_map<std::string, cmGeneratorTarget*> + GeneratorTargetMap; + GeneratorTargetMap GeneratorTargetSearchIndex; std::vector<cmGeneratorTarget*> GeneratorTargets; + + std::set<cmGeneratorTarget const*> WarnCMP0063; std::vector<cmGeneratorTarget*> ImportedGeneratorTargets; std::vector<cmGeneratorTarget*> OwnedImportedGeneratorTargets; std::map<std::string, std::string> AliasTargets; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 5f37af5..ab6774e 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -20,9 +20,9 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() void cmLocalGhsMultiGenerator::Generate() { - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 266710c..9fa3ca5 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -79,8 +79,8 @@ void cmLocalNinjaGenerator::Generate() } } - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9b9d22c..2d10021 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -116,10 +116,10 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -172,8 +172,8 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( std::map<std::string, LocalObjectInfo>& localObjectFiles) { - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmGeneratorTarget* gt = *ti; if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -382,9 +382,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( // for each target we just provide a rule to cd up to the top and do a make // on the target - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); std::string localName; - for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { if (((*t)->GetType() == cmStateEnums::EXECUTABLE) || ((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) || @@ -1562,8 +1562,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( this->WriteDivider(ruleFileStream); ruleFileStream << "# Targets provided globally by CMake.\n" << "\n"; - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - std::vector<cmGeneratorTarget*>::iterator glIt; + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + std::vector<cmGeneratorTarget*>::const_iterator glIt; for (glIt = targets.begin(); glIt != targets.end(); ++glIt) { if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::string targetString = diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 85d4a73..db1776a 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -60,8 +60,8 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() void cmLocalVisualStudio10Generator::Generate() { - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd08e5b..857ce46 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -62,8 +62,8 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() void cmLocalVisualStudio7Generator::AddHelperCommands() { // Now create GUIDs for targets - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -91,8 +91,9 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() // specification source changes. if (cmSourceFile* sf = this->CreateVCProjBuildRule()) { // Add the rule to targets that need it. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = + this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; @@ -110,8 +111,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() // Visual Studio .NET 2003 Service Pack 1 will not run post-build // commands for targets in which no sources are built. Add dummy // rules to force these targets to build. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::vector<std::string> no_depends; @@ -150,10 +151,10 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() } // Get the set of targets in this directory. - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); + const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); // Create the project file for each target. - for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); + for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 739ef43..355c394 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -42,8 +42,8 @@ void cmLocalXCodeGenerator::Generate() { cmLocalGenerator::Generate(); - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { (*iter)->HasMacOSXRpathInstallNameDir(""); } @@ -53,8 +53,8 @@ void cmLocalXCodeGenerator::GenerateInstallRules() { cmLocalGenerator::GenerateInstallRules(); - std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin(); + const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); + for (std::vector<cmGeneratorTarget*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { (*iter)->HasMacOSXRpathInstallNameDir(""); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cb6cf2d..29999e9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3902,16 +3902,6 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath, return false; } -void cmMakefile::AddQtUiFileWithOptions(cmSourceFile* sf) -{ - this->QtUiFilesWithOptions.push_back(sf); -} - -std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const -{ - return this->QtUiFilesWithOptions; -} - static std::string const matchVariables[] = { "CMAKE_MATCH_0", "CMAKE_MATCH_1", "CMAKE_MATCH_2", "CMAKE_MATCH_3", "CMAKE_MATCH_4", "CMAKE_MATCH_5", "CMAKE_MATCH_6", "CMAKE_MATCH_7", diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e65ba46..059a4e7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -12,6 +12,7 @@ #include <stack> #include <stddef.h> #include <string> +#include <unordered_map> #include <vector> #include "cmAlgorithms.h" @@ -22,7 +23,6 @@ #include "cmStateTypes.h" #include "cmTarget.h" #include "cm_auto_ptr.hxx" -#include "cm_unordered_map.hxx" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -736,9 +736,6 @@ public: cmStringRange GetCompileDefinitionsEntries() const; cmBacktraceRange GetCompileDefinitionsBacktraces() const; - void AddQtUiFileWithOptions(cmSourceFile* sf); - std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const; - std::set<std::string> const& GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; @@ -871,7 +868,7 @@ private: friend class cmParseFileScope; std::vector<cmTarget*> ImportedTargetsOwned; - typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap; + typedef std::unordered_map<std::string, cmTarget*> TargetMap; TargetMap ImportedTargets; // Internal policy stack management. @@ -909,7 +906,7 @@ private: cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const; // A map for fast output to input look up. - typedef CM_UNORDERED_MAP<std::string, cmSourceFile*> OutputToSourceMap; + typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap; OutputToSourceMap OutputToSource; void UpdateOutputToSourceMap(std::vector<std::string> const& outputs, @@ -917,8 +914,6 @@ private: void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source); - std::vector<cmSourceFile*> QtUiFilesWithOptions; - bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature, std::string* error = CM_NULLPTR) const; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 2339d68..93d2c14 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -5,6 +5,7 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include <map> +#include <unordered_map> #include <utility> #include "cmAlgorithms.h" @@ -13,7 +14,6 @@ #include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cm_unordered_map.hxx" class cmExecutionStatus; diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 7974977..a8e2bca 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -4,6 +4,8 @@ #include "cmQtAutoGeneratorCommon.h" #include "cmAlgorithms.h" +#include "cmConfigure.h" +#include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmFilePathChecksum.h" #include "cmGeneratorTarget.h" @@ -19,13 +21,8 @@ #include "cmTarget.h" #include "cm_sys_stat.h" #include "cmake.h" - -#if defined(_WIN32) && !defined(__CYGWIN__) -#include "cmGlobalVisualStudioGenerator.h" -#endif - -#include "cmConfigure.h" #include "cmsys/FStream.hxx" + #include <algorithm> #include <map> #include <set> @@ -34,26 +31,20 @@ #include <utility> #include <vector> -static void utilCopyTargetProperty(cmTarget* destinationTarget, - cmTarget* sourceTarget, - const std::string& propertyName) +inline static const char* SafeString(const char* value) { - const char* propertyValue = sourceTarget->GetProperty(propertyName); - if (propertyValue) { - destinationTarget->SetProperty(propertyName, propertyValue); - } + return (value != CM_NULLPTR) ? value : ""; } -inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key) +static std::string GetSafeProperty(cmGeneratorTarget const* target, + const char* key) { - return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key)); + return std::string(SafeString(target->GetProperty(key))); } -static std::string GetSafeProperty(cmGeneratorTarget const* target, - const char* key) +inline static bool AutogenMultiConfig(cmGlobalGenerator* globalGen) { - const char* tmp = target->GetProperty(key); - return std::string((tmp != CM_NULLPTR) ? tmp : ""); + return globalGen->IsMultiConfig(); } static std::string GetAutogenTargetName(cmGeneratorTarget const* target) @@ -156,11 +147,6 @@ static void GetCompileDefinitionsAndDirectories( } } -static bool IsMultiConfig(cmGlobalGenerator* globalGen) -{ - return globalGen->IsMultiConfig(); -} - static std::vector<std::string> GetConfigurations( cmMakefile* makefile, std::string* config = CM_NULLPTR) { @@ -181,7 +167,7 @@ static std::vector<std::string> GetConfigurations( static std::vector<std::string> GetConfigurationSuffixes(cmMakefile* makefile) { std::vector<std::string> suffixes; - if (IsMultiConfig(makefile->GetGlobalGenerator())) { + if (AutogenMultiConfig(makefile->GetGlobalGenerator())) { makefile->GetConfigurations(suffixes); for (std::vector<std::string>::iterator it = suffixes.begin(); it != suffixes.end(); ++it) { @@ -208,6 +194,13 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str()); } +static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, + const std::set<std::string>& values) +{ + makefile->AddDefinition( + key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str()); +} + static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, cmQtAutoGeneratorCommon::GeneratorType genType) { @@ -263,6 +256,12 @@ static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, return true; } +static void AddCleanFile(cmMakefile* makefile, const std::string& fileName) +{ + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fileName.c_str(), + false); +} + static void AddGeneratedSource(cmGeneratorTarget* target, const std::string& filename, cmQtAutoGeneratorCommon::GeneratorType genType) @@ -278,39 +277,81 @@ static void AddGeneratedSource(cmGeneratorTarget* target, AddToSourceGroup(makefile, filename, genType); } -static void AcquireScanFiles(cmGeneratorTarget const* target, - std::vector<std::string>& mocUicSources, - std::vector<std::string>& mocUicHeaders, - std::vector<std::string>& mocSkipList, - std::vector<std::string>& uicSkipList) +struct AutogenSetup +{ + std::vector<std::string> sources; + std::vector<std::string> headers; + + std::set<std::string> mocSkip; + std::set<std::string> uicSkip; + + std::map<std::string, std::string> configSuffix; + std::map<std::string, std::string> configMocIncludes; + std::map<std::string, std::string> configMocDefines; + std::map<std::string, std::string> configUicOptions; +}; + +static void SetupAcquireScanFiles(cmGeneratorTarget const* target, + bool mocEnabled, bool uicEnabled, + const std::vector<cmSourceFile*>& srcFiles, + AutogenSetup& setup) { - const bool mocTarget = target->GetPropertyAsBool("AUTOMOC"); - const bool uicTarget = target->GetPropertyAsBool("AUTOUIC"); + // Read skip files from makefile sources + { + const std::vector<cmSourceFile*>& allSources = + target->Makefile->GetSourceFiles(); + for (std::vector<cmSourceFile*>::const_iterator fit = allSources.begin(); + fit != allSources.end(); ++fit) { + cmSourceFile* sf = *fit; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); + if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && + !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + continue; + } + const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN"); + const bool mocSkip = + mocEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC")); + const bool uicSkip = + uicEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC")); + if (mocSkip || uicSkip) { + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); + if (mocSkip) { + setup.mocSkip.insert(absFile); + } + if (uicSkip) { + setup.uicSkip.insert(absFile); + } + } + } + } + const cmPolicies::PolicyStatus CMP0071_status = target->Makefile->GetPolicyStatus(cmPolicies::CMP0071); - - std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); const cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { continue; } - - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - // Skip flags - const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN"); - const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC"); - const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC"); - const bool accept = (mocTarget && !mocSkip) || (uicTarget && !uicSkip); + // Real file path + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); + // Skip test + const bool mocSkip = !mocEnabled || (setup.mocSkip.count(absFile) != 0); + const bool uicSkip = !uicEnabled || (setup.uicSkip.count(absFile) != 0); + if (mocSkip && uicSkip) { + continue; + } // For GENERATED files check status of policy CMP0071 - if (accept && PropertyEnabled(sf, "GENERATED")) { + if (sf->GetPropertyAsBool("GENERATED")) { bool policyAccept = false; switch (CMP0071_status) { case cmPolicies::WARN: { @@ -336,50 +377,37 @@ static void AcquireScanFiles(cmGeneratorTarget const* target, } } - // Add file name to skip lists. - // Do this even when the file is not added to the sources/headers lists - // because the file name may be extracted from an other file when - // processing - if (mocSkip) { - mocSkipList.push_back(absFile); - } - if (uicSkip) { - uicSkipList.push_back(absFile); - } - - if (accept) { - // Add file name to sources or headers list - switch (fileType) { - case cmSystemTools::CXX_FILE_FORMAT: - mocUicSources.push_back(absFile); - break; - case cmSystemTools::HEADER_FILE_FORMAT: - mocUicHeaders.push_back(absFile); - break; - default: - break; - } + // Add file name to sources or headers list + switch (fileType) { + case cmSystemTools::CXX_FILE_FORMAT: + setup.sources.push_back(absFile); + break; + case cmSystemTools::HEADER_FILE_FORMAT: + setup.headers.push_back(absFile); + break; + default: + break; } } } -static void MocSetupAutoTarget( - cmGeneratorTarget const* target, const std::string& autogenTargetName, - std::string const& qtMajorVersion, std::string const& config, - std::vector<std::string> const& configs, - std::vector<std::string> const& mocSkipList, - std::map<std::string, std::string>& configMocIncludes, - std::map<std::string, std::string>& configMocDefines) +static void SetupAutoTargetMoc(cmGeneratorTarget const* target, + std::string const& qtMajorVersion, + std::string const& config, + std::vector<std::string> const& configs, + AutogenSetup& setup) { - cmLocalGenerator* lg = target->GetLocalGenerator(); + cmLocalGenerator* localGen = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); + AddDefinitionEscaped(makefile, "_moc_skip", setup.mocSkip); AddDefinitionEscaped(makefile, "_moc_options", GetSafeProperty(target, "AUTOMOC_MOC_OPTIONS")); - AddDefinitionEscaped(makefile, "_moc_skip", mocSkipList); 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")); @@ -406,42 +434,41 @@ static void MocSetupAutoTarget( GetCompileDefinitionsAndDirectories(target, *li, configIncs, configCompileDefs); if (configIncs != incs) { - configMocIncludes[*li] = cmOutputConverter::EscapeForCMake(configIncs); + setup.configMocIncludes[*li] = configIncs; } if (configCompileDefs != compileDefs) { - configMocDefines[*li] = - cmOutputConverter::EscapeForCMake(configCompileDefs); + setup.configMocDefines[*li] = configCompileDefs; } } } // Moc executable { + std::string mocExec; std::string err; - const char* mocExec = CM_NULLPTR; + if (qtMajorVersion == "5") { - cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc"); - if (qt5Moc != CM_NULLPTR) { - mocExec = qt5Moc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt5::moc"); + if (tgt != CM_NULLPTR) { + mocExec = SafeString(tgt->ImportedGetLocation("")); } else { - err = "Qt5::moc target not found " + autogenTargetName; + err = "AUTOMOC: Qt5::moc target not found"; } } else if (qtMajorVersion == "4") { - cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc"); - if (qt4Moc != CM_NULLPTR) { - mocExec = qt4Moc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt4::moc"); + if (tgt != CM_NULLPTR) { + mocExec = SafeString(tgt->ImportedGetLocation("")); } else { - err = "Qt4::moc target not found " + autogenTargetName; + err = "AUTOMOC: Qt4::moc target not found"; } } else { - err = "The CMAKE_AUTOMOC feature supports only Qt 4 and Qt 5 "; - err += autogenTargetName; + err = "The AUTOMOC feature supports only Qt 4 and Qt 5"; } - // Add definition or error + if (err.empty()) { - AddDefinitionEscaped(makefile, "_qt_moc_executable", - mocExec ? mocExec : ""); + AddDefinitionEscaped(makefile, "_qt_moc_executable", mocExec); } else { + err += " (" + target->GetName() + ")"; cmSystemTools::Error(err.c_str()); } } @@ -455,26 +482,30 @@ static void UicGetOpts(cmGeneratorTarget const* target, optString = cmJoin(opts, ";"); } -static void UicSetupAutoTarget( - cmGeneratorTarget const* target, std::string const& qtMajorVersion, - std::string const& config, std::vector<std::string> const& configs, - std::vector<std::string> const& uicSkipList, - std::map<std::string, std::string>& configUicOptions) +static void SetupAutoTargetUic(cmGeneratorTarget const* target, + std::string const& qtMajorVersion, + std::string const& config, + std::vector<std::string> const& configs, + AutogenSetup& setup) { - cmLocalGenerator* lg = target->GetLocalGenerator(); + cmLocalGenerator* localGen = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); - AddDefinitionEscaped(makefile, "_uic_skip", uicSkipList); + AddDefinitionEscaped(makefile, "_uic_skip", setup.uicSkip); // Uic search paths { std::vector<std::string> uicSearchPaths; - cmSystemTools::ExpandListArgument( - GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"), uicSearchPaths); - const std::string srcDir = makefile->GetCurrentSourceDirectory(); - for (std::vector<std::string>::iterator it = uicSearchPaths.begin(); - it != uicSearchPaths.end(); ++it) { - *it = cmSystemTools::CollapseFullPath(*it, srcDir); + { + const std::string usp = GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"); + if (!usp.empty()) { + cmSystemTools::ExpandListArgument(usp, uicSearchPaths); + const std::string srcDir = makefile->GetCurrentSourceDirectory(); + for (std::vector<std::string>::iterator it = uicSearchPaths.begin(); + it != uicSearchPaths.end(); ++it) { + *it = cmSystemTools::CollapseFullPath(*it, srcDir); + } + } } AddDefinitionEscaped(makefile, "_uic_search_paths", uicSearchPaths); } @@ -491,8 +522,7 @@ static void UicSetupAutoTarget( std::string configUicOpts; UicGetOpts(target, *li, configUicOpts); if (configUicOpts != uicOpts) { - configUicOptions[*li] = - cmOutputConverter::EscapeForCMake(configUicOpts); + setup.configUicOptions[*li] = configUicOpts; } } } @@ -501,25 +531,25 @@ static void UicSetupAutoTarget( std::vector<std::string> uiFileFiles; std::vector<std::string> uiFileOptions; { - std::set<std::string> skipped; - skipped.insert(uicSkipList.begin(), uicSkipList.end()); - - const std::vector<cmSourceFile*> uiFilesWithOptions = - makefile->GetQtUiFilesWithOptions(); - for (std::vector<cmSourceFile*>::const_iterator fileIt = - uiFilesWithOptions.begin(); - fileIt != uiFilesWithOptions.end(); ++fileIt) { - cmSourceFile* sf = *fileIt; - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - if (skipped.insert(absFile).second) { - // The file wasn't skipped - uiFileFiles.push_back(absFile); - { - std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); - cmSystemTools::ReplaceString(opts, ";", - cmQtAutoGeneratorCommon::listSep); - uiFileOptions.push_back(opts); + const std::string uiExt = "ui"; + const std::vector<cmSourceFile*>& srcFiles = makefile->GetSourceFiles(); + for (std::vector<cmSourceFile*>::const_iterator fit = srcFiles.begin(); + fit != srcFiles.end(); ++fit) { + cmSourceFile* sf = *fit; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); + if (sf->GetExtension() == uiExt) { + // Check if the files has uic options + std::string uicOpts = sf->GetProperty("AUTOUIC_OPTIONS"); + if (!uicOpts.empty()) { + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); + // Check if file isn't skipped + if (setup.uicSkip.count(absFile) == 0) { + uiFileFiles.push_back(absFile); + cmSystemTools::ReplaceString(uicOpts, ";", + cmQtAutoGeneratorCommon::listSep); + uiFileOptions.push_back(uicOpts); + } } } } @@ -531,30 +561,30 @@ static void UicSetupAutoTarget( // Uic executable { std::string err; - const char* uicExec = CM_NULLPTR; + std::string uicExec; + if (qtMajorVersion == "5") { - cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic"); - if (qt5Uic != CM_NULLPTR) { - uicExec = qt5Uic->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt5::uic"); + if (tgt != CM_NULLPTR) { + uicExec = SafeString(tgt->ImportedGetLocation("")); } else { // Project does not use Qt5Widgets, but has AUTOUIC ON anyway } } else if (qtMajorVersion == "4") { - cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic"); - if (qt4Uic != CM_NULLPTR) { - uicExec = qt4Uic->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt4::uic"); + if (tgt != CM_NULLPTR) { + uicExec = SafeString(tgt->ImportedGetLocation("")); } else { - err = "Qt4::uic target not found " + target->GetName(); + err = "AUTOUIC: Qt4::uic target not found"; } } else { - err = "The CMAKE_AUTOUIC feature supports only Qt 4 and Qt 5 "; - err += target->GetName(); + err = "The AUTOUIC feature supports only Qt 4 and Qt 5"; } - // Add definition or error + if (err.empty()) { - AddDefinitionEscaped(makefile, "_qt_uic_executable", - uicExec ? uicExec : ""); + AddDefinitionEscaped(makefile, "_qt_uic_executable", uicExec); } else { + err += " (" + target->GetName() + ")"; cmSystemTools::Error(err.c_str()); } } @@ -564,27 +594,30 @@ static std::string RccGetExecutable(cmGeneratorTarget const* target, const std::string& qtMajorVersion) { std::string rccExec; - cmLocalGenerator* lg = target->GetLocalGenerator(); + std::string err; + + cmLocalGenerator* localGen = target->GetLocalGenerator(); if (qtMajorVersion == "5") { - cmGeneratorTarget* qt5Rcc = lg->FindGeneratorTargetToUse("Qt5::rcc"); - if (qt5Rcc != CM_NULLPTR) { - rccExec = qt5Rcc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt5::rcc"); + if (tgt != CM_NULLPTR) { + rccExec = SafeString(tgt->ImportedGetLocation("")); } else { - cmSystemTools::Error("Qt5::rcc target not found ", - target->GetName().c_str()); + err = "AUTORCC: Qt5::rcc target not found"; } } else if (qtMajorVersion == "4") { - cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc"); - if (qt4Rcc != CM_NULLPTR) { - rccExec = qt4Rcc->ImportedGetLocation(""); + cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse("Qt4::rcc"); + if (tgt != CM_NULLPTR) { + rccExec = SafeString(tgt->ImportedGetLocation("")); } else { - cmSystemTools::Error("Qt4::rcc target not found ", - target->GetName().c_str()); + err = "AUTORCC: Qt4::rcc target not found"; } } else { - cmSystemTools::Error( - "The CMAKE_AUTORCC feature supports only Qt 4 and Qt 5 ", - target->GetName().c_str()); + err = "The AUTORCC feature supports only Qt 4 and Qt 5"; + } + + if (!err.empty()) { + err += " (" + target->GetName() + ")"; + cmSystemTools::Error(err.c_str()); } return rccExec; } @@ -626,38 +659,38 @@ static void RccMergeOptions(std::vector<std::string>& opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void RccSetupAutoTarget(cmGeneratorTarget const* target, - const std::string& qtMajorVersion) +static void SetupAutoTargetRcc(cmGeneratorTarget const* target, + const std::string& qtMajorVersion, + const std::vector<cmSourceFile*>& srcFiles) { cmMakefile* makefile = target->Target->GetMakefile(); const bool qtMajorVersion5 = (qtMajorVersion == "5"); const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); - std::vector<std::string> _rcc_files; - std::vector<std::string> _rcc_inputs; + std::vector<std::string> rccFiles; + std::vector<std::string> rccInputs; std::vector<std::string> rccFileFiles; std::vector<std::string> rccFileOptions; std::vector<std::string> rccOptionsTarget; - if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) { - cmSystemTools::ExpandListArgument(opts, rccOptionsTarget); - } - std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmSystemTools::ExpandListArgument(GetSafeProperty(target, "AUTORCC_OPTIONS"), + rccOptionsTarget); + for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); if ((sf->GetExtension() == "qrc") && - !PropertyEnabled(sf, "SKIP_AUTOGEN") && - !PropertyEnabled(sf, "SKIP_AUTORCC")) { - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); + !sf->GetPropertyAsBool("SKIP_AUTOGEN") && + !sf->GetPropertyAsBool("SKIP_AUTORCC")) { + const std::string absFile = cmsys::SystemTools::GetRealPath(fPath); // qrc file - _rcc_files.push_back(absFile); + rccFiles.push_back(absFile); // qrc file entries { std::string entriesList = "{"; // Read input file list only for non generated .qrc files. - if (!PropertyEnabled(sf, "GENERATED")) { + if (!sf->GetPropertyAsBool("GENERATED")) { std::string error; std::vector<std::string> files; if (cmQtAutoGeneratorCommon::RccListInputs( @@ -668,7 +701,7 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target, } } entriesList += "}"; - _rcc_inputs.push_back(entriesList); + rccInputs.push_back(entriesList); } // rcc options for this qrc file { @@ -690,44 +723,50 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target, } AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand); - AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files); - AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs); + AddDefinitionEscaped(makefile, "_rcc_files", rccFiles); + AddDefinitionEscaped(makefile, "_rcc_inputs", rccInputs); AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles); AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions); } void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( - cmLocalGenerator* lg, cmGeneratorTarget* target) + cmLocalGenerator* localGen, cmGeneratorTarget* target) { cmMakefile* makefile = target->Target->GetMakefile(); + cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator(); // Create a custom target for running generators at buildtime const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC"); const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC"); const bool rccEnabled = target->GetPropertyAsBool("AUTORCC"); - const bool multiConfig = IsMultiConfig(target->GetGlobalGenerator()); + const bool multiConfig = AutogenMultiConfig(globalGen); const std::string autogenTargetName = GetAutogenTargetName(target); const std::string autogenBuildDir = GetAutogenTargetBuildDir(target); const std::string workingDirectory = cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory()); - const std::string qtMajorVersion = GetQtMajorVersion(target); - const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); const std::vector<std::string> suffixes = GetConfigurationSuffixes(makefile); std::set<std::string> autogenDependsSet; std::vector<std::string> autogenProvides; + bool usePRE_BUILD = false; + if (globalGen->GetName().find("Visual Studio") != std::string::npos) { + // Under VS use a PRE_BUILD event instead of a separate target to + // reduce the number of targets loaded into the IDE. + // This also works around a VS 11 bug that may skip updating the target: + // https://connect.microsoft.com/VisualStudio/feedback/details/769495 + usePRE_BUILD = true; + } + // Remove build directories on cleanup - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - autogenBuildDir.c_str(), false); + AddCleanFile(makefile, autogenBuildDir); // Remove old settings on cleanup { std::string base = GetAutogenTargetFilesDir(target); + base += "/AutogenOldSettings"; for (std::vector<std::string>::const_iterator it = suffixes.begin(); it != suffixes.end(); ++it) { - std::string fname = base + "/AutogenOldSettings" + *it + ".cmake"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fname.c_str(), - false); + AddCleanFile(makefile, base + *it + ".cmake"); } } @@ -785,25 +824,16 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( target->AddIncludeDirectory(includeDir, true); } -#if defined(_WIN32) && !defined(__CYGWIN__) - bool usePRE_BUILD = false; - cmGlobalGenerator* gg = lg->GetGlobalGenerator(); - if (gg->GetName().find("Visual Studio") != std::string::npos) { - // Under VS use a PRE_BUILD event instead of a separate target to - // reduce the number of targets loaded into the IDE. - // This also works around a VS 11 bug that may skip updating the target: - // https://connect.microsoft.com/VisualStudio/feedback/details/769495 - usePRE_BUILD = true; - } -#endif - - // Initialize autogen target dependencies - if (const char* deps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) { - std::vector<std::string> extraDepends; - cmSystemTools::ExpandListArgument(deps, extraDepends); - autogenDependsSet.insert(extraDepends.begin(), extraDepends.end()); + // Add user defined autogen target dependencies + { + const std::string deps = GetSafeProperty(target, "AUTOGEN_TARGET_DEPENDS"); + if (!deps.empty()) { + std::vector<std::string> extraDepends; + cmSystemTools::ExpandListArgument(deps, extraDepends); + autogenDependsSet.insert(extraDepends.begin(), extraDepends.end()); + } } - // Add other target dependencies autogen dependencies + // Add utility target dependencies to the autogen dependencies { const std::set<std::string>& utils = target->Target->GetUtilities(); for (std::set<std::string>::const_iterator it = utils.begin(); @@ -814,7 +844,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( } } } - // Add link library targets to the autogen dependencies + // Add link library target dependencies to the autogen dependencies { const cmTarget::LinkLibraryVectorType& libVec = target->Target->GetOriginalLinkLibraries(); @@ -826,106 +856,127 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( } } } + + // Extract relevant source files + std::vector<std::string> generatedSources; + std::vector<std::pair<std::string, bool> > qrcSources; { - cmFilePathChecksum fpathCheckSum(makefile); - // Iterate over all source files + const std::string qrcExt = "qrc"; std::vector<cmSourceFile*> srcFiles; target->GetConfigCommonSourceFiles(srcFiles); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; - if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) { - std::string const& ext = sf->GetExtension(); - // Add generated file that will be scanned by moc or uic to - // the dependencies - if (mocEnabled || uicEnabled) { - const cmSystemTools::FileFormat fileType = - cmSystemTools::GetFileFormat(ext.c_str()); - if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || - (fileType == cmSystemTools::HEADER_FILE_FORMAT)) { - if (PropertyEnabled(sf, "GENERATED")) { - if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) || - (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) { - autogenDependsSet.insert( - cmsys::SystemTools::GetRealPath(sf->GetFullPath())); -#if defined(_WIN32) && !defined(__CYGWIN__) - // Cannot use PRE_BUILD with generated files - usePRE_BUILD = false; -#endif - } + if (sf->GetPropertyAsBool("SKIP_AUTOGEN")) { + continue; + } + // sf->GetExtension() is only valid after sf->GetFullPath() ... + const std::string& fPath = sf->GetFullPath(); + const std::string& ext = sf->GetExtension(); + // Register generated files that will be scanned by moc or uic + if (mocEnabled || uicEnabled) { + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(ext.c_str()); + if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || + (fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + if (sf->GetPropertyAsBool("GENERATED")) { + if ((mocEnabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) || + (uicEnabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) { + generatedSources.push_back( + cmsys::SystemTools::GetRealPath(fPath)); } } } - // Process rcc enabled files - if (rccEnabled && (ext == "qrc") && - !PropertyEnabled(sf, "SKIP_AUTORCC")) { - const std::string absFile = - cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - - // Compose rcc output file name - { - std::string rccBuildFile = autogenBuildDir + "/"; - rccBuildFile += fpathCheckSum.getPart(absFile); - rccBuildFile += "/qrc_"; - rccBuildFile += - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); - rccBuildFile += ".cpp"; - - // Register rcc ouput file as generated - AddGeneratedSource(target, rccBuildFile, - cmQtAutoGeneratorCommon::RCC); - // Register rcc ouput file as generated by the _autogen target - autogenProvides.push_back(rccBuildFile); - } + } + // Register rcc enabled files + if (rccEnabled && (ext == qrcExt) && + !sf->GetPropertyAsBool("SKIP_AUTORCC")) { + qrcSources.push_back( + std::pair<std::string, bool>(cmsys::SystemTools::GetRealPath(fPath), + sf->GetPropertyAsBool("GENERATED"))); + } + } + // cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's + // sources meta data cache. Clear it so that OBJECT library targets that + // are AUTOGEN initialized after this target get their added + // mocs_compilation.cpp source acknowledged by this target. + target->ClearSourcesCache(); + } + + if (!generatedSources.empty()) { + for (std::vector<std::string>::const_iterator it = + generatedSources.begin(); + it != generatedSources.end(); ++it) { + autogenDependsSet.insert(*it); + } + } + + if (!qrcSources.empty()) { + const std::string qtMajorVersion = GetQtMajorVersion(target); + const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); + const cmFilePathChecksum fpathCheckSum(makefile); + for (std::vector<std::pair<std::string, bool> >::const_iterator it = + qrcSources.begin(); + it != qrcSources.end(); ++it) { + const std::string& absFile = it->first; + + // Compose rcc output file name + { + std::string rccBuildFile = autogenBuildDir + "/"; + rccBuildFile += fpathCheckSum.getPart(absFile); + rccBuildFile += "/qrc_"; + rccBuildFile += + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); + rccBuildFile += ".cpp"; + + // Register rcc ouput file as generated + AddGeneratedSource(target, rccBuildFile, cmQtAutoGeneratorCommon::RCC); + // Register rcc ouput file as generated by the _autogen target + autogenProvides.push_back(rccBuildFile); + } - if (PropertyEnabled(sf, "GENERATED")) { - // Add generated qrc file to the dependencies - autogenDependsSet.insert(absFile); + if (it->second) { + // Add generated qrc file to the dependencies + autogenDependsSet.insert(absFile); + } else { + // Run cmake again when .qrc file changes + makefile->AddCMakeDependFile(absFile); + // Add the qrc input files to the dependencies + { + std::string error; + std::vector<std::string> extraDepends; + if (cmQtAutoGeneratorCommon::RccListInputs( + qtMajorVersion, rccCommand, absFile, extraDepends, &error)) { + autogenDependsSet.insert(extraDepends.begin(), extraDepends.end()); } else { - // Run cmake again when .qrc file changes - makefile->AddCMakeDependFile(absFile); - // Add the qrc input files to the dependencies - { - std::string error; - std::vector<std::string> extraDepends; - if (cmQtAutoGeneratorCommon::RccListInputs( - qtMajorVersion, rccCommand, absFile, extraDepends, - &error)) { - autogenDependsSet.insert(extraDepends.begin(), - extraDepends.end()); - } else { - cmSystemTools::Error(error.c_str()); - } - } + cmSystemTools::Error(error.c_str()); } -#if defined(_WIN32) && !defined(__CYGWIN__) - // Cannot use PRE_BUILD because the resource files themselves - // may not be sources within the target so VS may not know the - // target needs to re-build at all. - usePRE_BUILD = false; -#endif } } } } - // cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's - // sources meta data cache. Clear it so that OBJECT library targets that - // are AUTOGEN initialized after this target get their added - // mocs_compilation.cpp source acknowledged by this target. - target->ClearSourcesCache(); - // Convert std::set to std::vector const std::vector<std::string> autogenDepends(autogenDependsSet.begin(), autogenDependsSet.end()); -#if defined(_WIN32) && !defined(__CYGWIN__) + // Disable PRE_BUILD on demand if (usePRE_BUILD) { - // If the autogen target depends on an other target don't use PRE_BUILD - for (std::vector<std::string>::const_iterator it = autogenDepends.begin(); - it != autogenDepends.end(); ++it) { - if (makefile->FindTargetToUse(*it) != CM_NULLPTR) { - usePRE_BUILD = false; - break; + if (!generatedSources.empty() || !qrcSources.empty()) { + // - Cannot use PRE_BUILD with generated files + // - Cannot use PRE_BUILD because the resource files themselves + // may not be sources within the target so VS may not know the + // target needs to re-build at all. + usePRE_BUILD = false; + } + if (usePRE_BUILD) { + // If the autogen target depends on an other target don't use PRE_BUILD + for (std::vector<std::string>::const_iterator it = + autogenDepends.begin(); + it != autogenDepends.end(); ++it) { + if (makefile->FindTargetToUse(*it) != CM_NULLPTR) { + usePRE_BUILD = false; + break; + } } } } @@ -940,31 +991,33 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); target->Target->AddPreBuildCommand(cc); - } else -#endif - { + } else { cmTarget* autogenTarget = makefile->AddUtilityCommand( autogenTargetName, true, workingDirectory.c_str(), /*byproducts=*/autogenProvides, autogenDepends, commandLines, false, autogenComment.c_str()); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); - lg->AddGeneratorTarget(gt); + localGen->AddGeneratorTarget( + new cmGeneratorTarget(autogenTarget, localGen)); - // Set target folder - const char* autogenFolder = - makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); - if (!autogenFolder) { - autogenFolder = - makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); - } - if (autogenFolder && *autogenFolder) { - autogenTarget->SetProperty("FOLDER", autogenFolder); - } else { - // inherit FOLDER property from target (#13688) - utilCopyTargetProperty(gt->Target, target->Target, "FOLDER"); + // Set autogen target FOLDER + { + const char* autogenFolder = + makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); + if (autogenFolder == CM_NULLPTR) { + autogenFolder = + makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); + } + // Inherit FOLDER property from target (#13688) + if (autogenFolder == CM_NULLPTR) { + autogenFolder = target->Target->GetProperty("FOLDER"); + } + if ((autogenFolder != CM_NULLPTR) && (*autogenFolder != '\0')) { + autogenTarget->SetProperty("FOLDER", autogenFolder); + } } + // Add autogen target to the origin target dependencies target->Target->AddUtility(autogenTargetName); } } @@ -982,54 +1035,46 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( std::string config; const std::vector<std::string> configs(GetConfigurations(makefile, &config)); - // Configurations settings buffers + // Configuration suffixes std::map<std::string, std::string> configSuffix; - std::map<std::string, std::string> configMocIncludes; - std::map<std::string, std::string> configMocDefines; - std::map<std::string, std::string> configUicOptions; - - // Configuration suffix - if (IsMultiConfig(target->GetGlobalGenerator())) { + if (AutogenMultiConfig(target->GetGlobalGenerator())) { for (std::vector<std::string>::const_iterator it = configs.begin(); it != configs.end(); ++it) { - configSuffix[*it] = cmOutputConverter::EscapeForCMake("_" + *it); + configSuffix[*it] = "_" + *it; } } + // Configurations settings buffers + AutogenSetup setup; + // Basic setup { const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC"); const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC"); const bool rccEnabled = target->GetPropertyAsBool("AUTORCC"); - const std::string autogenTargetName = GetAutogenTargetName(target); const std::string qtMajorVersion = GetQtMajorVersion(target); - - std::vector<std::string> sources; - std::vector<std::string> headers; - - if (mocEnabled || uicEnabled || rccEnabled) { - std::vector<std::string> mocSkipList; - std::vector<std::string> uicSkipList; - AcquireScanFiles(target, sources, headers, mocSkipList, uicSkipList); - if (mocEnabled) { - MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion, config, - configs, mocSkipList, configMocIncludes, - configMocDefines); - } - if (uicEnabled) { - UicSetupAutoTarget(target, qtMajorVersion, config, configs, - uicSkipList, configUicOptions); + { + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); + if (mocEnabled || uicEnabled) { + SetupAcquireScanFiles(target, mocEnabled, uicEnabled, srcFiles, setup); + if (mocEnabled) { + SetupAutoTargetMoc(target, qtMajorVersion, config, configs, setup); + } + if (uicEnabled) { + SetupAutoTargetUic(target, qtMajorVersion, config, configs, setup); + } } if (rccEnabled) { - RccSetupAutoTarget(target, qtMajorVersion); + SetupAutoTargetRcc(target, qtMajorVersion, srcFiles); } } - AddDefinitionEscaped(makefile, "_autogen_build_dir", + AddDefinitionEscaped(makefile, "_build_dir", GetAutogenTargetBuildDir(target)); AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion); - AddDefinitionEscaped(makefile, "_sources", sources); - AddDefinitionEscaped(makefile, "_headers", headers); + AddDefinitionEscaped(makefile, "_sources", setup.sources); + AddDefinitionEscaped(makefile, "_headers", setup.headers); } // Generate info file @@ -1042,8 +1087,8 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( } // Append custom definitions to info file on demand - if (!configSuffix.empty() || !configMocDefines.empty() || - !configMocIncludes.empty() || !configUicOptions.empty()) { + if (!configSuffix.empty() || !setup.configMocDefines.empty() || + !setup.configMocIncludes.empty() || !setup.configUicOptions.empty()) { // Ensure we have write permission in case .in was read-only. mode_t perm = 0; @@ -1065,29 +1110,29 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( it = configSuffix.begin(), end = configSuffix.end(); it != end; ++it) { - ofs << "set(AM_CONFIG_SUFFIX_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_CONFIG_SUFFIX_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } for (std::map<std::string, std::string>::iterator - it = configMocDefines.begin(), - end = configMocDefines.end(); + it = setup.configMocDefines.begin(), + end = setup.configMocDefines.end(); it != end; ++it) { - ofs << "set(AM_MOC_DEFINITIONS_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_MOC_DEFINITIONS_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } for (std::map<std::string, std::string>::iterator - it = configMocIncludes.begin(), - end = configMocIncludes.end(); + it = setup.configMocIncludes.begin(), + end = setup.configMocIncludes.end(); it != end; ++it) { - ofs << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_MOC_INCLUDES_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } for (std::map<std::string, std::string>::iterator - it = configUicOptions.begin(), - end = configUicOptions.end(); + it = setup.configUicOptions.begin(), + end = setup.configUicOptions.end(); it != end; ++it) { - ofs << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " << it->second - << ")\n"; + ofs << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " + << cmOutputConverter::EscapeForCMake(it->second) << ")\n"; } } else { // File open error diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h index 11f6e1e..48ae70e 100644 --- a/Source/cmQtAutoGeneratorInitializer.h +++ b/Source/cmQtAutoGeneratorInitializer.h @@ -11,7 +11,7 @@ class cmLocalGenerator; class cmQtAutoGeneratorInitializer { public: - static void InitializeAutogenTarget(cmLocalGenerator* lg, + static void InitializeAutogenTarget(cmLocalGenerator* localGen, cmGeneratorTarget* target); static void SetupAutoGenerateTarget(cmGeneratorTarget const* target); }; 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/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index baaf11a..2063c82 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -903,7 +903,7 @@ static Json::Value DumpTargetsList( std::vector<cmGeneratorTarget*> targetList; for (const auto& lgIt : generators) { - auto list = lgIt->GetGeneratorTargets(); + const auto& list = lgIt->GetGeneratorTargets(); targetList.insert(targetList.end(), list.begin(), list.end()); } std::sort(targetList.begin(), targetList.end()); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 5c4f18b..baf95c5 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -17,8 +17,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name) { this->CustomCommand = CM_NULLPTR; this->FindFullPathFailed = false; - this->IsUiFile = (".ui" == cmSystemTools::GetFilenameLastExtension( - this->Location.GetName())); } cmSourceFile::~cmSourceFile() @@ -245,13 +243,6 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) void cmSourceFile::SetProperty(const std::string& prop, const char* value) { this->Properties.SetProperty(prop, value); - - if (this->IsUiFile) { - cmMakefile const* mf = this->Location.GetMakefile(); - if (prop == "AUTOUIC_OPTIONS") { - const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this); - } - } } void cmSourceFile::AppendProperty(const std::string& prop, const char* value, diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index e739d18..91f783d 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -107,7 +107,6 @@ private: std::string ObjectLibrary; std::vector<std::string> Depends; bool FindFullPathFailed; - bool IsUiFile; bool FindFullPath(std::string* error); bool TryFullPath(const std::string& path, const std::string& ext); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c1b6f97..a116ea3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -9,6 +9,7 @@ #include <set> #include <sstream> #include <string.h> +#include <unordered_set> #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" @@ -26,7 +27,6 @@ #include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmTargetPropertyComputer.h" -#include "cm_unordered_set.hxx" #include "cmake.h" template <> @@ -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); @@ -1179,7 +1180,7 @@ const char* cmTarget::GetComputedProperty( const char* cmTarget::GetProperty(const std::string& prop) const { - static CM_UNORDERED_SET<std::string> specialProps; + static std::unordered_set<std::string> specialProps; #define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP MAKE_STATIC_PROP(LINK_LIBRARIES); MAKE_STATIC_PROP(TYPE); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1f00c01..53fd45e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -9,6 +9,7 @@ #include <map> #include <set> #include <string> +#include <unordered_map> #include <utility> #include <vector> @@ -19,7 +20,6 @@ #include "cmPropertyMap.h" #include "cmStateTypes.h" #include "cmTargetLinkLibraryType.h" -#include "cm_unordered_map.hxx" class cmGlobalGenerator; class cmMakefile; @@ -323,7 +323,7 @@ private: cmListFileBacktrace Backtrace; }; -typedef CM_UNORDERED_MAP<std::string, cmTarget> cmTargets; +typedef std::unordered_map<std::string, cmTarget> cmTargets; class cmTargetSet : public std::set<std::string> { diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx index a57bc5a..b19b024 100644 --- a/Source/cmTargetPropertyComputer.cxx +++ b/Source/cmTargetPropertyComputer.cxx @@ -4,11 +4,11 @@ #include "cmTargetPropertyComputer.h" #include <sstream> +#include <unordered_set> #include "cmMessenger.h" #include "cmPolicies.h" #include "cmStateSnapshot.h" -#include "cm_unordered_set.hxx" #include "cmake.h" bool cmTargetPropertyComputer::HandleLocationPropertyPolicy( @@ -49,7 +49,7 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty( if (cmHasLiteralPrefix(prop, "INTERFACE_")) { return true; } - static CM_UNORDERED_SET<std::string> builtIns; + static std::unordered_set<std::string> builtIns; if (builtIns.empty()) { builtIns.insert("COMPATIBLE_INTERFACE_BOOL"); builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX"); 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/Source/cm_unordered_map.hxx b/Source/cm_unordered_map.hxx deleted file mode 100644 index bf38903..0000000 --- a/Source/cm_unordered_map.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef CM_UNORDERED_MAP_HXX -#define CM_UNORDERED_MAP_HXX - -#include "cmConfigure.h" - -#if defined(CMake_HAVE_CXX_UNORDERED_MAP) - -#include <unordered_map> -#define CM_UNORDERED_MAP std::unordered_map - -#elif defined(CMAKE_BUILD_WITH_CMAKE) - -#include "cmsys/hash_map.hxx" -#define CM_UNORDERED_MAP cmsys::hash_map - -#else - -#include <map> -#define CM_UNORDERED_MAP std::map - -#endif - -#endif diff --git a/Source/cm_unordered_set.hxx b/Source/cm_unordered_set.hxx deleted file mode 100644 index dd1a9a1..0000000 --- a/Source/cm_unordered_set.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef CM_UNORDERED_SET_HXX -#define CM_UNORDERED_SET_HXX - -#include "cmConfigure.h" - -#if defined(CMake_HAVE_CXX_UNORDERED_SET) - -#include <unordered_set> -#define CM_UNORDERED_SET std::unordered_set - -#elif defined(CMAKE_BUILD_WITH_CMAKE) - -#include "cmsys/hash_set.hxx" -#define CM_UNORDERED_SET cmsys::hash_set - -#else - -#include <set> -#define CM_UNORDERED_SET std::set - -#endif - -#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6894393..4269a10 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -32,7 +32,7 @@ #include "cmGraphVizWriter.h" #include "cmVariableWatch.h" -#include "cm_unordered_map.hxx" +#include <unordered_map> #endif // only build kdevelop generator on non-windows platforms @@ -120,7 +120,7 @@ namespace { #if defined(CMAKE_BUILD_WITH_CMAKE) -typedef CM_UNORDERED_MAP<std::string, Json::Value> JsonValueMapType; +typedef std::unordered_map<std::string, Json::Value> JsonValueMapType; #endif } // namespace diff --git a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt index 607dcd3..4a41a98 100644 --- a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-C LANGUAGES C) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_C) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.c) diff --git a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt index 2dede93..1bb2b84 100644 --- a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-CXX LANGUAGES CXX) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_CXX) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.cpp) diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt index dee5c25..3872b56 100644 --- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_Fortran) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.f) diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 198bf63..81ab734 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) @@ -105,16 +114,27 @@ target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) # -- Test # Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target if(ALLOW_WRAP_CPP) + # Generate header mocs manually qtx_wrap_cpp(skipMocWrapMoc skipSource/qItemA.hpp - skipSource/qItemB.hpp) + skipSource/qItemB.hpp + skipSource/qItemC.hpp + skipSource/qItemD.hpp + ) set(skipMocSources skipMoc.cpp skipSource/qItemA.cpp skipSource/qItemB.cpp - skipSource/qItemC.cpp) + skipSource/qItemC.cpp + skipSource/qItemD.cpp + ) + # When cpp files are skipped, the hpp won't be processed either, + # unless they are mentioned in the sources - which they aren't. set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) + # When hpp files are skipped, the cpp still get processed. + set_property(SOURCE skipSource/qItemC.hpp PROPERTY SKIP_AUTOMOC ON) + set_property(SOURCE skipSource/qItemD.hpp PROPERTY SKIP_AUTOGEN ON) # AUTOMOC enabled only add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) set_property(TARGET skipMocA PROPERTY AUTOMOC ON) 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; +} diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp index 85305f5..d6b292f 100644 --- a/Tests/QtAutogen/skipMoc.cpp +++ b/Tests/QtAutogen/skipMoc.cpp @@ -2,12 +2,14 @@ #include "skipSource/qItemA.hpp" #include "skipSource/qItemB.hpp" #include "skipSource/qItemC.hpp" +#include "skipSource/qItemD.hpp" int main(int, char**) { QItemA itemA; - QItemA itemB; - QItemA itemC; + QItemB itemB; + QItemC itemC; + QItemD itemD; // Fails to link if the symbol is not present. return 0; diff --git a/Tests/QtAutogen/skipSource/qItemC.cpp b/Tests/QtAutogen/skipSource/qItemC.cpp index 700abd6..622f282 100644 --- a/Tests/QtAutogen/skipSource/qItemC.cpp +++ b/Tests/QtAutogen/skipSource/qItemC.cpp @@ -1,5 +1,17 @@ #include "qItemC.hpp" +class QItemC_Local : public QObject +{ + Q_OBJECT +public: + QItemC_Local(){}; + ~QItemC_Local(){}; +}; + void QItemC::go() { + QItemC_Local localObject; } + +// We need AUTOMOC processing +#include "qItemC.moc" diff --git a/Tests/QtAutogen/skipSource/qItemD.cpp b/Tests/QtAutogen/skipSource/qItemD.cpp new file mode 100644 index 0000000..fe0f4e4 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemD.cpp @@ -0,0 +1,17 @@ +#include "qItemD.hpp" + +class QItemD_Local : public QObject +{ + Q_OBJECT +public: + QItemD_Local(){}; + ~QItemD_Local(){}; +}; + +void QItemD::go() +{ + QItemD_Local localObject; +} + +// We need AUTOMOC processing +#include "qItemD.moc" diff --git a/Tests/QtAutogen/skipSource/qItemD.hpp b/Tests/QtAutogen/skipSource/qItemD.hpp new file mode 100644 index 0000000..99e0acb --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemD.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMD_HPP +#define QITEMD_HPP + +#include <QObject> + +class QItemD : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index c361af0..1b3dbb2 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -15,3 +15,7 @@ include(tests/${RunCMake_TEST_FILE_PREFIX}/test.cmake) set(CPACK_GENERATOR "${GENERATOR_TYPE}") include(CPack) + +if(COMMAND run_after_include_cpack) + run_after_include_cpack() +endif() diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index 7c98f69..cf7c02c 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -91,6 +91,11 @@ If test will be used for multiple generators but some of them require some generator specific commands then those commands should be added to 'test.cmake' script wrapped with 'if(GENERATOR_TYPE STREQUAL <name_of_the_generator>)'. +NOTE: In some cases (for example when testing CPackComponent.cmake functions) +the test has to run some functions after CPack.cmake is included. In such cases +a function run_after_include_cpack can be declared in test.cmake file and that +function will run after the inclusion of CPack.cmake. + build phase (optional and not available for source package tests) ----------------------------------------------------------------- diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 23ca091..349945a 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -68,18 +68,6 @@ { symbol: [ "std::__decay_and_strip<cmFindPackageCommand::PathLabel &>::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip<__gnu_cxx::__normal_iterator<const cmCTestTestHandler::cmCTestTestProperties *, std::vector<cmCTestTestHandler::cmCTestTestProperties, std::allocator<cmCTestTestHandler::cmCTestTestProperties> > > &>::__type", private, "\"cmConfigure.h\"", public ] }, - # Wrappers for headers added in TR1 / C++11 - # { include: [ "<array>", public, "\"cm_array.hxx\"", public ] }, - # { include: [ "<functional>", public, "\"cm_functional.hxx\"", public ] }, - # { include: [ "<memory>", public, "\"cm_memory.hxx\"", public ] }, - { include: [ "<unordered_map>", public, "\"cm_unordered_map.hxx\"", public ] }, - { include: [ "<unordered_set>", public, "\"cm_unordered_set.hxx\"", public ] }, - # { include: [ "<tr1/array>", public, "\"cm_array.hxx\"", public ] }, - # { include: [ "<tr1/functional>", public, "\"cm_functional.hxx\"", public ] }, - # { include: [ "<tr1/memory>", public, "\"cm_memory.hxx\"", public ] }, - { include: [ "<tr1/unordered_map>", public, "\"cm_unordered_map.hxx\"", public ] }, - { include: [ "<tr1/unordered_set>", public, "\"cm_unordered_set.hxx\"", public ] }, - # KWIML { include: [ "<stdint.h>", public, "\"cm_kwiml.h\"", public ] }, { include: [ "<inttypes.h>", public, "\"cm_kwiml.h\"", public ] }, @@ -88,14 +76,6 @@ { include: [ "<sys/stat.h>", public, "\"cm_sys_stat.h\"", public ] }, { symbol: [ "mode_t", private, "\"cm_sys_stat.h\"", public ] }, - # TODO: remove once TR1 / C++11 is required. - { include: [ "\"cmsys/hash_fun.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] }, - { include: [ "\"cmsys/hash_fun.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] }, - { include: [ "\"cmsys/hash_map.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] }, - { include: [ "\"cmsys/hash_set.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] }, - { include: [ "\"cmsys/hashtable.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] }, - { include: [ "\"cmsys/hashtable.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] }, - # Wrappers for 3rd-party libraries used from the system. { include: [ "<archive.h>", private, "\"cm_libarchive.h\"", public ] }, { include: [ "<archive_entry.h>", private, "\"cm_libarchive.h\"", public ] }, @@ -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 |