diff options
89 files changed, 1151 insertions, 356 deletions
diff --git a/Help/dev/review.rst b/Help/dev/review.rst index be02a1a..a524115 100644 --- a/Help/dev/review.rst +++ b/Help/dev/review.rst @@ -401,11 +401,14 @@ The ``Do: merge`` command accepts the following arguments: branch in the constructed merge commit message. Additionally, ``Do: merge`` extracts configuration from trailing lines -in the MR description: +in the MR description (the following have no effect if used in a MR +comment instead): * ``Topic-rename: <topic>``: substitute ``<topic>`` for the name of the MR topic branch in the constructed merge commit message. - The ``-t`` option overrides this. + It is also used in merge commits constructed by ``Do: stage``. + The ``-t`` option to a ``Do: merge`` command overrides any topic + rename set in the MR description. .. _`CMake GitLab Project Masters`: https://gitlab.kitware.com/cmake/cmake/settings/members diff --git a/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst b/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst new file mode 100644 index 0000000..198dc51 --- /dev/null +++ b/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst @@ -0,0 +1,9 @@ +CMAKE_BUILD_PARALLEL_LEVEL +-------------------------- + +Specifies the maximum number of concurrent processes to use when building +using the ``cmake --build`` command line +:ref:`Build Tool Mode <Build Tool Mode>`. + +If this variable is defined empty the native build tool's default number is +used. diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index e8b87c9..33d27af 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -11,7 +11,7 @@ cache-format file. ``-D <var>:<type>=<value>, -D <var>=<value>`` - Create a cmake cache entry. + Create or update a cmake cache entry. When cmake is first run in an empty build tree, it creates a CMakeCache.txt file and populates it with customizable settings for diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index 2d8869f..2d17bb5 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -13,6 +13,7 @@ Environment Variables that Control the Build .. toctree:: :maxdepth: 1 + /envvar/CMAKE_BUILD_PARALLEL_LEVEL /envvar/CMAKE_CONFIG_TYPE /envvar/CMAKE_MSVCIDE_RUN_PATH /envvar/CMAKE_OSX_ARCHITECTURES diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 3bfaa54..8ef4d7d 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -156,6 +156,7 @@ All Modules /module/FindMPEG2 /module/FindMPEG /module/FindMPI + /module/FindODBC /module/FindOpenACC /module/FindOpenAL /module/FindOpenCL diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 577d321..177acd4 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -159,6 +159,13 @@ following options: ``--build <dir>`` Project binary directory to be built. This is required and must be first. +``-j [<jobs>], --parallel [<jobs>]`` + The maximum number of concurrent processes to use when building. + If ``<jobs>`` is omitted the native build tool's default number is used. + + The :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment variable, if set, + specifies a default parallel level when this option is not given. + ``--target <tgt>`` Build ``<tgt>`` instead of default targets. May only be specified once. diff --git a/Help/module/FindODBC.rst b/Help/module/FindODBC.rst new file mode 100644 index 0000000..8558334 --- /dev/null +++ b/Help/module/FindODBC.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindODBC.cmake diff --git a/Help/release/dev/FindODBC-module.rst b/Help/release/dev/FindODBC-module.rst new file mode 100644 index 0000000..f270e8e --- /dev/null +++ b/Help/release/dev/FindODBC-module.rst @@ -0,0 +1,5 @@ +FindODBC-module +--------------- + +* A :module:`FindODBC` module was added to find an Open Database Connectivity + (ODBC) library. diff --git a/Help/release/dev/parallel_build_option.rst b/Help/release/dev/parallel_build_option.rst new file mode 100644 index 0000000..2451fd0 --- /dev/null +++ b/Help/release/dev/parallel_build_option.rst @@ -0,0 +1,6 @@ +parallel_build_option +--------------------- + +* The :manual:`cmake(1)` :ref:`Build Tool Mode` (``cmake --build``) gained + ``--parallel [<jobs>]`` and ``-j [<jobs>]`` options to specify a parallel + build level. They map to corresponding options of the native build tool. diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index 479493b..8e62941 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -168,7 +168,7 @@ endif() # compile a cu file into an executable if(NOT CMAKE_CUDA_LINK_EXECUTABLE) set(CMAKE_CUDA_LINK_EXECUTABLE - "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}") + "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}") endif() if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") @@ -194,11 +194,11 @@ unset(__IMPLICT_DLINK_DIRS) #These are used when linking relocatable (dc) cuda code if(NOT CMAKE_CUDA_DEVICE_LINK_LIBRARY) set(CMAKE_CUDA_DEVICE_LINK_LIBRARY - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") endif() if(NOT CMAKE_CUDA_DEVICE_LINK_EXECUTABLE) set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> <CMAKE_CUDA_LINK_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") endif() unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 0375b09..4d7123d 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -18,13 +18,24 @@ # # This module defines the following variables: # -# :: +# ``BZIP2_FOUND`` +# system has BZip2 +# ``BZIP2_INCLUDE_DIRS`` +# the BZip2 include directories +# ``BZIP2_LIBRARIES`` +# Link these to use BZip2 +# ``BZIP2_NEED_PREFIX`` +# this is set if the functions are prefixed with ``BZ2_`` +# ``BZIP2_VERSION_STRING`` +# the version of BZip2 found # -# BZIP2_FOUND - system has BZip2 -# BZIP2_INCLUDE_DIR - the BZip2 include directory -# BZIP2_LIBRARIES - Link these to use BZip2 -# BZIP2_NEED_PREFIX - this is set if the functions are prefixed with BZ2_ -# BZIP2_VERSION_STRING - the version of BZip2 found (since CMake 2.8.8) +# Cache variables +# ^^^^^^^^^^^^^^^ +# +# The following cache variables may also be set: +# +# ``BZIP2_INCLUDE_DIR`` +# the BZip2 include directory set(_BZIP2_PATHS PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]" @@ -53,6 +64,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 VERSION_VAR BZIP2_VERSION_STRING) if (BZIP2_FOUND) + set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR}) include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) cmake_push_check_state() diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 599d799..945ee0e 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -69,6 +69,7 @@ Functions doxygen_add_docs(targetName [filesOrDirs...] + [ALL] [WORKING_DIRECTORY dir] [COMMENT comment]) @@ -91,6 +92,8 @@ Functions the :command:`add_custom_target` command used to create the custom target internally. + If ALL is set, the target will be added to the default build target. + The contents of the generated ``Doxyfile`` can be customized by setting CMake variables before calling ``doxygen_add_docs()``. Any variable with a name of the form ``DOXYGEN_<tag>`` will have its value substituted for the @@ -788,7 +791,7 @@ function(doxygen_list_to_quoted_strings LIST_VARIABLE) endfunction() function(doxygen_add_docs targetName) - set(_options) + set(_options ALL) set(_one_value_args WORKING_DIRECTORY COMMENT) set(_multi_value_args) cmake_parse_arguments(_args @@ -1089,8 +1092,13 @@ doxygen_add_docs() for target ${targetName}") set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.${targetName}") configure_file("${_doxyfile_template}" "${_target_doxyfile}") + unset(_all) + if(${_args_ALL}) + set(_all ALL) + endif() + # Add the target - add_custom_target( ${targetName} VERBATIM + add_custom_target( ${targetName} ${_all} VERBATIM COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir} COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}" WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}" diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index 7eba206..8f35fc7 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -39,9 +39,16 @@ unset(_lua_include_subdirs) unset(_lua_library_names) unset(_lua_append_versions) +set(_lua_additional_paths + ~/Library/Frameworks + /Library/Frameworks + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt) # this is a function only to have all the variables inside go away automatically -function(_lua_set_version_vars) +function(_lua_get_versions) set(LUA_VERSIONS5 5.3 5.2 5.1 5.0) if (Lua_FIND_VERSION_EXACT) @@ -59,6 +66,10 @@ function(_lua_set_version_vars) list(APPEND _lua_append_versions ${subver}) endif () endforeach () + # New version -> Search for it (heuristic only! Defines in include might have changed) + if (NOT _lua_append_versions) + set(_lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}) + endif() endif () endif () else () @@ -66,22 +77,42 @@ function(_lua_set_version_vars) set(_lua_append_versions ${LUA_VERSIONS5}) endif () - list(APPEND _lua_include_subdirs "include/lua" "include") + if (LUA_Debug) + message(STATUS "Considering following Lua versions: ${_lua_append_versions}") + endif() + + set(_lua_append_versions "${_lua_append_versions}" PARENT_SCOPE) +endfunction() + +function(_lua_set_version_vars) + set(_lua_include_subdirs_raw "lua") foreach (ver IN LISTS _lua_append_versions) string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}") - list(APPEND _lua_include_subdirs - include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2} - include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2} - include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2} + list(APPEND _lua_include_subdirs_raw + lua${CMAKE_MATCH_1}${CMAKE_MATCH_2} + lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2} + lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2} ) endforeach () + # Prepend "include/" to each path directly after the path + set(_lua_include_subdirs "include") + foreach (dir IN LISTS _lua_include_subdirs_raw) + list(APPEND _lua_include_subdirs "${dir}" "include/${dir}") + endforeach () + set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE) - set(_lua_append_versions "${_lua_append_versions}" PARENT_SCOPE) endfunction(_lua_set_version_vars) -function(_lua_check_header_version _hdr_file) +function(_lua_get_header_version) + unset(LUA_VERSION_STRING PARENT_SCOPE) + set(_hdr_file "${LUA_INCLUDE_DIR}/lua.h") + + if (NOT EXISTS "${_hdr_file}") + return() + endif () + # At least 5.[012] have different ways to express the version # so all of them need to be tested. Lua 5.2 defines LUA_VERSION # and LUA_RELEASE as joined by the C preprocessor, so avoid those. @@ -111,39 +142,54 @@ function(_lua_check_header_version _hdr_file) return() endif () endforeach () -endfunction(_lua_check_header_version) - -_lua_set_version_vars() - -if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") - _lua_check_header_version("${LUA_INCLUDE_DIR}/lua.h") -endif () - -if (NOT LUA_VERSION_STRING) - foreach (subdir IN LISTS _lua_include_subdirs) - unset(LUA_INCLUDE_PREFIX CACHE) - unset(LUA_INCLUDE_PREFIX) - find_path(LUA_INCLUDE_PREFIX ${subdir}/lua.h - HINTS - ENV LUA_DIR - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - if (LUA_INCLUDE_PREFIX) - _lua_check_header_version("${LUA_INCLUDE_PREFIX}/${subdir}/lua.h") - if (LUA_VERSION_STRING) - set(LUA_INCLUDE_DIR "${LUA_INCLUDE_PREFIX}/${subdir}") +endfunction(_lua_get_header_version) + +function(_lua_find_header) + _lua_set_version_vars() + + # Initialize as local variable + set(CMAKE_IGNORE_PATH ${CMAKE_IGNORE_PATH}) + while (TRUE) + # Find the next header to test. Check each possible subdir in order + # This prefers e.g. higher versions as they are earlier in the list + # It is also consistent with previous versions of FindLua + foreach (subdir IN LISTS _lua_include_subdirs) + find_path(LUA_INCLUDE_DIR lua.h + HINTS + ENV LUA_DIR + PATH_SUFFIXES ${subdir} + PATHS ${_lua_additional_paths} + ) + if (LUA_INCLUDE_DIR) break() - endif () - endif () - endforeach () -endif () -unset(_lua_include_subdirs) + endif() + endforeach() + # Did not found header -> Fail + if (NOT LUA_INCLUDE_DIR) + return() + endif() + _lua_get_header_version() + # Found accepted version -> Ok + if (LUA_VERSION_STRING) + if (LUA_Debug) + message(STATUS "Found suitable version ${LUA_VERSION_STRING} in ${LUA_INCLUDE_DIR}/lua.h") + endif() + return() + endif() + # Found wrong version -> Ignore this path and retry + if (LUA_Debug) + message(STATUS "Ignoring unsuitable version in ${LUA_INCLUDE_DIR}") + endif() + list(APPEND CMAKE_IGNORE_PATH "${LUA_INCLUDE_DIR}") + unset(LUA_INCLUDE_DIR CACHE) + unset(LUA_INCLUDE_DIR) + unset(LUA_INCLUDE_DIR PARENT_SCOPE) + endwhile () +endfunction() + +_lua_get_versions() +_lua_find_header() +_lua_get_header_version() unset(_lua_append_versions) if (LUA_VERSION_STRING) @@ -160,13 +206,7 @@ find_library(LUA_LIBRARY HINTS ENV LUA_DIR PATH_SUFFIXES lib - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw - /opt/local - /opt/csw - /opt + PATHS ${_lua_additional_paths} ) unset(_lua_library_names) diff --git a/Modules/FindODBC.cmake b/Modules/FindODBC.cmake new file mode 100644 index 0000000..c8ca477 --- /dev/null +++ b/Modules/FindODBC.cmake @@ -0,0 +1,227 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindODBC +-------- + +Find an Open Database Connectivity (ODBC) include directory and library. + +On Windows, when building with Visual Studio, this module assumes the ODBC +library is provided by the available Windows SDK. + +On Unix, this module allows to search for ODBC library provided by +unixODBC or iODBC implementations of ODBC API. +This module reads hint about location of the config program: + +.. variable:: ODBC_CONFIG + + Location of odbc_config or iodbc-config program + +Otherwise, this module tries to find the config program, +first from unixODBC, then from iODBC. +If no config program found, this module searches for ODBC header +and library in list of known locations. + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +.. variable:: ODBC::ODBC + + Imported target for using the ODBC library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +.. variable:: ODBC_FOUND + + Set to true if ODBC library found, otherwise false or undefined. + +.. variable:: ODBC_INCLUDE_DIRS + + Paths to include directories listed in one variable for use by ODBC client. + May be empty on Windows, where the include directory corresponding to the + expected Windows SDK is already available in the compilation environment. + +.. variable:: ODBC_LIBRARIES + + Paths to libraries to linked against to use ODBC. + May just a library name on Windows, where the library directory corresponding + to the expected Windows SDK is already available in the compilation environment. + +.. variable:: ODBC_CONFIG + + Path to unixODBC or iODBC config program, if found or specified. + +Cache variables +^^^^^^^^^^^^^^^ + +For users who wish to edit and control the module behavior, this module +reads hints about search locations from the following variables: + +.. variable:: ODBC_INCLUDE_DIR + + Path to ODBC include directory with ``sql.h`` header. + +.. variable:: ODBC_LIBRARY + + Path to ODBC library to be linked. + +These variables should not be used directly by project code. + +Limitations +^^^^^^^^^^^ + +On Windows, this module does not search for iODBC. +On Unix, there is no way to prefer unixODBC over iODBC, or vice versa, +other than providing the config program location using the ``ODBC_CONFIG``. +This module does not allow to search for a specific ODBC driver. + +#]=======================================================================] + +# Define lists used internally +set(_odbc_include_paths) +set(_odbc_lib_paths) +set(_odbc_lib_names) +set(_odbc_required_libs_names) + +### Try Windows Kits ########################################################## +if(WIN32) + # List names of ODBC libraries on Windows + set(ODBC_LIBRARY odbc32.lib) + set(_odbc_lib_names odbc32;) + + # List additional libraries required to use ODBC library + if(MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(_odbc_required_libs_names odbccp32;ws2_32) + elseif(MINGW) + set(_odbc_required_libs_names odbccp32) + endif() +endif() + +### Try unixODBC or iODBC config program ###################################### +if (UNIX) + find_program(ODBC_CONFIG + NAMES odbc_config iodbc-config + DOC "Path to unixODBC or iODBC config program") + mark_as_advanced(ODBC_CONFIG) +endif() + +if (UNIX AND ODBC_CONFIG) + # unixODBC and iODBC accept unified command line options + execute_process(COMMAND ${ODBC_CONFIG} --cflags + OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${ODBC_CONFIG} --libs + OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE) + + # Collect paths of include directories from CFLAGS + separate_arguments(_cflags NATIVE_COMMAND "${_cflags}") + foreach(arg IN LISTS _cflags) + if("${arg}" MATCHES "^-I(.*)$") + list(APPEND _odbc_include_paths "${CMAKE_MATCH_1}") + endif() + endforeach() + unset(_cflags) + + # Collect paths of library names and directories from LIBS + separate_arguments(_libs NATIVE_COMMAND "${_libs}") + foreach(arg IN LISTS _libs) + if("${arg}" MATCHES "^-L(.*)$") + list(APPEND _odbc_lib_paths "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-l(.*)$") + set(_lib_name ${CMAKE_MATCH_1}) + string(REGEX MATCH "odbc" _is_odbc ${_lib_name}) + if(_is_odbc) + list(APPEND _odbc_lib_names ${_lib_name}) + else() + list(APPEND _odbc_required_libs_names ${_lib_name}) + endif() + unset(_lib_name) + endif() + endforeach() + unset(_libs) +endif() + +### Try unixODBC or iODBC in include/lib filesystems ########################## +if (UNIX AND NOT ODBC_CONFIG) + # List names of both ODBC libraries, unixODBC and iODBC + set(_odbc_lib_names odbc;iodbc;unixodbc;) +endif() + +### Find include directories ################################################## +find_path(ODBC_INCLUDE_DIR + NAMES sql.h + PATHS ${_odbc_include_paths}) + +if(NOT ODBC_INCLUDE_DIR AND WIN32) + set(ODBC_INCLUDE_DIR "") +endif() + +### Find libraries ############################################################ +if(NOT ODBC_LIBRARY) + find_library(ODBC_LIBRARY + NAMES ${_odbc_lib_names} + PATHS ${_odbc_lib_paths} + PATH_SUFFIXES odbc) + + foreach(_lib IN LISTS _odbc_required_libs_names) + find_library(_lib_path + NAMES ${_lib} + PATHS ${_odbc_lib_paths} # system parths or collected from ODBC_CONFIG + PATH_SUFFIXES odbc) + if(_lib_path) + list(APPEND _odbc_required_libs_paths ${_lib_path}) + endif() + unset(_lib_path CACHE) + endforeach() +endif() + +# Unset internal lists as no longer used +unset(_odbc_include_paths) +unset(_odbc_lib_paths) +unset(_odbc_lib_names) +unset(_odbc_required_libs_names) + +### Set result variables ###################################################### +set(_odbc_required_vars ODBC_LIBRARY) +if(NOT WIN32) + list(APPEND _odbc_required_vars ODBC_INCLUDE_DIR) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ODBC DEFAULT_MSG ${_odbc_required_vars}) + +unset(_odbc_required_vars) + +mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR) + +set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR}) +list(APPEND ODBC_LIBRARIES ${ODBC_LIBRARY}) +list(APPEND ODBC_LIBRARIES ${_odbc_required_libs_paths}) + +### Import targets ############################################################ +if(ODBC_FOUND) + if(NOT TARGET ODBC::ODBC) + if(IS_ABSOLUTE "${ODBC_LIBRARY}") + add_library(ODBC::ODBC UNKNOWN IMPORTED) + set_target_properties(ODBC::ODBC PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${ODBC_LIBRARY}") + else() + add_library(ODBC::ODBC INTERFACE IMPORTED) + set_target_properties(ODBC::ODBC PROPERTIES + IMPORTED_LIBNAME "${ODBC_LIBRARY}") + endif() + set_target_properties(ODBC::ODBC PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}") + + if(_odbc_required_libs_paths) + set_property(TARGET ODBC::ODBC APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "${_odbc_required_libs_paths}") + endif() + endif() +endif() + +unset(_odbc_required_libs_paths) diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index 423fc69..c38527c 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -28,6 +28,7 @@ if(WIN32) NAME) set(PERL_POSSIBLE_BIN_PATHS ${PERL_POSSIBLE_BIN_PATHS} "C:/Perl/bin" + "C:/Strawberry/perl/bin" [HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl\\${ActivePerl_CurrentVersion}]/bin ) endif() diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index 0c11e55..f1c1f2d 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -15,7 +15,7 @@ foreach(lib ${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}) string(APPEND __IMPLICT_LINKS " \"${lib}\"") endforeach() set(CMAKE_CUDA_LINK_EXECUTABLE - "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_LIBRARIES>${__IMPLICT_LINKS}") + "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_LIBRARIES>${__IMPLICT_LINKS}") set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ") set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ") @@ -26,7 +26,7 @@ set(CMAKE_CUDA_CREATE_SHARED_MODULE ${CMAKE_CUDA_CREATE_SHARED_LIBRARY}) set(CMAKE_CUDA_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") set(CMAKE_CUDA_LINKER_SUPPORTS_PDB ON) set(CMAKE_CUDA_LINK_EXECUTABLE - "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}") + "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}") unset(_CMAKE_VS_LINK_EXE) unset(_CMAKE_VS_LINK_EXE) @@ -51,9 +51,9 @@ endforeach() unset(__IMPLICT_DLINK_DIRS) set(CMAKE_CUDA_DEVICE_LINK_LIBRARY - "<CMAKE_CUDA_COMPILER> <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE - "<CMAKE_CUDA_COMPILER> <FLAGS> <CMAKE_CUDA_LINK_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS) unset(__IMPLICT_DLINK_FLAGS) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e689245..0080650 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 11) -set(CMake_VERSION_PATCH 20180522) +set(CMake_VERSION_PATCH 20180530) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index b2c68e7..fccbc95 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -253,9 +253,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) config = "Debug"; } int retVal = cm.GetGlobalGenerator()->Build( - this->SourceDir, this->BinaryDir, this->BuildProject, tar, output, - this->BuildMakeProgram, config, !this->BuildNoClean, false, false, - remainingTime); + cmake::NO_BUILD_PARALLEL_LEVEL, this->SourceDir, this->BinaryDir, + this->BuildProject, tar, output, this->BuildMakeProgram, config, + !this->BuildNoClean, false, false, remainingTime); out << output; // if the build failed then return if (retVal) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 26e0db9..a9b7adf 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -818,7 +818,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, // actually do the try compile now that everything is setup int res = this->Makefile->TryCompile( sourceDirectory, this->BinaryDirectory, projectName, targetName, - this->SrcFileSignature, &cmakeFlags, output); + this->SrcFileSignature, cmake::NO_BUILD_PARALLEL_LEVEL, &cmakeFlags, + output); if (erroroc) { cmSystemTools::SetErrorOccured(); } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index df288bd..9ff967c 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -29,10 +29,10 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus& inStatus) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "foreach")) { + if (lff.Name.Lower == "foreach") { // record the number of nested foreach commands this->Depth++; - } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endforeach")) { + } else if (lff.Name.Lower == "endforeach") { // if this is the endofreach for this statement if (!this->Depth) { // Remove the function blocker for this scope or bail. @@ -97,7 +97,7 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endforeach")) { + if (lff.Name.Lower == "endforeach") { std::vector<std::string> expandedArguments; mf.ExpandArguments(lff.Arguments, expandedArguments); // if the endforeach has arguments then make sure diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 774df84..67c9e9a 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -9,7 +9,6 @@ #include "cmMakefile.h" #include "cmPolicies.h" #include "cmState.h" -#include "cmSystemTools.h" // define the class for function commands class cmFunctionHelperCommand : public cmCommand @@ -128,9 +127,9 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked( { // record commands until we hit the ENDFUNCTION // at the ENDFUNCTION call we shift gears and start looking for invocations - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "function")) { + if (lff.Name.Lower == "function") { this->Depth++; - } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) { + } else if (lff.Name.Lower == "endfunction") { // if this is the endfunction for this function then execute if (!this->Depth) { // create a new command and add it to cmake @@ -157,7 +156,7 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked( bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) { + if (lff.Name.Lower == "endfunction") { std::vector<std::string> expandedArguments; mf.ExpandArguments(lff.Arguments, expandedArguments, this->GetStartingContext().FilePath.c_str()); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index d2372a7..2389103 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -51,3 +51,32 @@ void cmGlobalBorlandMakefileGenerator::GetDocumentation( entry.Name = cmGlobalBorlandMakefileGenerator::GetActualName(); entry.Brief = "Generates Borland makefiles."; } + +void cmGlobalBorlandMakefileGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int /*jobs*/, bool verbose, std::vector<std::string> const& makeOptions) +{ + this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, targetName, config, + fast, cmake::NO_BUILD_PARALLEL_LEVEL, verbose, makeOptions); +} + +void cmGlobalBorlandMakefileGenerator::PrintBuildCommandAdvice( + std::ostream& os, int jobs) const +{ + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + // Borland's make does not support parallel builds + // see http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Make + + /* clang-format off */ + os << + "Warning: Borland's make does not support parallel builds. " + "Ignoring parallel build command line option.\n"; + /* clang-format on */ + } + + this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice( + os, cmake::NO_BUILD_PARALLEL_LEVEL); +} diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 5578d76..85fee74 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -5,6 +5,8 @@ #include "cmGlobalNMakeMakefileGenerator.h" +#include <iosfwd> + /** \class cmGlobalBorlandMakefileGenerator * \brief Write a Borland makefiles. * @@ -21,7 +23,7 @@ public: } ///! Get the name for the generator. - virtual std::string GetName() const + std::string GetName() const override { return cmGlobalBorlandMakefileGenerator::GetActualName(); } @@ -31,17 +33,27 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); + cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string> const& languages, - cmMakefile*, bool optional); + void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, + bool optional) override; + + bool AllowNotParallel() const override { return false; } + bool AllowDeleteOnError() const override { return false; } + +protected: + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = + std::vector<std::string>()) override; - virtual bool AllowNotParallel() const { return false; } - virtual bool AllowDeleteOnError() const { return false; } + void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override; }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cf277d5..8a89f36 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1741,7 +1741,7 @@ void cmGlobalGenerator::CheckTargetProperties() } } -int cmGlobalGenerator::TryCompile(const std::string& srcdir, +int cmGlobalGenerator::TryCompile(int jobs, const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& target, bool fast, @@ -1782,7 +1782,7 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, } std::string config = mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); - return this->Build(srcdir, bindir, projectName, newTarget, output, "", + return this->Build(jobs, srcdir, bindir, projectName, newTarget, output, "", config, false, fast, false, this->TryCompileTimeout); } @@ -1790,13 +1790,21 @@ void cmGlobalGenerator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, - bool /*unused*/, bool /*unused*/, std::vector<std::string> const& /*unused*/) + bool /*unused*/, int /*unused*/, bool /*unused*/, + std::vector<std::string> const& /*unused*/) { makeCommand.push_back( "cmGlobalGenerator::GenerateBuildCommand not implemented"); } -int cmGlobalGenerator::Build(const std::string& /*unused*/, +void cmGlobalGenerator::PrintBuildCommandAdvice(std::ostream& /*os*/, + int /*jobs*/) const +{ + // Subclasses override this method if they e.g want to give a warning that + // they do not support certain build command line options +} + +int cmGlobalGenerator::Build(int jobs, const std::string& /*unused*/, const std::string& bindir, const std::string& projectName, const std::string& target, std::string& output, @@ -1832,7 +1840,8 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, std::vector<std::string> makeCommand; this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName, bindir, - target, config, fast, verbose, nativeOptions); + target, config, fast, jobs, verbose, + nativeOptions); // Workaround to convince VCExpress.exe to produce output. if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH && @@ -1846,7 +1855,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, if (clean) { std::vector<std::string> cleanCommand; this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName, - bindir, "clean", config, fast, verbose); + bindir, "clean", config, fast, jobs, verbose); output += "\nRun Clean Command:"; output += cmSystemTools::PrintSingleCommand(cleanCommand); output += "\n"; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 34ed5b0..62c5441 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -147,9 +147,10 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - int TryCompile(const std::string& srcdir, const std::string& bindir, - const std::string& projectName, const std::string& targetName, - bool fast, std::string& output, cmMakefile* mf); + int TryCompile(int jobs, const std::string& srcdir, + const std::string& bindir, const std::string& projectName, + const std::string& targetName, bool fast, std::string& output, + cmMakefile* mf); /** * Build a file given the following information. This is a more direct call @@ -157,7 +158,7 @@ public: * empty then all is assumed. clean indicates if a "make clean" should be * done first. */ - int Build(const std::string& srcdir, const std::string& bindir, + int Build(int jobs, const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, std::string& output, const std::string& makeProgram, const std::string& config, bool clean, bool fast, bool verbose, @@ -176,9 +177,11 @@ public: std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, - bool verbose, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()); + virtual void PrintBuildCommandAdvice(std::ostream& os, int jobs) const; + /** Generate a "cmake --build" call for a given target and config. */ std::string GenerateCMakeBuildCommand(const std::string& target, const std::string& config, diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 946ed80..f4ecff2 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -273,11 +273,18 @@ void cmGlobalGhsMultiGenerator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool /*fast*/, - bool /*verbose*/, std::vector<std::string> const& makeOptions) + int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) { makeCommand.push_back( this->SelectMakeProgram(makeProgram, this->GetGhsBuildCommand())); + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back("-parallel"); + if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back(std::to_string(jobs)); + } + } + makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 7d4b2ba..c5388ad 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -89,7 +89,7 @@ protected: std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, - bool verbose, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()); private: diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 18c45e0..0f41ea1 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -52,3 +52,29 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice( } this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); } + +void cmGlobalJOMMakefileGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions) +{ + std::vector<std::string> jomMakeOptions; + + // Since we have full control over the invocation of JOM, let us + // make it quiet. + jomMakeOptions.push_back(this->MakeSilentFlag); + jomMakeOptions.insert(jomMakeOptions.end(), makeOptions.begin(), + makeOptions.end()); + + // JOM does parallel builds by default, the -j is only needed if a specific + // number is given + // see https://github.com/qt-labs/jom/blob/v1.1.2/src/jomlib/options.cpp + if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { + jobs = cmake::NO_BUILD_PARALLEL_LEVEL; + } + + cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, targetName, config, + fast, jobs, verbose, jomMakeOptions); +} diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 2e8ee29..65f340c 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -5,6 +5,8 @@ #include "cmGlobalUnixMakefileGenerator3.h" +#include <iosfwd> + /** \class cmGlobalJOMMakefileGenerator * \brief Write a JOM makefiles. * @@ -19,7 +21,7 @@ public: return new cmGlobalGeneratorSimpleFactory<cmGlobalJOMMakefileGenerator>(); } ///! Get the name for the generator. - virtual std::string GetName() const + std::string GetName() const override { return cmGlobalJOMMakefileGenerator::GetActualName(); } @@ -34,12 +36,20 @@ public: * Try to determine system information such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string> const& languages, - cmMakefile*, bool optional); + void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, + bool optional) override; + +protected: + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = + std::vector<std::string>()) override; private: void PrintCompilerAdvice(std::ostream& os, std::string const& lang, - const char* envVar) const; + const char* envVar) const override; }; #endif diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index da683fb..eb66bd1 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -52,3 +52,40 @@ void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice( } this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); } + +void cmGlobalNMakeMakefileGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int /*jobs*/, bool verbose, std::vector<std::string> const& makeOptions) +{ + std::vector<std::string> nmakeMakeOptions; + + // Since we have full control over the invocation of nmake, let us + // make it quiet. + nmakeMakeOptions.push_back(this->MakeSilentFlag); + nmakeMakeOptions.insert(nmakeMakeOptions.end(), makeOptions.begin(), + makeOptions.end()); + + this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, targetName, config, + fast, cmake::NO_BUILD_PARALLEL_LEVEL, verbose, nmakeMakeOptions); +} + +void cmGlobalNMakeMakefileGenerator::PrintBuildCommandAdvice(std::ostream& os, + int jobs) const +{ + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + // nmake does not support parallel build level + // see https://msdn.microsoft.com/en-us/library/afyyse50.aspx + + /* clang-format off */ + os << + "Warning: NMake does not support parallel builds. " + "Ignoring parallel build command line option.\n"; + /* clang-format on */ + } + + this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice( + os, cmake::NO_BUILD_PARALLEL_LEVEL); +} diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 05ab904..4b6382e 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -5,6 +5,8 @@ #include "cmGlobalUnixMakefileGenerator3.h" +#include <iosfwd> + /** \class cmGlobalNMakeMakefileGenerator * \brief Write a NMake makefiles. * @@ -20,7 +22,7 @@ public: cmGlobalNMakeMakefileGenerator>(); } ///! Get the name for the generator. - virtual std::string GetName() const + std::string GetName() const override { return cmGlobalNMakeMakefileGenerator::GetActualName(); } @@ -39,12 +41,22 @@ public: * Try to determine system information such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string> const& languages, - cmMakefile*, bool optional); + void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, + bool optional) override; + +protected: + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = + std::vector<std::string>()) override; + + void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override; private: void PrintCompilerAdvice(std::ostream& os, std::string const& lang, - const char* envVar) const; + const char* envVar) const override; }; #endif diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c19a61c..69bc3be 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -674,7 +674,7 @@ void cmGlobalNinjaGenerator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool /*fast*/, - bool verbose, std::vector<std::string> const& makeOptions) + int jobs, bool verbose, std::vector<std::string> const& makeOptions) { makeCommand.push_back(this->SelectMakeProgram(makeProgram)); @@ -682,6 +682,12 @@ void cmGlobalNinjaGenerator::GenerateBuildCommand( makeCommand.push_back("-v"); } + if ((jobs != cmake::NO_BUILD_PARALLEL_LEVEL) && + (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL)) { + makeCommand.push_back("-j"); + makeCommand.push_back(std::to_string(jobs)); + } + makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index bfff3d9..17b9a7d 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -202,13 +202,11 @@ public: void EnableLanguage(std::vector<std::string> const& languages, cmMakefile* mf, bool optional) override; - void GenerateBuildCommand(std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, bool fast, bool verbose, - std::vector<std::string> const& makeOptions = + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()) override; // Setup target names diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index c07f10f..641b760 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -7,7 +7,6 @@ #include <sstream> #include <utility> -#include "cmAlgorithms.h" #include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" @@ -494,31 +493,33 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool fast, - bool /*verbose*/, std::vector<std::string> const& makeOptions) + int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) { + cmMakefile* mf; + if (!this->Makefiles.empty()) { + mf = this->Makefiles[0]; + } else { + cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); + snapshot.GetDirectory().SetCurrentSource( + this->CMakeInstance->GetHomeDirectory()); + snapshot.GetDirectory().SetCurrentBinary( + this->CMakeInstance->GetHomeOutputDirectory()); + snapshot.SetDefaultDefinitions(); + mf = new cmMakefile(this, snapshot); + } + makeCommand.push_back(this->SelectMakeProgram(makeProgram)); - // Since we have full control over the invocation of nmake, let us - // make it quiet. - if (cmHasLiteralPrefix(this->GetName(), "NMake Makefiles")) { - makeCommand.push_back("/NOLOGO"); + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back("-j"); + if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back(std::to_string(jobs)); + } } + makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { - cmMakefile* mf; - if (!this->Makefiles.empty()) { - mf = this->Makefiles[0]; - } else { - cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); - snapshot.GetDirectory().SetCurrentSource( - this->CMakeInstance->GetHomeDirectory()); - snapshot.GetDirectory().SetCurrentBinary( - this->CMakeInstance->GetHomeOutputDirectory()); - snapshot.SetDefaultDefinitions(); - mf = new cmMakefile(this, snapshot); - } - std::string tname = targetName; if (fast) { tname += "/fast"; @@ -528,9 +529,9 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( conv.ConvertToRelativePath(mf->GetState()->GetBinaryDirectory(), tname); cmSystemTools::ConvertToOutputSlashes(tname); makeCommand.push_back(std::move(tname)); - if (this->Makefiles.empty()) { - delete mf; - } + } + if (this->Makefiles.empty()) { + delete mf; } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index f9ce88c..097678f 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -127,13 +127,11 @@ public: std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; } // change the build command for speed - void GenerateBuildCommand(std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, bool fast, bool verbose, - std::vector<std::string> const& makeOptions = + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()) override; /** Record per-target progress information. */ diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 205e0d0..51e9ab1 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -764,7 +764,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, - bool verbose, std::vector<std::string> const& makeOptions) + int jobs, bool verbose, std::vector<std::string> const& makeOptions) { // Select the caller- or user-preferred make program, else MSBuild. std::string makeProgramSelected = @@ -805,7 +805,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( // Use devenv to build solutions containing Intel Fortran projects. cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeCommand, makeProgram, projectName, projectDir, targetName, config, - fast, verbose, makeOptions); + fast, jobs, verbose, makeOptions); return; } @@ -813,6 +813,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::string realTarget = targetName; // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD + // /m if (realTarget.empty()) { realTarget = "ALL_BUILD"; } @@ -841,6 +842,17 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(configArg); makeCommand.push_back(std::string("/p:VisualStudioVersion=") + this->GetIDEVersion()); + + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back("/m"); + } else { + makeCommand.push_back(std::string("/m:") + std::to_string(jobs)); + } + // Having msbuild.exe and cl.exe using multiple jobs is discouraged + makeCommand.push_back("/p:CL_MPCount=1"); + } + makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index f2501c2..098c8d4 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -24,13 +24,11 @@ public: bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override; bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override; - void GenerateBuildCommand(std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, bool fast, bool verbose, - std::vector<std::string> const& makeOptions = + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()) override; ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 7ff007f..158f484 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -199,7 +199,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, - bool /*verbose*/, std::vector<std::string> const& makeOptions) + int /*jobs*/, bool /*verbose*/, std::vector<std::string> const& makeOptions) { // Select the caller- or user-preferred make program, else devenv. std::string makeProgramSelected = diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 8d1bdc0..77d4a96 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -55,13 +55,11 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - void GenerateBuildCommand(std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, bool fast, bool verbose, - std::vector<std::string> const& makeOptions = + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()) override; /** diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 94cdb38..558ef15 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -7,6 +7,8 @@ #include "cmState.h" #include "cmake.h" +#include <ostream> + cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm) : cmGlobalUnixMakefileGenerator3(cm) { @@ -47,3 +49,31 @@ void cmGlobalWatcomWMakeGenerator::GetDocumentation( entry.Name = cmGlobalWatcomWMakeGenerator::GetActualName(); entry.Brief = "Generates Watcom WMake makefiles."; } + +void cmGlobalWatcomWMakeGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int /*jobs*/, bool verbose, std::vector<std::string> const& makeOptions) +{ + this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, targetName, config, + fast, cmake::NO_BUILD_PARALLEL_LEVEL, verbose, makeOptions); +} + +void cmGlobalWatcomWMakeGenerator::PrintBuildCommandAdvice(std::ostream& os, + int jobs) const +{ + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + // wmake does not support parallel build level + + /* clang-format off */ + os << + "Warning: Watcom's WMake does not support parallel builds. " + "Ignoring parallel build command line option.\n"; + /* clang-format on */ + } + + this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice( + os, cmake::NO_BUILD_PARALLEL_LEVEL); +} diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index e8b3a73..1729bf1 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -8,6 +8,7 @@ #include "cmGlobalGeneratorFactory.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include <iosfwd> #include <string> #include <vector> @@ -47,6 +48,16 @@ public: bool AllowNotParallel() const override { return false; } bool AllowDeleteOnError() const override { return false; } + +protected: + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = + std::vector<std::string>()) override; + + void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override; }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4481bdc..f69f23e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -325,7 +325,7 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, - bool /*verbose*/, std::vector<std::string> const& makeOptions) + int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) { // now build the test makeCommand.push_back( @@ -356,6 +356,14 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( } makeCommand.push_back("-configuration"); makeCommand.push_back(!config.empty() ? config : "Debug"); + + if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back("-jobs"); + if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { + makeCommand.push_back(std::to_string(jobs)); + } + } + makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 7c51177..f7f4428 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -66,13 +66,11 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - void GenerateBuildCommand(std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, bool fast, bool verbose, - std::vector<std::string> const& makeOptions = + void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector<std::string> const& makeOptions = std::vector<std::string>()) override; /** Append the subdirectory for the given configuration. */ diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 4926f22..ae4041d 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -30,9 +30,9 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus& inStatus) { // we start by recording all the functions - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "if")) { + if (lff.Name.Lower == "if") { this->ScopeDepth++; - } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endif")) { + } else if (lff.Name.Lower == "endif") { this->ScopeDepth--; // if this is the endif for this if statement, then start executing if (!this->ScopeDepth) { @@ -48,15 +48,14 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, int scopeDepth = 0; for (cmListFileFunction const& func : this->Functions) { // keep track of scope depth - if (!cmSystemTools::Strucmp(func.Name.c_str(), "if")) { + if (func.Name.Lower == "if") { scopeDepth++; } - if (!cmSystemTools::Strucmp(func.Name.c_str(), "endif")) { + if (func.Name.Lower == "endif") { scopeDepth--; } // watch for our state change - if (scopeDepth == 0 && - !cmSystemTools::Strucmp(func.Name.c_str(), "else")) { + if (scopeDepth == 0 && func.Name.Lower == "else") { if (this->ElseSeen) { cmListFileBacktrace bt = mf.GetBacktrace(func); @@ -76,8 +75,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) { mf.PrintCommandTrace(func); } - } else if (scopeDepth == 0 && - !cmSystemTools::Strucmp(func.Name.c_str(), "elseif")) { + } else if (scopeDepth == 0 && func.Name.Lower == "elseif") { if (this->ElseSeen) { cmListFileBacktrace bt = mf.GetBacktrace(func); mf.GetCMakeInstance()->IssueMessage( @@ -163,7 +161,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile&) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endif")) { + if (lff.Name.Lower == "endif") { // if the endif has arguments, then make sure // they match the arguments of the matching if if (lff.Arguments.empty() || lff.Arguments == this->Args) { diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 64e634f..b468257 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -13,6 +13,14 @@ #include <assert.h> #include <sstream> +cmCommandContext::cmCommandName& cmCommandContext::cmCommandName::operator=( + std::string const& name) +{ + this->Original = name; + this->Lower = cmSystemTools::LowerCase(name); + return *this; +} + struct cmListFileParser { cmListFileParser(cmListFile* lf, cmListFileBacktrace const& lfbt, diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 1f9e374..70f7166 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -23,11 +23,22 @@ class cmMessenger; struct cmCommandContext { - std::string Name; + struct cmCommandName + { + std::string Lower; + std::string Original; + cmCommandName() {} + cmCommandName(std::string const& name) { *this = name; } + cmCommandName& operator=(std::string const& name); + } Name; long Line; cmCommandContext() - : Name() - , Line(0) + : Line(0) + { + } + cmCommandContext(const char* name, int line) + : Name(name) + , Line(line) { } }; @@ -81,7 +92,7 @@ public: cmListFileContext lfc; lfc.FilePath = fileName; lfc.Line = lfcc.Line; - lfc.Name = lfcc.Name; + lfc.Name = lfcc.Name.Original; return lfc; } }; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 6f4b930..23d93a3 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -161,9 +161,9 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, { // record commands until we hit the ENDMACRO // at the ENDMACRO call we shift gears and start looking for invocations - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "macro")) { + if (lff.Name.Lower == "macro") { this->Depth++; - } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) { + } else if (lff.Name.Lower == "endmacro") { // if this is the endmacro for this macro then execute if (!this->Depth) { mf.AppendProperty("MACROS", this->Args[0].c_str()); @@ -191,7 +191,7 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) { + if (lff.Name.Lower == "endmacro") { std::vector<std::string> expandedArguments; mf.ExpandArguments(lff.Arguments, expandedArguments, this->GetStartingContext().FilePath.c_str()); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 33e76b2..d67d280 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -224,7 +224,7 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const { cmListFileContext lfc; - lfc.Name = cc.Name; + lfc.Name = cc.Name.Original; lfc.Line = cc.Line; lfc.FilePath = this->StateSnapshot.GetExecutionListFile(); return this->Backtrace.Push(lfc); @@ -265,7 +265,7 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const std::ostringstream msg; msg << full_path << "(" << lff.Line << "): "; - msg << lff.Name << "("; + msg << lff.Name.Original << "("; bool expand = this->GetCMakeInstance()->GetTraceExpand(); std::string temp; for (cmListFileArgument const& arg : lff.Arguments) { @@ -317,14 +317,13 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, return result; } - std::string name = lff.Name; - // Place this call on the call stack. cmMakefileCall stack_manager(this, lff, status); static_cast<void>(stack_manager); // Lookup the command prototype. - if (cmCommand* proto = this->GetState()->GetCommand(name)) { + if (cmCommand* proto = + this->GetState()->GetCommandByExactName(lff.Name.Lower)) { // Clone the prototype. std::unique_ptr<cmCommand> pcmd(proto->Clone()); pcmd->SetMakefile(this); @@ -341,7 +340,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, if (!invokeSucceeded || hadNestedError) { if (!hadNestedError) { // The command invocation requested that we report an error. - std::string const error = name + " " + pcmd->GetError(); + std::string const error = + std::string(lff.Name.Original) + " " + pcmd->GetError(); this->IssueMessage(cmake::FATAL_ERROR, error); } result = false; @@ -356,7 +356,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, } else { if (!cmSystemTools::GetFatalErrorOccured()) { std::string error = "Unknown CMake command \""; - error += lff.Name; + error += lff.Name.Original; error += "\"."; this->IssueMessage(cmake::FATAL_ERROR, error); result = false; @@ -1454,7 +1454,7 @@ void cmMakefile::Configure() bool hasVersion = false; // search for the right policy command for (cmListFileFunction const& func : listFile.Functions) { - if (cmSystemTools::LowerCase(func.Name) == "cmake_minimum_required") { + if (func.Name.Lower == "cmake_minimum_required") { hasVersion = true; break; } @@ -1481,8 +1481,7 @@ void cmMakefile::Configure() allowedCommands.insert("message"); isProblem = false; for (cmListFileFunction const& func : listFile.Functions) { - std::string name = cmSystemTools::LowerCase(func.Name); - if (allowedCommands.find(name) == allowedCommands.end()) { + if (allowedCommands.find(func.Name.Lower) == allowedCommands.end()) { isProblem = true; break; } @@ -1501,7 +1500,7 @@ void cmMakefile::Configure() bool hasProject = false; // search for a project command for (cmListFileFunction const& func : listFile.Functions) { - if (cmSystemTools::LowerCase(func.Name) == "project") { + if (func.Name.Lower == "project") { hasProject = true; break; } @@ -1509,7 +1508,7 @@ void cmMakefile::Configure() // if no project command is found, add one if (!hasProject) { cmListFileFunction project; - project.Name = "PROJECT"; + project.Name.Lower = "project"; project.Arguments.emplace_back("Project", cmListFileArgument::Unquoted, 0); listFile.Functions.insert(listFile.Functions.begin(), project); @@ -3269,7 +3268,7 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const& lang, int cmMakefile::TryCompile(const std::string& srcdir, const std::string& bindir, const std::string& projectName, - const std::string& targetName, bool fast, + const std::string& targetName, bool fast, int jobs, const std::vector<std::string>* cmakeArgs, std::string& output) { @@ -3381,7 +3380,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, // finally call the generator to actually build the resulting project int ret = this->GetGlobalGenerator()->TryCompile( - srcdir, bindir, projectName, targetName, fast, output, this); + jobs, srcdir, bindir, projectName, targetName, fast, output, this); this->IsSourceFileTryCompile = false; return ret; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 9f32c4f..ac7baae 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -102,7 +102,8 @@ public: */ int TryCompile(const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, - bool fast, const std::vector<std::string>* cmakeArgs, + bool fast, int jobs, + const std::vector<std::string>* cmakeArgs, std::string& output); bool GetIsSourceFileTryCompile() const; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a93fb11..a57be4d 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -462,13 +462,17 @@ void cmState::AddScriptedCommand(std::string const& name, cmCommand* command) cmCommand* cmState::GetCommand(std::string const& name) const { - std::string sName = cmSystemTools::LowerCase(name); + return GetCommandByExactName(cmSystemTools::LowerCase(name)); +} + +cmCommand* cmState::GetCommandByExactName(std::string const& name) const +{ std::map<std::string, cmCommand*>::const_iterator pos; - pos = this->ScriptedCommands.find(sName); + pos = this->ScriptedCommands.find(name); if (pos != this->ScriptedCommands.end()) { return pos->second; } - pos = this->BuiltinCommands.find(sName); + pos = this->BuiltinCommands.find(name); if (pos != this->BuiltinCommands.end()) { return pos->second; } diff --git a/Source/cmState.h b/Source/cmState.h index 4c6fc69..38bdfec 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -125,7 +125,11 @@ public: bool GetIsGeneratorMultiConfig() const; void SetIsGeneratorMultiConfig(bool b); + // Returns a command from its name, case insensitive, or nullptr cmCommand* GetCommand(std::string const& name) const; + // Returns a command from its name, or nullptr + cmCommand* GetCommandByExactName(std::string const& name) const; + void AddBuiltinCommand(std::string const& name, cmCommand* command); void AddDisallowedCommand(std::string const& name, cmCommand* command, cmPolicies::PolicyID policy, const char* message); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 99b8998..f3b9c84 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -42,6 +42,7 @@ struct cmVisualStudio10TargetGenerator::Elem std::ostream& S; const int Indent; bool HasElements = false; + bool HasContent = false; std::string Tag; Elem(std::ostream& s) @@ -79,8 +80,7 @@ struct cmVisualStudio10TargetGenerator::Elem } void Element(const char* tag, const std::string& val) { - Elem(*this).WriteString("<") << tag << ">" << cmVS10EscapeXML(val) << "</" - << tag << ">\n"; + Elem(*this, tag).Content(val); } Elem& Attribute(const char* an, const std::string& av) { @@ -88,14 +88,22 @@ struct cmVisualStudio10TargetGenerator::Elem return *this; } // This method for now assumes that this->Tag has been set, e.g. by calling - // StartElement(). Also, it finishes the element so it should be the last - // one called + // StartElement(). void Content(const std::string& val) { - S << ">" << cmVS10EscapeXML(val) << "</" << this->Tag << ">\n"; + if (!this->HasContent) { + this->S << ">"; + this->HasContent = true; + } + this->S << cmVS10EscapeXML(val); } - void EndElement() + ~Elem() { + // Do not emit element which has not been started + if (Tag.empty()) { + return; + } + if (HasElements) { this->WriteString("</") << this->Tag << ">"; if (this->Indent > 0) { @@ -103,6 +111,8 @@ struct cmVisualStudio10TargetGenerator::Elem } else { // special case: don't print EOL at EOF } + } else if (HasContent) { + this->S << "</" << this->Tag << ">\n"; } else { this->S << " />\n"; } @@ -397,14 +407,12 @@ void cmVisualStudio10TargetGenerator::Generate() // Require Nsight Tegra 1.6 for JCompile support. e1.Element("NsightTegraProjectRevisionNumber", "7"); } - e1.EndElement(); } if (const char* hostArch = this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) { Elem e1(e0, "PropertyGroup"); e1.Element("PreferredToolArchitecture", hostArch); - e1.EndElement(); } if (this->ProjectType != csproj) { @@ -545,28 +553,23 @@ void cmVisualStudio10TargetGenerator::Generate() e1.Element("OutputType", outputType); e1.Element("AppDesignerFolder", "Properties"); } - - e1.EndElement(); } switch (this->ProjectType) { case vcxproj: - Elem(e0, "Import") - .Attribute("Project", VS10_CXX_DEFAULT_PROPS) - .EndElement(); + Elem(e0, "Import").Attribute("Project", VS10_CXX_DEFAULT_PROPS); break; case csproj: Elem(e0, "Import") .Attribute("Project", VS10_CSharp_DEFAULT_PROPS) - .Attribute("Condition", "Exists('" VS10_CSharp_DEFAULT_PROPS "')") - .EndElement(); + .Attribute("Condition", "Exists('" VS10_CSharp_DEFAULT_PROPS "')"); break; } this->WriteProjectConfigurationValues(e0); if (this->ProjectType == vcxproj) { - Elem(e0, "Import").Attribute("Project", VS10_CXX_PROPS).EndElement(); + Elem(e0, "Import").Attribute("Project", VS10_CXX_PROPS); } { Elem e1(e0, "ImportGroup"); @@ -575,16 +578,15 @@ void cmVisualStudio10TargetGenerator::Generate() if (this->GlobalGenerator->IsCudaEnabled()) { Elem(e1, "Import") - .Attribute( - "Project", "$(VCTargetsPath)\\BuildCustomizations\\CUDA " + - this->GlobalGenerator->GetPlatformToolsetCudaString() + ".props") - .EndElement(); + .Attribute("Project", + "$(VCTargetsPath)\\BuildCustomizations\\CUDA " + + this->GlobalGenerator->GetPlatformToolsetCudaString() + + ".props"); } if (this->GlobalGenerator->IsMasmEnabled()) { Elem(e1, "Import") .Attribute("Project", - "$(VCTargetsPath)\\BuildCustomizations\\masm.props") - .EndElement(); + "$(VCTargetsPath)\\BuildCustomizations\\masm.props"); } if (this->GlobalGenerator->IsNasmEnabled()) { // Always search in the standard modules location. @@ -597,9 +599,8 @@ void cmVisualStudio10TargetGenerator::Generate() ConvertToWindowsSlash(propsLocal); this->Makefile->ConfigureFile(propsTemplate.c_str(), propsLocal.c_str(), false, true, true); - Elem(e1, "Import").Attribute("Project", propsLocal).EndElement(); + Elem(e1, "Import").Attribute("Project", propsLocal); } - e1.EndElement(); } { Elem e1(e0, "ImportGroup"); @@ -622,14 +623,12 @@ void cmVisualStudio10TargetGenerator::Generate() Elem(e1, "Import") .Attribute("Project", props) .Attribute("Condition", "exists('" + props + "')") - .Attribute("Label", "LocalAppDataPlatform") - .EndElement(); + .Attribute("Label", "LocalAppDataPlatform"); } this->WritePlatformExtensions(e1); - e1.EndElement(); } - Elem(e0, "PropertyGroup").Attribute("Label", "UserMacros").EndElement(); + Elem(e0, "PropertyGroup").Attribute("Label", "UserMacros"); this->WriteWinRTPackageCertificateKeyFile(e0); this->WritePathAndIncrementalLinkOptions(e0); this->WriteItemDefinitionGroups(e0); @@ -643,12 +642,10 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteSDKReferences(e0); switch (this->ProjectType) { case vcxproj: - Elem(e0, "Import").Attribute("Project", VS10_CXX_TARGETS).EndElement(); + Elem(e0, "Import").Attribute("Project", VS10_CXX_TARGETS); break; case csproj: - Elem(e0, "Import") - .Attribute("Project", VS10_CSharp_TARGETS) - .EndElement(); + Elem(e0, "Import").Attribute("Project", VS10_CSharp_TARGETS); break; } @@ -663,21 +660,18 @@ void cmVisualStudio10TargetGenerator::Generate() .Attribute("Project", "$(VCTargetsPath)\\BuildCustomizations\\CUDA " + this->GlobalGenerator->GetPlatformToolsetCudaString() + - ".targets") - .EndElement(); + ".targets"); } if (this->GlobalGenerator->IsMasmEnabled()) { Elem(e1, "Import") .Attribute("Project", - "$(VCTargetsPath)\\BuildCustomizations\\masm.targets") - .EndElement(); + "$(VCTargetsPath)\\BuildCustomizations\\masm.targets"); } if (this->GlobalGenerator->IsNasmEnabled()) { std::string nasmTargets = GetCMakeFilePath("Templates/MSBuild/nasm.targets"); - Elem(e1, "Import").Attribute("Project", nasmTargets).EndElement(); + Elem(e1, "Import").Attribute("Project", nasmTargets); } - e1.EndElement(); } if (this->ProjectType == csproj) { for (std::string const& c : this->Configurations) { @@ -685,7 +679,6 @@ void cmVisualStudio10TargetGenerator::Generate() e1.Attribute("Condition", "'$(Configuration)' == '" + c + "'"); e1.SetHasElements(); this->WriteEvents(e1, c); - e1.EndElement(); } // make sure custom commands are executed before build (if necessary) { @@ -698,10 +691,8 @@ void cmVisualStudio10TargetGenerator::Generate() oss << " " << "$(BuildDependsOn)\n"; e1.Element("BuildDependsOn", oss.str()); - e1.EndElement(); } } - e0.EndElement(); } if (BuildFileStream.Close()) { @@ -757,7 +748,6 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) this->WriteDotNetReference(e1, i.first, i.second, h.first); } } - e1.EndElement(); } } @@ -787,7 +777,6 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference( e2.Element("HintPath", hint); } this->WriteDotNetReferenceCustomTags(e2, ref); - e2.EndElement(); } void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( @@ -910,10 +899,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) } } } - - e2.EndElement(); } - e1.EndElement(); } } @@ -954,9 +940,7 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup(Elem& e0) } } e2.Element("SubType", "Designer"); - e2.EndElement(); } - e1.EndElement(); } } @@ -969,8 +953,7 @@ void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences(Elem& e0) .Attribute("Project", "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v" "$(TargetPlatformVersion)\\Microsoft.Cpp.WindowsPhone." - "$(TargetPlatformVersion).targets") - .EndElement(); + "$(TargetPlatformVersion).targets"); } } } @@ -993,8 +976,7 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1) Elem(e1, "Import") .Attribute("Project", tac.File) - .Attribute("Condition", oss.str()) - .EndElement(); + .Attribute("Condition", oss.str()); } } @@ -1017,9 +999,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0) Elem e2(e1, "Reference"); e2.Attribute("Include", ri); e2.Element("IsWinMDFile", "true"); - e2.EndElement(); } - e1.EndElement(); } } @@ -1034,9 +1014,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations(Elem& e0) e2.Attribute("Include", c + "|" + this->Platform); e2.Element("Configuration", c); e2.Element("Platform", this->Platform); - e2.EndElement(); } - e1.EndElement(); } void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0) @@ -1096,8 +1074,6 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0) } else if (this->NsightTegra) { this->WriteNsightTegraConfigurationValues(e1, c); } - - e1.EndElement(); } } @@ -1280,12 +1256,16 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - Elem e1(e0, "ItemGroup"); - Elem e2(e1); + std::unique_ptr<Elem> spe1; + std::unique_ptr<Elem> spe2; if (this->ProjectType != csproj) { - this->WriteSource(e2, "CustomBuild", source); - e2.SetHasElements(); + spe1 = cm::make_unique<Elem>(e0, "ItemGroup"); + spe2 = cm::make_unique<Elem>(*spe1); + this->WriteSource(*spe2, "CustomBuild", source); + spe2->SetHasElements(); } else { + Elem e1(e0, "ItemGroup"); + Elem e2(e1); std::string link; this->GetCSharpSourceLink(source, link); this->WriteSource(e2, "None", source); @@ -1293,8 +1273,6 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( if (!link.empty()) { e2.Element("Link", link); } - e2.EndElement(); - e1.EndElement(); } for (std::string const& c : this->Configurations) { cmCustomCommandGenerator ccg(command, c, lg); @@ -1326,14 +1304,10 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( this->WriteCustomRuleCSharp(e0, c, name, script, inputs.str(), outputs.str(), comment); } else { - this->WriteCustomRuleCpp(e2, c, script, inputs.str(), outputs.str(), + this->WriteCustomRuleCpp(*spe2, c, script, inputs.str(), outputs.str(), comment); } } - if (this->ProjectType != csproj) { - e2.EndElement(); - e1.EndElement(); - } } void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp( @@ -1366,10 +1340,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp( e1.S << "\n Inputs=\"" << cmVS10EscapeAttr(inputs) << "\""; e1.S << "\n Outputs=\"" << cmVS10EscapeAttr(outputs) << "\""; if (!comment.empty()) { - Elem(e1, "Exec").Attribute("Command", "echo " + comment).EndElement(); + Elem(e1, "Exec").Attribute("Command", "echo " + comment); } - Elem(e1, "Exec").Attribute("Command", script).EndElement(); - e1.EndElement(); + Elem(e1, "Exec").Attribute("Command", script); } std::string cmVisualStudio10TargetGenerator::ConvertPath( @@ -1450,26 +1423,21 @@ void cmVisualStudio10TargetGenerator::WriteGroups() Elem e2(e1, "XML"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); - e2.EndElement(); } else if (cmSystemTools::GetFilenameExtension(fileName) == ".appxmanifest") { Elem e2(e1, "AppxManifest"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); - e2.EndElement(); } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") { Elem e2(e1, "None"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); - e2.EndElement(); } else { Elem e2(e1, "Image"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); - e2.EndElement(); } } - e1.EndElement(); } std::vector<cmSourceFile const*> resxObjs; @@ -1482,9 +1450,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() Elem e2(e1, "EmbeddedResource"); e2.Attribute("Include", obj); e2.Element("Filter", "Resource Files"); - e2.EndElement(); } - e1.EndElement(); } { Elem e1(e0, "ItemGroup"); @@ -1503,7 +1469,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups() Elem e2(e1, "Filter"); e2.Attribute("Include", name); e2.Element("UniqueIdentifier", "{" + guid + "}"); - e2.EndElement(); } } @@ -1516,12 +1481,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() e2.Element("Extensions", "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;" "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms"); - e2.EndElement(); } - - e1.EndElement(); } - e0.EndElement(); } fout << '\n'; @@ -1586,9 +1547,7 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources( if (!filter.empty()) { e2.Element("Filter", filter); } - e2.EndElement(); } - e1.EndElement(); } void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1, @@ -1603,7 +1562,6 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1, std::string xamlFileName = fileName.substr(0, fileName.find_last_of(".")); e2.Element("DependentUpon", xamlFileName); } - e2.EndElement(); } void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, @@ -1878,7 +1836,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, // write source file specific tags this->WriteCSharpSourceProperties(e2, sourceFileTags); } - e2.EndElement(); } void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, @@ -2034,15 +1991,12 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) if (!exclude_configs.empty()) { this->WriteExcludeFromBuild(e2, exclude_configs); } - e2.EndElement(); } } if (this->IsMissingFiles) { this->WriteMissingFiles(e1); } - - e1.EndElement(); } void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( @@ -2345,7 +2299,6 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( this->OutputLinkIncremental(e1, config); } } - e1.EndElement(); } void cmVisualStudio10TargetGenerator::OutputLinkIncremental( @@ -2641,7 +2594,6 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( if (!clOptions.IsDebug()) { Elem e3(e2, "DebugInformationFormat"); e3.SetHasElements(); - e3.EndElement(); } // Specify the compiler program database file if configured. @@ -2663,8 +2615,6 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( e2.Element("AdditionalUsingDirectories", dirs); } } - - e2.EndElement(); } bool cmVisualStudio10TargetGenerator::ComputeRcOptions() @@ -2718,8 +2668,6 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions( rcOptions.OutputAdditionalIncludeDirectories("RC"); rcOptions.PrependInheritedString("AdditionalOptions"); rcOptions.OutputFlagMap(); - - e2.EndElement(); } bool cmVisualStudio10TargetGenerator::ComputeCudaOptions() @@ -2866,8 +2814,6 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions( cudaOptions.OutputPreprocessorDefinitions("CUDA"); cudaOptions.PrependInheritedString("AdditionalOptions"); cudaOptions.OutputFlagMap(); - - e2.EndElement(); } bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions() @@ -2935,7 +2881,6 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions( Elem e2(e1, "CudaLink"); OptionsHelper cudaLinkOptions(*(this->CudaLinkOptions[configName]), e2); cudaLinkOptions.OutputFlagMap(); - e2.EndElement(); } bool cmVisualStudio10TargetGenerator::ComputeMasmOptions() @@ -2991,8 +2936,6 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions( masmOptions.OutputAdditionalIncludeDirectories("ASM_MASM"); masmOptions.PrependInheritedString("AdditionalOptions"); masmOptions.OutputFlagMap(); - - e2.EndElement(); } bool cmVisualStudio10TargetGenerator::ComputeNasmOptions() @@ -3052,8 +2995,6 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions( // Preprocessor definitions and includes are shared with clOptions. OptionsHelper clOptions(*(this->ClOptions[configName]), e2); clOptions.OutputPreprocessorDefinitions("ASM_NASM"); - - e2.EndElement(); } void cmVisualStudio10TargetGenerator::WriteLibOptions( @@ -3076,7 +3017,6 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( OptionsHelper oh(libOptions, e2); oh.PrependInheritedString("AdditionalOptions"); oh.OutputFlagMap(); - e2.EndElement(); } // We cannot generate metadata for static libraries. WindowsPhone @@ -3086,7 +3026,6 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( this->GlobalGenerator->TargetsWindowsStore()) { Elem e2(e1, "Link"); e2.Element("GenerateWindowsMetadata", "false"); - e2.EndElement(); } } @@ -3110,7 +3049,6 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions( } Elem e2(e1, "Manifest"); e2.Element("AdditionalManifestFiles", oss.str()); - e2.EndElement(); } } @@ -3215,8 +3153,6 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( e2.Element("AdditionalOptions", std::string(antAdditionalOptions) + " %(AdditionalOptions)"); } - - e2.EndElement(); } bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() @@ -3513,14 +3449,12 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions( OptionsHelper linkOptions(*(this->LinkOptions[config]), e2); linkOptions.PrependInheritedString("AdditionalOptions"); linkOptions.OutputFlagMap(); - e2.EndElement(); } if (!this->GlobalGenerator->NeedLinkLibraryDependencies( this->GeneratorTarget)) { Elem e2(e1, "ProjectReference"); e2.Element("LinkLibraryDependencies", "false"); - e2.EndElement(); } } @@ -3646,7 +3580,6 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions( e2.Element("TypeLibraryName", "%(Filename).tlb"); e2.Element("InterfaceIdentifierFileName", "%(Filename)_i.c"); e2.Element("ProxyFileName", "%(Filename)_p.c"); - e2.EndElement(); } void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups(Elem& e0) @@ -3685,7 +3618,6 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups(Elem& e0) this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { this->WriteAntBuildOptions(e1, c); } - e1.EndElement(); } } @@ -3739,7 +3671,6 @@ void cmVisualStudio10TargetGenerator::WriteEvent( Elem e2(e1, name); e2.Element("Message", comment); e2.Element("Command", script); - e2.EndElement(); } else { std::string strippedComment = comment; strippedComment.erase( @@ -3816,9 +3747,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) e2.Element("CopyToOutputDirectory", "Never"); } } - e2.EndElement(); } - e1.EndElement(); } void cmVisualStudio10TargetGenerator::WritePlatformExtensions(Elem& e1) @@ -3855,7 +3784,6 @@ void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension( Elem e2(e1, "Import"); e2.Attribute("Project", s); e2.Attribute("Condition", "exists('" + s + "')"); - e2.EndElement(); } void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) @@ -3869,7 +3797,7 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) e1.StartElement("ItemGroup"); hasWrittenItemGroup = true; for (std::string const& ri : sdkReferences) { - Elem(e1, "SDKReference").Attribute("Include", ri).EndElement(); + Elem(e1, "SDKReference").Attribute("Include", ri); } } @@ -3887,7 +3815,6 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) iotExtensionsVersion) { if (!hasWrittenItemGroup) { e1.StartElement("ItemGroup"); - hasWrittenItemGroup = true; } if (desktopExtensionsVersion) { this->WriteSingleSDKReference(e1, "WindowsDesktop", @@ -3902,18 +3829,13 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) } } } - - if (hasWrittenItemGroup) { - e1.EndElement(); - } } void cmVisualStudio10TargetGenerator::WriteSingleSDKReference( Elem& e1, std::string const& extension, std::string const& version) { Elem(e1, "SDKReference") - .Attribute("Include", extension + ", Version=" + version) - .EndElement(); + .Attribute("Include", extension + ", Version=" + version); } void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( @@ -3963,7 +3885,6 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( if (!thumb.empty()) { e1.Element("PackageCertificateThumbprint", thumb); } - e1.EndElement(); } else if (!pfxFile.empty()) { Elem e1(e0, "PropertyGroup"); e1.Element("PackageCertificateKeyFile", pfxFile); @@ -3971,7 +3892,6 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( if (!thumb.empty()) { e1.Element("PackageCertificateThumbprint", thumb); } - e1.EndElement(); } } } @@ -4207,23 +4127,24 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) std::string sourceFile = this->ConvertPath(manifestFile, false); ConvertToWindowsSlash(sourceFile); - Elem e2(e1, "Xml"); - e2.Attribute("Include", sourceFile); - e2.Element("SubType", "Designer"); - e2.EndElement(); + { + Elem e2(e1, "Xml"); + e2.Attribute("Include", sourceFile); + e2.Element("SubType", "Designer"); + } this->AddedFiles.push_back(sourceFile); std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo, false); ConvertToWindowsSlash(smallLogo); - Elem(e1, "Image").Attribute("Include", smallLogo).EndElement(); + Elem(e1, "Image").Attribute("Include", smallLogo); this->AddedFiles.push_back(smallLogo); std::string logo = this->DefaultArtifactDir + "/Logo.png"; cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); ConvertToWindowsSlash(logo); - Elem(e1, "Image").Attribute("Include", logo).EndElement(); + Elem(e1, "Image").Attribute("Include", logo); this->AddedFiles.push_back(logo); std::string applicationIcon = @@ -4231,7 +4152,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) cmSystemTools::CopyAFile(templateFolder + "/ApplicationIcon.png", applicationIcon, false); ConvertToWindowsSlash(applicationIcon); - Elem(e1, "Image").Attribute("Include", applicationIcon).EndElement(); + Elem(e1, "Image").Attribute("Include", applicationIcon); this->AddedFiles.push_back(applicationIcon); } @@ -4482,44 +4403,45 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string sourceFile = this->ConvertPath(manifestFile, false); ConvertToWindowsSlash(sourceFile); - Elem e2(e1, "AppxManifest"); - e2.Attribute("Include", sourceFile); - e2.Element("SubType", "Designer"); - e2.EndElement(); + { + Elem e2(e1, "AppxManifest"); + e2.Attribute("Include", sourceFile); + e2.Element("SubType", "Designer"); + } this->AddedFiles.push_back(sourceFile); std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo, false); ConvertToWindowsSlash(smallLogo); - Elem(e1, "Image").Attribute("Include", smallLogo).EndElement(); + Elem(e1, "Image").Attribute("Include", smallLogo); this->AddedFiles.push_back(smallLogo); std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png"; cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", smallLogo44, false); ConvertToWindowsSlash(smallLogo44); - Elem(e1, "Image").Attribute("Include", smallLogo44).EndElement(); + Elem(e1, "Image").Attribute("Include", smallLogo44); this->AddedFiles.push_back(smallLogo44); std::string logo = this->DefaultArtifactDir + "/Logo.png"; cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); ConvertToWindowsSlash(logo); - Elem(e1, "Image").Attribute("Include", logo).EndElement(); + Elem(e1, "Image").Attribute("Include", logo); this->AddedFiles.push_back(logo); std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png"; cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png", storeLogo, false); ConvertToWindowsSlash(storeLogo); - Elem(e1, "Image").Attribute("Include", storeLogo).EndElement(); + Elem(e1, "Image").Attribute("Include", storeLogo); this->AddedFiles.push_back(storeLogo); std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png"; cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png", splashScreen, false); ConvertToWindowsSlash(splashScreen); - Elem(e1, "Image").Attribute("Include", splashScreen).EndElement(); + Elem(e1, "Image").Attribute("Include", splashScreen); this->AddedFiles.push_back(splashScreen); if (this->AddedDefaultCertificate) { @@ -4527,7 +4449,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string keyFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx"; ConvertToWindowsSlash(keyFile); - Elem(e1, "None").Attribute("Include", keyFile).EndElement(); + Elem(e1, "None").Attribute("Include", keyFile); } } diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index a080034..d5bcfc2 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -28,10 +28,10 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus& inStatus) { // at end of for each execute recorded commands - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "while")) { + if (lff.Name.Lower == "while") { // record the number of while commands past this one this->Depth++; - } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) { + } else if (lff.Name.Lower == "endwhile") { // if this is the endwhile for this while loop then execute if (!this->Depth) { // Remove the function blocker for this scope or bail. @@ -117,7 +117,7 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile&) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) { + if (lff.Name.Lower == "endwhile") { // if the endwhile has arguments, then make sure // they match the arguments of the matching while if (lff.Arguments.empty() || lff.Arguments == this->Args) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5bae4e7..801d52d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2398,7 +2398,7 @@ cmMessenger* cmake::GetMessenger() const return this->Messenger; } -int cmake::Build(const std::string& dir, const std::string& target, +int cmake::Build(int jobs, const std::string& dir, const std::string& target, const std::string& config, const std::vector<std::string>& nativeOptions, bool clean) { @@ -2508,7 +2508,9 @@ int cmake::Build(const std::string& dir, const std::string& target, } #endif - return gen->Build("", dir, projName, target, output, "", config, clean, + gen->PrintBuildCommandAdvice(std::cerr, jobs); + + return gen->Build(jobs, "", dir, projName, target, output, "", config, clean, false, verbose, cmDuration::zero(), cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions); } diff --git a/Source/cmake.h b/Source/cmake.h index 63dbe9f..53c2f45 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -119,6 +119,9 @@ public: typedef std::map<std::string, cmInstalledFile> InstalledFilesMap; + static const int NO_BUILD_PARALLEL_LEVEL = -1; + static const int DEFAULT_BUILD_PARALLEL_LEVEL = 0; + /// Default constructor cmake(Role role); /// Destructor @@ -430,7 +433,7 @@ public: cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const; ///! run the --build option - int Build(const std::string& dir, const std::string& target, + int Build(int jobs, const std::string& dir, const std::string& target, const std::string& config, const std::vector<std::string>& nativeOptions, bool clean); @@ -550,7 +553,7 @@ private: #define CMAKE_STANDARD_OPTIONS_TABLE \ { "-C <initial-cache>", "Pre-load a script to populate the cache." }, \ - { "-D <var>[:<type>]=<value>", "Create a cmake cache entry." }, \ + { "-D <var>[:<type>]=<value>", "Create or update a cmake cache entry." }, \ { "-U <globbing_expr>", "Remove matching entries from CMake cache." }, \ { "-G <generator-name>", "Specify a build system generator." }, \ { "-T <toolset-name>", \ diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index b185a1b..9c9f65c 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -22,6 +22,8 @@ #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) #include "cmsys/ConsoleBuf.hxx" #endif + +#include <ctype.h> #include <iostream> #include <string.h> #include <string> @@ -49,6 +51,12 @@ static const char* cmDocumentationUsageNote[][2] = { #define CMAKE_BUILD_OPTIONS \ " <dir> = Project binary directory to be built.\n" \ + " -j [<jobs>] --parallel [<jobs>] = Build in parallel using\n" \ + " the given number of jobs. If <jobs> is omitted\n" \ + " the native build tool's default number is used.\n" \ + " The CMAKE_BUILD_PARALLEL_LEVEL environment variable\n" \ + " specifies a default parallel level when this option\n" \ + " is not given.\n" \ " --target <tgt> = Build <tgt> instead of default targets.\n" \ " May only be specified once.\n" \ " --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \ @@ -338,6 +346,7 @@ static int do_build(int ac, char const* const* av) std::cerr << "This cmake does not support --build\n"; return -1; #else + int jobs = cmake::NO_BUILD_PARALLEL_LEVEL; std::string target; std::string config = "Debug"; std::string dir; @@ -348,6 +357,7 @@ static int do_build(int ac, char const* const* av) enum Doing { DoingNone, + DoingJobs, DoingDir, DoingTarget, DoingConfig, @@ -357,6 +367,13 @@ static int do_build(int ac, char const* const* av) for (int i = 2; i < ac; ++i) { if (doing == DoingNative) { nativeOptions.push_back(av[i]); + } else if ((strcmp(av[i], "-j") == 0) || + (strcmp(av[i], "--parallel") == 0)) { + jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; + /* does the next argument start with a number? */ + if ((i + 1 < ac) && (isdigit(*av[i + 1]))) { + doing = DoingJobs; + } } else if (strcmp(av[i], "--target") == 0) { if (!hasTarget) { doing = DoingTarget; @@ -377,6 +394,18 @@ static int do_build(int ac, char const* const* av) doing = DoingNative; } else { switch (doing) { + case DoingJobs: { + unsigned long numJobs = 0; + if (cmSystemTools::StringToULong(av[i], &numJobs)) { + jobs = int(numJobs); + doing = DoingNone; + } else { + std::cerr << "'" << av[i - 1] << "' invalid number '" << av[i] + << "' given.\n\n"; + dir.clear(); + break; + } + } break; case DoingDir: dir = cmSystemTools::CollapseFullPath(av[i]); doing = DoingNone; @@ -396,6 +425,25 @@ static int do_build(int ac, char const* const* av) } } } + + if (jobs == cmake::NO_BUILD_PARALLEL_LEVEL) { + std::string parallel; + if (cmSystemTools::GetEnv("CMAKE_BUILD_PARALLEL_LEVEL", parallel)) { + if (parallel.empty()) { + jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; + } else { + unsigned long numJobs = 0; + if (cmSystemTools::StringToULong(parallel.c_str(), &numJobs)) { + jobs = int(numJobs); + } else { + std::cerr << "'CMAKE_BUILD_PARALLEL_LEVEL' environment variable\n" + << "invalid number '" << parallel << "' given.\n\n"; + dir.clear(); + } + } + } + } + if (dir.empty()) { /* clang-format off */ std::cerr << @@ -410,7 +458,7 @@ static int do_build(int ac, char const* const* av) cmake cm(cmake::RoleInternal); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); cm.SetProgressCallback(cmakemainProgressCallback, &cm); - return cm.Build(dir, target, config, nativeOptions, clean); + return cm.Build(jobs, dir, target, config, nativeOptions, clean); #endif } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index fe8f2cc..0e94388 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1438,6 +1438,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindLTTngUST) endif() + if(CMake_TEST_FindODBC) + add_subdirectory(FindODBC) + endif() + if(CMake_TEST_FindOpenCL) add_subdirectory(FindOpenCL) endif() diff --git a/Tests/FindDoxygen/AllTarget/CMakeLists.txt b/Tests/FindDoxygen/AllTarget/CMakeLists.txt new file mode 100644 index 0000000..69aa518 --- /dev/null +++ b/Tests/FindDoxygen/AllTarget/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE) +enable_testing() + +find_package(Doxygen REQUIRED) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp [[ +/** + * \file + * \brief One C++ file w/ sample Doxygen comment just to produce any docs... + */ +]]) + +set(DOXYGEN_OUTPUT_DIRECTORY outDirWithout) +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}) +doxygen_add_docs(docsNoAll ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) + +set(DOXYGEN_OUTPUT_DIRECTORY outDirWith) +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}) +doxygen_add_docs(docsWithAll ALL ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) + +# Define tests cases that check whether targets were built +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dirExists.cmake [[ +cmake_minimum_required(VERSION 3.11) +if(NOT EXISTS ${dirName}) + message(FATAL_ERROR "Directory does not exist: ${dirName}") +endif() +]]) + +add_test(NAME checkWith COMMAND + ${CMAKE_COMMAND} + -D dirName=${CMAKE_CURRENT_BINARY_DIR}/outDirWith + -P dirExists.cmake +) +add_test(NAME checkWithout COMMAND + ${CMAKE_COMMAND} + -D dirName=${CMAKE_CURRENT_BINARY_DIR}/outDirWithout + -P dirExists.cmake +) +set_tests_properties(checkWithout PROPERTIES + WILL_FAIL TRUE +) diff --git a/Tests/FindDoxygen/CMakeLists.txt b/Tests/FindDoxygen/CMakeLists.txt index 69b9eed..7ce98d5 100644 --- a/Tests/FindDoxygen/CMakeLists.txt +++ b/Tests/FindDoxygen/CMakeLists.txt @@ -18,6 +18,16 @@ add_test(NAME FindDoxygen.QuotingTest COMMAND --build-options ${build_options} ) +add_test(NAME FindDoxygen.AllTarget COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindDoxygen/AllTarget" + "${CMake_BINARY_DIR}/Tests/FindDoxygen/AllTarget" + ${build_generator_args} + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> +) + if(CMake_TEST_FindDoxygen_Dot) add_test(NAME FindDoxygen.DotComponentTest COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> diff --git a/Tests/FindODBC/CMakeLists.txt b/Tests/FindODBC/CMakeLists.txt new file mode 100644 index 0000000..6a81090 --- /dev/null +++ b/Tests/FindODBC/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindODBC.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindODBC/Test" + "${CMake_BINARY_DIR}/Tests/FindODBC/Test" + ${build_generator_args} + --build-project TestFindODBC + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindODBC/Test/CMakeLists.txt b/Tests/FindODBC/Test/CMakeLists.txt new file mode 100644 index 0000000..a20c0f7 --- /dev/null +++ b/Tests/FindODBC/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindODBC C) +include(CTest) + +find_package(ODBC) + +add_executable(test_odbc_tgt main.c) +target_link_libraries(test_odbc_tgt ODBC::ODBC) +add_test(NAME test_odbc_tgt COMMAND test_odbc_tgt) + +add_executable(test_odbc_var main.c) +target_include_directories(test_odbc_var PRIVATE ${ODBC_INCLUDE_DIRS}) +target_link_libraries(test_odbc_var PRIVATE ${ODBC_LIBRARIES}) +add_test(NAME test_odbc_var COMMAND test_odbc_var) diff --git a/Tests/FindODBC/Test/main.c b/Tests/FindODBC/Test/main.c new file mode 100644 index 0000000..917167b --- /dev/null +++ b/Tests/FindODBC/Test/main.c @@ -0,0 +1,12 @@ +#ifdef WIN32 +#include <windows.h> +#endif +#include <sql.h> + +int main() +{ + SQLHENV env; + SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); + SQLFreeHandle(SQL_HANDLE_ENV, env); + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 690c5b4..bb46144 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -152,6 +152,7 @@ add_RunCMake_test(ExternalData) add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) add_RunCMake_test(FindBoost) +add_RunCMake_test(FindLua) add_RunCMake_test(FindOpenGL) if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom") add_RunCMake_test(GenerateExportHeader) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt new file mode 100644 index 0000000..e73d760 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt @@ -0,0 +1,3 @@ +^'--parallel' invalid number '12ab' given\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt new file mode 100644 index 0000000..c810087 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt @@ -0,0 +1,3 @@ +^'-j' invalid number '12ab' given\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index d8dbeec..3bb2a89 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -59,6 +59,29 @@ function(run_BuildDir) ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget) run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3) + run_cmake_command(BuildDir--build-jobs-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 12ab) + run_cmake_command(BuildDir--build-jobs-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 2) + run_cmake_command(BuildDir--build-jobs-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 2 --target CustomTarget) + run_cmake_command(BuildDir--build--parallel-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 12ab) + run_cmake_command(BuildDir--build--parallel-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 2) + run_cmake_command(BuildDir--build--parallel-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 2 --target CustomTarget) + # No default jobs for Xcode and FreeBSD build command + if(NOT RunCMake_GENERATOR MATCHES "Xcode" AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + run_cmake_command(BuildDir--build-jobs-no-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j) + run_cmake_command(BuildDir--build-jobs-no-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j --target CustomTarget) + run_cmake_command(BuildDir--build--parallel-no-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel) + run_cmake_command(BuildDir--build--parallel-no-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel --target CustomTarget) + endif() endfunction() run_BuildDir() diff --git a/Tests/RunCMake/FindLua/CMakeLists.txt b/Tests/RunCMake/FindLua/CMakeLists.txt new file mode 100644 index 0000000..a2c4d98 --- /dev/null +++ b/Tests/RunCMake/FindLua/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.4) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindLua/FindLuaTest.cmake b/Tests/RunCMake/FindLua/FindLuaTest.cmake new file mode 100644 index 0000000..610d544 --- /dev/null +++ b/Tests/RunCMake/FindLua/FindLuaTest.cmake @@ -0,0 +1,87 @@ +unset(VERSION) + +# Ignore all default paths for this test to avoid finding system Lua +set(CMAKE_INCLUDE_PATH ) +set(CMAKE_PREFIX_PATH ) +set(CMAKE_FRAMEWORK_PATH ) + +set(ENV{CMAKE_INCLUDE_PATH} ) +set(ENV{CMAKE_PREFIX_PATH} ) +set(ENV{CMAKE_FRAMEWORK_PATH} ) + +set(ENV{PATH} ) +set(ENV{INCLUDE} ) + +set(CMAKE_SYSTEM_INCLUDE_PATH ) +set(CMAKE_SYSTEM_PREFIX_PATH ) +set(CMAKE_SYSTEM_FRAMEWORK_PATH ) + +function(require_found path version) + find_package(Lua ${VERSION} QUIET) + if(NOT "${LUA_INCLUDE_DIR}" STREQUAL "${path}") + message(FATAL_ERROR "LUA_INCLUDE_PATH != path: '${LUA_INCLUDE_DIR}' != '${path}'") + endif() + if(NOT LUA_VERSION_STRING MATCHES "^${version}\.[0-9]$") + message(FATAL_ERROR "Wrong versionfound in '${LUA_INCLUDE_DIR}': ${LUA_VERSION_STRING} != ${version}") + endif() +endfunction() + +# Use functions for scoping and better error messages +function(require_find path version) + unset(LUA_INCLUDE_DIR CACHE) + require_found(${lua_path} ${version}) +endfunction() + +function(test_prefix_path path lua_path version) + set(CMAKE_PREFIX_PATH ${path}) + require_find(lua_path ${version}) +endfunction() + +function(test_include_path path lua_path version) + set(CMAKE_INCLUDE_PATH ${path}) + require_find(lua_path ${version}) +endfunction() + +function(test_env_path path lua_path version) + set(ENV{LUA_DIR} ${path}) + require_find(lua_path ${version}) + unset(ENV{LUA_DIR}) +endfunction() + +function(test_path prefix_path lua_path version) + # Shortcut: Make paths relative to current list dir + set(prefix_path ${CMAKE_CURRENT_LIST_DIR}/${prefix_path}) + set(lua_path ${CMAKE_CURRENT_LIST_DIR}/${lua_path}) + + test_prefix_path(${prefix_path} ${lua_path} ${version}) + test_include_path(${prefix_path}/include ${lua_path} ${version}) + test_env_path(${prefix_path} ${lua_path} ${version}) +endfunction() + +# Simple test +test_path(prefix1 prefix1/include 5.3) +# Find highest version +test_path(prefix2 prefix2/include/lua5.3 5.3) +foreach(ver 5.3 5.2 5.1) + # At least X or X.0 -> Highest + set(VERSION "${ver}") + test_path(prefix2 prefix2/include/lua5.3 5.3) + set(VERSION "${ver}.0") + test_path(prefix2 prefix2/include/lua5.3 5.3) + # Exactly X/X.0 + set(VERSION "${ver}" EXACT) + test_path(prefix2 prefix2/include/lua${ver} ${ver}) + set(VERSION "${ver}.0" EXACT) + test_path(prefix2 prefix2/include/lua${ver} ${ver}) +endforeach() + +# Find unknown version +set(VERSION "5.9") +test_path(prefix2 prefix2/include/lua5.9 5.9) +set(VERSION "5.9" EXACT) +test_path(prefix2 prefix2/include/lua5.9 5.9) + +# Set LUA_INCLUDE_DIR (non-cache) to unsuitable version +set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/prefix2/include/lua5.2) +set(VERSION "5.1" EXACT) +test_path(prefix2 prefix2/include/lua5.1 5.1) diff --git a/Tests/RunCMake/FindLua/RunCMakeTest.cmake b/Tests/RunCMake/FindLua/RunCMakeTest.cmake new file mode 100644 index 0000000..3f18033 --- /dev/null +++ b/Tests/RunCMake/FindLua/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(FindLuaTest) diff --git a/Tests/RunCMake/FindLua/prefix1/include/lua.h b/Tests/RunCMake/FindLua/prefix1/include/lua.h new file mode 100644 index 0000000..d33434a --- /dev/null +++ b/Tests/RunCMake/FindLua/prefix1/include/lua.h @@ -0,0 +1,8 @@ + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "3" +#define LUA_VERSION_NUM 503 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h new file mode 100644 index 0000000..661e62c --- /dev/null +++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h @@ -0,0 +1,8 @@ + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "1" +#define LUA_VERSION_NUM 501 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h new file mode 100644 index 0000000..d53f326 --- /dev/null +++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h @@ -0,0 +1,8 @@ + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "2" +#define LUA_VERSION_NUM 502 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h new file mode 100644 index 0000000..d33434a --- /dev/null +++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h @@ -0,0 +1,8 @@ + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "3" +#define LUA_VERSION_NUM 503 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h new file mode 100644 index 0000000..730f7cc --- /dev/null +++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h @@ -0,0 +1,8 @@ + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "9" +#define LUA_VERSION_NUM 509 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE @@ -1250,6 +1250,12 @@ else echo "${cmake_cxx_compiler} does not have <ext/stdio_filebuf.h>" fi +if [ -n "${cmake_ccache_enabled}" ]; then + echo "Building CMake with ccache" + cmake_c_compiler="ccache ${cmake_c_compiler}" + cmake_cxx_compiler="ccache ${cmake_cxx_compiler}" +fi + # Just to be safe, let us store compiler and flags to the header file cmake_bootstrap_version='$Revision$' @@ -1536,10 +1542,6 @@ cd "${cmake_binary_dir}" # build with same compiler and make CC="${cmake_c_compiler}" CXX="${cmake_cxx_compiler}" -if [ -n "${cmake_ccache_enabled}" ]; then - CC="ccache ${CC}" - CXX="ccache ${CXX}" -fi MAKE="${cmake_make_processor}" export CC export CXX |