diff options
66 files changed, 482 insertions, 160 deletions
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index ed8447e..52536bb 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -144,7 +144,12 @@ The ``<type>`` must be one of: References a library file located outside the project. The :prop_tgt:`IMPORTED_LOCATION` target property (or its per-configuration variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) specifies the - location of the main library file on disk. + location of the main library file on disk. In the case of a ``SHARED`` + library on Windows, the :prop_tgt:`IMPORTED_IMPLIB` target property + (or its per-configuration variant :prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`) + specifies the location of the DLL import library file (``.lib`` or + ``.dll.a``) on disk, and the ``IMPORTED_LOCATION`` is the location of + the ``.dll`` runtime library (and is optional). Additional usage requirements may be specified in ``INTERFACE_*`` properties. An ``UNKNOWN`` library type is typically only used in the implementation of diff --git a/Help/envvar/ASM_DIALECT.rst b/Help/envvar/ASM_DIALECT.rst index 768d8fe..a606280 100644 --- a/Help/envvar/ASM_DIALECT.rst +++ b/Help/envvar/ASM_DIALECT.rst @@ -14,3 +14,11 @@ in the cache as :variable:`CMAKE_ASM<DIALECT>_COMPILER <CMAKE_<LANG>_COMPILER>`. For subsequent configuration runs, the environment variable will be ignored in favor of :variable:`CMAKE_ASM<DIALECT>_COMPILER <CMAKE_<LANG>_COMPILER>`. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export ASM="custom-compiler --arg1 --arg2" diff --git a/Help/envvar/CC.rst b/Help/envvar/CC.rst index 7d2b870..4c970b4 100644 --- a/Help/envvar/CC.rst +++ b/Help/envvar/CC.rst @@ -11,3 +11,11 @@ value for ``CC`` is stored in the cache as :variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run (including the first), the environment variable will be ignored if the :variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export CC="custom-compiler --arg1 --arg2" diff --git a/Help/envvar/CSFLAGS.rst b/Help/envvar/CSFLAGS.rst index e8c0a11..d875209 100644 --- a/Help/envvar/CSFLAGS.rst +++ b/Help/envvar/CSFLAGS.rst @@ -5,7 +5,7 @@ CSFLAGS .. include:: ENV_VAR.txt -Preferred executable for compiling ``CSharp`` language files. Will only be +Default compilation flags to be used when compiling ``CSharp`` files. Will only be used by CMake on the first configuration to determine ``CSharp`` default compilation flags, after which the value for ``CSFLAGS`` is stored in the cache as :variable:`CMAKE_CSharp_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration diff --git a/Help/envvar/CUDACXX.rst b/Help/envvar/CUDACXX.rst index 1affab6..69471b0 100644 --- a/Help/envvar/CUDACXX.rst +++ b/Help/envvar/CUDACXX.rst @@ -11,3 +11,11 @@ value for ``CUDA`` is stored in the cache as :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run (including the first), the environment variable will be ignored if the :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export CUDACXX="custom-compiler --arg1 --arg2" diff --git a/Help/envvar/CXX.rst b/Help/envvar/CXX.rst index df927d5..908a521 100644 --- a/Help/envvar/CXX.rst +++ b/Help/envvar/CXX.rst @@ -11,3 +11,11 @@ value for ``CXX`` is stored in the cache as :variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run (including the first), the environment variable will be ignored if the :variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export CXX="custom-compiler --arg1 --arg2" diff --git a/Help/envvar/FC.rst b/Help/envvar/FC.rst index f1c26b0..dcee02d 100644 --- a/Help/envvar/FC.rst +++ b/Help/envvar/FC.rst @@ -12,3 +12,11 @@ which the value for ``Fortran`` is stored in the cache as configuration run (including the first), the environment variable will be ignored if the :variable:`CMAKE_Fortran_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export FC="custom-compiler --arg1 --arg2" diff --git a/Help/envvar/RC.rst b/Help/envvar/RC.rst index 3ec1788..adfaecc 100644 --- a/Help/envvar/RC.rst +++ b/Help/envvar/RC.rst @@ -11,3 +11,11 @@ value for ``RC`` is stored in the cache as :variable:`CMAKE_RC_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run (including the first), the environment variable will be ignored if the :variable:`CMAKE_RC_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export RC="custom-compiler --arg1 --arg2" diff --git a/Help/envvar/SWIFTC.rst b/Help/envvar/SWIFTC.rst index ce01ca2..896e156 100644 --- a/Help/envvar/SWIFTC.rst +++ b/Help/envvar/SWIFTC.rst @@ -11,3 +11,11 @@ value for ``SWIFTC`` is stored in the cache as :variable:`CMAKE_Swift_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run (including the first), the environment variable will be ignored if the :variable:`CMAKE_Swift_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. + +.. note:: + Options that are required to make the compiler work correctly can be included; + they can not be changed. + +.. code-block:: console + + $ export SWIFTC="custom-compiler --arg1 --arg2" diff --git a/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst b/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst index b923800..c9301b5 100644 --- a/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst @@ -10,7 +10,7 @@ If this property is set to ``ON``, then the value of the property is ``OFF`` or unset, the :prop_tgt:`CUDA_STANDARD` target property is treated as optional and may "decay" to a previous standard if the requested is not available. For compilers that have no notion of a standard level, such as -MSVC, this has no effect. +MSVC 1800 (Visual Studio 2013) and lower, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst index 2ea2215..8b17490 100644 --- a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst @@ -10,7 +10,7 @@ If this property is set to ``ON``, then the value of the property is ``OFF`` or unset, the :prop_tgt:`CXX_STANDARD` target property is treated as optional and may "decay" to a previous standard if the requested is not available. For compilers that have no notion of a standard level, such as -MSVC, this has no effect. +MSVC 1800 (Visual Studio 2013) and lower, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/prop_tgt/C_STANDARD_REQUIRED.rst b/Help/prop_tgt/C_STANDARD_REQUIRED.rst index c1b58a0..55bff04 100644 --- a/Help/prop_tgt/C_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/C_STANDARD_REQUIRED.rst @@ -10,7 +10,7 @@ If this property is set to ``ON``, then the value of the property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is treated as optional and may "decay" to a previous standard if the requested is not available. For compilers that have no notion of a standard level, such as -MSVC, this has no effect. +MSVC 1800 (Visual Studio 2013) and lower, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/release/dev/compiler_flags.rst b/Help/release/dev/compiler_flags.rst new file mode 100644 index 0000000..7138e80 --- /dev/null +++ b/Help/release/dev/compiler_flags.rst @@ -0,0 +1,9 @@ +compiler_flags +----------------- + +* The :variable:`CMAKE_<LANG>_COMPILER` variable may now be used to + store "mandatory" compiler flags like the :envvar:`CC` and other environment variables. + +* The :variable:`CMAKE_<LANG>_FLAGS_INIT` variable will now be considered during + the compiler indentification check if other sources like :variable:`CMAKE_<LANG>_FLAGS` + or :envvar:`CFLAGS` are not set. diff --git a/Help/variable/CMAKE_LANG_COMPILER.rst b/Help/variable/CMAKE_LANG_COMPILER.rst index 89df495..e694b33 100644 --- a/Help/variable/CMAKE_LANG_COMPILER.rst +++ b/Help/variable/CMAKE_LANG_COMPILER.rst @@ -5,3 +5,28 @@ The full path to the compiler for ``LANG``. This is the command that will be used as the ``<LANG>`` compiler. Once set, you can not change this variable. + +Usage +^^^^^ + +This variable can be set by the user during the first time a build tree is configured. + +If a non-full path value is supplied then CMake will resolve the full path of +the compiler. + +The variable could be set in a user supplied toolchain file or via `-D` on the command line. + +.. note:: + Options that are required to make the compiler work correctly can be included + as items in a list; they can not be changed. + +.. code-block:: cmake + + #set within user supplied toolchain file + set(CMAKE_C_COMPILER /full/path/to/qcc --arg1 --arg2) + +or + +.. code-block:: console + + $ cmake ... -DCMAKE_C_COMPILER='qcc;--arg1;--arg2' diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index bc8b86b..a3e5a12 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) if(NOT $ENV{ASM${ASM_DIALECT}} STREQUAL "") get_filename_component(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT $ENV{ASM${ASM_DIALECT}} PROGRAM PROGRAM_ARGS CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT) if(CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT) - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT}" CACHE STRING "First argument to ASM${ASM_DIALECT} compiler") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT}" CACHE STRING "Arguments to ASM${ASM_DIALECT} compiler") endif() if(NOT EXISTS ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ASM${ASM_DIALECT}:\n$ENV{ASM${ASM_DIALECT}}.") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 1311719..96f32e5 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -43,7 +43,7 @@ else() if(NOT $ENV{CC} STREQUAL "") get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) if(CMAKE_C_FLAGS_ENV_INIT) - set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") + set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "Arguments to C compiler") endif() if(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 0c586f5..daca382 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -19,7 +19,7 @@ else() if(NOT $ENV{CUDACXX} STREQUAL "") get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT) if(CMAKE_CUDA_FLAGS_ENV_INIT) - set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") endif() if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 46f1ee1..4c2924a 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -42,7 +42,7 @@ else() if(NOT $ENV{CXX} STREQUAL "") get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) if(CMAKE_CXX_FLAGS_ENV_INIT) - set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") endif() if(NOT EXISTS ${CMAKE_CXX_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}") diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index cb1ab1d..2780399 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -107,16 +107,14 @@ macro(_cmake_find_compiler_path lang) if(CMAKE_${lang}_COMPILER) # we only get here if CMAKE_${lang}_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_${lang}_COMPILER is a list of length 2, use the first item as - # CMAKE_${lang}_COMPILER and the 2nd one as CMAKE_${lang}_COMPILER_ARG1 - list(LENGTH CMAKE_${lang}_COMPILER _CMAKE_${lang}_COMPILER_LIST_LENGTH) - if("${_CMAKE_${lang}_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_${lang}_COMPILER 1 CMAKE_${lang}_COMPILER_ARG1) - list(GET CMAKE_${lang}_COMPILER 0 CMAKE_${lang}_COMPILER) - endif() - unset(_CMAKE_${lang}_COMPILER_LIST_LENGTH) + # if CMAKE_${lang}_COMPILER is a list, use the first item as + # CMAKE_${lang}_COMPILER and the rest as CMAKE_${lang}_COMPILER_ARG1 + set(CMAKE_${lang}_COMPILER_ARG1 "${CMAKE_${lang}_COMPILER}") + list(POP_FRONT CMAKE_${lang}_COMPILER_ARG1 CMAKE_${lang}_COMPILER) + list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1) # find the compiler in the PATH if necessary + # if compiler (and arguments) comes from cache then synchronize cache with updated CMAKE_<LANG>_COMPILER get_filename_component(_CMAKE_USER_${lang}_COMPILER_PATH "${CMAKE_${lang}_COMPILER}" PATH) if(NOT _CMAKE_USER_${lang}_COMPILER_PATH) find_program(CMAKE_${lang}_COMPILER_WITH_PATH NAMES ${CMAKE_${lang}_COMPILER}) @@ -129,6 +127,12 @@ macro(_cmake_find_compiler_path lang) unset(_CMAKE_${lang}_COMPILER_CACHED) endif() unset(CMAKE_${lang}_COMPILER_WITH_PATH CACHE) + elseif (EXISTS ${CMAKE_${lang}_COMPILER}) + get_property(_CMAKE_${lang}_COMPILER_CACHED CACHE CMAKE_${lang}_COMPILER PROPERTY TYPE) + if(_CMAKE_${lang}_COMPILER_CACHED) + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE STRING "${lang} compiler" FORCE) + endif() + unset(_CMAKE_${lang}_COMPILER_CACHED) endif() endif() endmacro() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 832b18d..d7a35e1 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -14,8 +14,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Make sure user-specified compiler flags are used. if(CMAKE_${lang}_FLAGS) set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS}) - else() + elseif(DEFINED ENV{${flagvar}}) set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}}) + else(CMAKE_${lang}_FLAGS_INIT) + set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS_INIT}) endif() string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 5f5a70a..8a57408 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -26,7 +26,7 @@ else() if(NOT $ENV{FC} STREQUAL "") get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) if(CMAKE_Fortran_FLAGS_ENV_INIT) - set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") + set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Fortran compiler") endif() if(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) else() diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index 3092bb5..db456c0 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_Java_COMPILER) if(NOT $ENV{JAVA_COMPILER} STREQUAL "") get_filename_component(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) if(CMAKE_Java_FLAGS_ENV_INIT) - set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler") + set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Java compiler") endif() if(NOT EXISTS ${CMAKE_Java_COMPILER_INIT}) message(SEND_ERROR "Could not find compiler set in environment variable JAVA_COMPILER:\n$ENV{JAVA_COMPILER}.") diff --git a/Modules/CMakeDetermineOBJCCompiler.cmake b/Modules/CMakeDetermineOBJCCompiler.cmake index 11b47fd..709eb25 100644 --- a/Modules/CMakeDetermineOBJCCompiler.cmake +++ b/Modules/CMakeDetermineOBJCCompiler.cmake @@ -39,7 +39,7 @@ else() if($ENV{${var}} MATCHES ".+") get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT) if(CMAKE_OBJC_FLAGS_ENV_INIT) - set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C compiler") + set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Objective-C compiler") endif() if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}") @@ -65,14 +65,11 @@ else() else() # we only get here if CMAKE_OBJC_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_OBJC_COMPILER is a list of length 2, use the first item as - # CMAKE_OBJC_COMPILER and the 2nd one as CMAKE_OBJC_COMPILER_ARG1 - - list(LENGTH CMAKE_OBJC_COMPILER _CMAKE_OBJC_COMPILER_LIST_LENGTH) - if("${_CMAKE_OBJC_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_OBJC_COMPILER 1 CMAKE_OBJC_COMPILER_ARG1) - list(GET CMAKE_OBJC_COMPILER 0 CMAKE_OBJC_COMPILER) - endif() + # if CMAKE_OBJC_COMPILER is a list, use the first item as + # CMAKE_OBJC_COMPILER and the rest as CMAKE_OBJC_COMPILER_ARG1 + set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_COMPILER}") + list(POP_FRONT CMAKE_OBJC_COMPILER_ARG1 CMAKE_OBJC_COMPILER) + list(JOIN CMAKE_OBJC_COMPILER_ARG1 " " CMAKE_OBJC_COMPILER_ARG1) # if a compiler was specified by the user but without path, # now try to find it with the full path diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake index 99ad6c3..ffd0091 100644 --- a/Modules/CMakeDetermineOBJCXXCompiler.cmake +++ b/Modules/CMakeDetermineOBJCXXCompiler.cmake @@ -41,7 +41,7 @@ else() if($ENV{${var}} MATCHES ".+") get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT) if(CMAKE_OBJCXX_FLAGS_ENV_INIT) - set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C++ compiler") + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Objective-C++ compiler") endif() if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}") @@ -67,14 +67,11 @@ else() else() # we only get here if CMAKE_OBJCXX_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_OBJCXX_COMPILER is a list of length 2, use the first item as - # CMAKE_OBJCXX_COMPILER and the 2nd one as CMAKE_OBJCXX_COMPILER_ARG1 - - list(LENGTH CMAKE_OBJCXX_COMPILER _CMAKE_OBJCXX_COMPILER_LIST_LENGTH) - if("${_CMAKE_OBJCXX_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_OBJCXX_COMPILER 1 CMAKE_OBJCXX_COMPILER_ARG1) - list(GET CMAKE_OBJCXX_COMPILER 0 CMAKE_OBJCXX_COMPILER) - endif() + # if CMAKE_OBJCXX_COMPILER is a list, use the first item as + # CMAKE_OBJCXX_COMPILER and the rest as CMAKE_OBJCXX_COMPILER_ARG1 + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_COMPILER}") + list(POP_FRONT CMAKE_OBJCXX_COMPILER_ARG1 CMAKE_OBJCXX_COMPILER) + list(JOIN CMAKE_OBJCXX_COMPILER_ARG1 " " CMAKE_OBJCXX_COMPILER_ARG1) # if a compiler was specified by the user but without path, # now try to find it with the full path diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index 8801e16..f8d55a5 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -13,7 +13,7 @@ if(NOT CMAKE_RC_COMPILER) if(NOT $ENV{RC} STREQUAL "") get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT) if(CMAKE_RC_FLAGS_ENV_INIT) - set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler") + set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "Arguments to RC compiler") endif() if(EXISTS ${CMAKE_RC_COMPILER_INIT}) else() diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index 688133f..aaad560 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -27,7 +27,7 @@ elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja") PROGRAM_ARGS CMAKE_Swift_FLAGS_ENV_INIT) if(CMAKE_Swift_FLAGS_ENV_INIT) set(CMAKE_Swift_COMPILER_ARG1 "${CMAKE_Swift_FLAGS_ENV_INIT}" CACHE - STRING "First argument to the Swift compiler") + STRING "Arguments to the Swift compiler") endif() if(NOT EXISTS ${CMAKE_Swift_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable SWIFTC\n$ENV{SWIFTC}.\n${CMAKE_Swift_COMPILER_INIT}") diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 5d098d9..883e1f4 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -44,8 +44,8 @@ function(gtest_discover_tests_impl) cmake_parse_arguments( "" "" - "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_EXECUTOR;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR" - "TEST_EXTRA_ARGS;TEST_PROPERTIES" + "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR" + "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR" ${ARGN} ) diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake index 4a03900..6618fd5 100644 --- a/Modules/UseSWIG/ManageSupportFiles.cmake +++ b/Modules/UseSWIG/ManageSupportFiles.cmake @@ -4,7 +4,7 @@ if (ACTION STREQUAL "CLEAN") # Collect current list of generated files - file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") if (files) # clean-up the output directory @@ -22,7 +22,7 @@ endif() if (ACTION STREQUAL "COPY") # Collect current list of generated files - file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + file (GLOB files LIST_DIRECTORIES TRUE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") if (files) # copy files to the output directory diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3a0d53d..b6b868e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 18) -set(CMake_VERSION_PATCH 20200805) +set(CMake_VERSION_PATCH 20200807) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 9db8b85..8d20d35 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2937,7 +2937,7 @@ bool HandleConfigureCommand(std::vector<std::string> const& args, } fout.SetCopyIfDifferent(true); - // copy intput to output and expand variables from input at the same time + // copy input to output and expand variables from input at the same time std::stringstream sin(input, std::ios::in); std::string inLine; std::string outLine; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 530bb59..cad5d1f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -235,6 +235,14 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, } cmProp cname = this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp); + + // Split compiler from arguments + std::vector<std::string> cnameArgVec; + if (cname && !cname->empty()) { + cmExpandList(*cname, cnameArgVec); + cname = &cnameArgVec.front(); + } + std::string changeVars; if (cname && !optional) { std::string cnameString; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 8e9abf8..570f4ea 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -125,14 +125,6 @@ cmGraphVizWriter::cmGraphVizWriter(std::string const& fileName, cmGraphVizWriter::~cmGraphVizWriter() { this->WriteFooter(this->GlobalFileStream); - - for (auto& fileStream : this->PerTargetFileStreams) { - this->WriteFooter(*fileStream.second); - } - - for (auto& fileStream : this->TargetDependersFileStreams) { - this->WriteFooter(*fileStream.second); - } } void cmGraphVizWriter::VisitGraph(std::string const&) @@ -151,20 +143,10 @@ void cmGraphVizWriter::OnItem(cmLinkItem const& item) ++NextNodeId; this->WriteNode(this->GlobalFileStream, item); - - if (this->GeneratePerTarget) { - this->CreateTargetFile(this->PerTargetFileStreams, item); - } - - if (this->GenerateDependers) { - this->CreateTargetFile(this->TargetDependersFileStreams, item, - ".dependers"); - } } -void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap, - cmLinkItem const& item, - std::string const& fileNameSuffix) +std::unique_ptr<cmGeneratedFileStream> cmGraphVizWriter::CreateTargetFile( + cmLinkItem const& item, std::string const& fileNameSuffix) { auto const pathSafeItemName = PathSafeString(item.AsStr()); auto const perTargetFileName = @@ -175,7 +157,7 @@ void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap, this->WriteHeader(*perTargetFileStream, item.AsStr()); this->WriteNode(*perTargetFileStream, item); - fileStreamMap.emplace(item.AsStr(), std::move(perTargetFileStream)); + return perTargetFileStream; } void cmGraphVizWriter::OnDirectLink(cmLinkItem const& depender, @@ -323,13 +305,12 @@ void cmGraphVizWriter::Write() } if (this->GeneratePerTarget) { - WritePerTargetConnections<DependeesDir>(PerTargetConnections, - PerTargetFileStreams); + WritePerTargetConnections<DependeesDir>(PerTargetConnections); } if (this->GenerateDependers) { WritePerTargetConnections<DependersDir>(TargetDependersConnections, - TargetDependersFileStreams); + ".dependers"); } } @@ -368,7 +349,7 @@ void cmGraphVizWriter::FindAllConnections(const ConnectionsMap& connectionMap, template <typename DirFunc> void cmGraphVizWriter::WritePerTargetConnections( - const ConnectionsMap& connections, const FileStreamMap& streams) + const ConnectionsMap& connections, const std::string& fileNameSuffix) { // the per target connections must be extended by indirect dependencies ConnectionsMap extendedConnections; @@ -387,7 +368,9 @@ void cmGraphVizWriter::WritePerTargetConnections( } const Connections& cons = conPerTarget.second; - auto fileStream = streams.at(rootItem.AsStr()).get(); + + std::unique_ptr<cmGeneratedFileStream> fileStream = + this->CreateTargetFile(rootItem, fileNameSuffix); for (const Connection& con : cons) { const cmLinkItem& src = DirFunc::src(con); @@ -395,6 +378,8 @@ void cmGraphVizWriter::WritePerTargetConnections( this->WriteNode(*fileStream, con.dst); this->WriteConnection(*fileStream, src, dst, con.scopeType); } + + this->WriteFooter(*fileStream); } } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 9766068..d1300ac 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -46,9 +46,6 @@ public: void Write(); private: - using FileStreamMap = - std::map<std::string, std::unique_ptr<cmGeneratedFileStream>>; - struct Connection { Connection(cmLinkItem s, cmLinkItem d, std::string scope) @@ -76,8 +73,8 @@ private: void WriteNode(cmGeneratedFileStream& fs, cmLinkItem const& item); - void CreateTargetFile(FileStreamMap& fileStreamMap, cmLinkItem const& target, - std::string const& fileNameSuffix = ""); + std::unique_ptr<cmGeneratedFileStream> CreateTargetFile( + cmLinkItem const& target, std::string const& fileNameSuffix = ""); void WriteConnection(cmGeneratedFileStream& fs, cmLinkItem const& dependerTargetName, @@ -95,7 +92,7 @@ private: template <typename DirFunc> void WritePerTargetConnections(const ConnectionsMap& connections, - const FileStreamMap& streams); + const std::string& fileNameSuffix = ""); bool ItemExcluded(cmLinkItem const& item); bool ItemNameFilteredOut(std::string const& itemName); @@ -111,8 +108,6 @@ private: std::string FileName; cmGeneratedFileStream GlobalFileStream; - FileStreamMap PerTargetFileStreams; - FileStreamMap TargetDependersFileStreams; ConnectionsMap PerTargetConnections; ConnectionsMap TargetDependersConnections; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4d39312..7e35fe7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2613,7 +2613,7 @@ void cmLocalGenerator::CopyPchCompilePdb( } file << " break()\n" << " endif()\n"; - file << " else()\n" + file << " elseif(NOT EXISTS \"" << from_file << "\")\n" << " execute_process(COMMAND ${CMAKE_COMMAND}" << " -E sleep 1)\n" << " endif()\n"; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1775085..bde5ee7 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -733,12 +733,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement( static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - globalGen->GetRuleCmdLength(this->LanguageLinkerDeviceRule(config)); - std::string path = localGen.GetHomeRelativeOutputPath(); - if (!path.empty()) { - path += '/'; - } build.RspFile = this->ConvertToNinjaPath( - cmStrCat(path, "CMakeFiles/", genTarget->GetName(), + cmStrCat("CMakeFiles/", genTarget->GetName(), globalGen->IsMultiConfig() ? cmStrCat('.', config) : "", ".rsp")); // Gather order-only dependencies. @@ -1160,12 +1156,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( globalGen->GetRuleCmdLength(linkBuild.Rule); } - std::string path = localGen.GetHomeRelativeOutputPath(); - if (!path.empty()) { - path += '/'; - } linkBuild.RspFile = this->ConvertToNinjaPath( - cmStrCat(path, "CMakeFiles/", gt->GetName(), + cmStrCat("CMakeFiles/", gt->GetName(), globalGen->IsMultiConfig() ? cmStrCat('.', config) : "", ".rsp")); // Gather order-only dependencies. diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 205097d..06957b0 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1181,11 +1181,54 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() if (useNinjaDepfile) { // Create a custom command that generates a timestamp file and // has a depfile assigned. The depfile is created by JobDepFilesMergeT. - - // Add additional autogen target dependencies + // + // Also create an additional '_autogen_timestamp_deps' that the custom + // command will depend on. It will have no sources or commands to + // execute, but it will have dependencies that would originally be + // assigned to the pre-Qt 5.15 'autogen' target. These dependencies will + // serve as a list of order-only dependencies for the custom command, + // without forcing the custom command to re-execute. + // + // The dependency tree would then look like + // '_autogen_timestamp_deps (order-only)' <- '/timestamp' file <- + // '_autogen' target. + const auto timestampTargetName = + cmStrCat(this->GenTarget->GetName(), "_autogen_timestamp_deps"); + std::vector<std::string> timestampTargetProvides; + cmCustomCommandLines timestampTargetCommandLines; + + // Add additional autogen target dependencies to + // '_autogen_timestamp_deps'. for (const cmTarget* t : this->AutogenTarget.DependTargets) { dependencies.push_back(t->GetName()); } + + cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand( + timestampTargetName, true, this->Dir.Work.c_str(), + /*byproducts=*/timestampTargetProvides, + /*depends=*/dependencies, timestampTargetCommandLines, false, nullptr); + this->LocalGen->AddGeneratorTarget( + cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen)); + + // Set FOLDER property on the timestamp target, so it appears in the + // appropriate folder in an IDE or in the file api. + if (!this->TargetsFolder.empty()) { + timestampTarget->SetProperty("FOLDER", this->TargetsFolder); + } + + // Make '/timestamp' file depend on '_autogen_timestamp_deps' and on the + // moc and uic executables (whichever are enabled). + dependencies.clear(); + dependencies.push_back(timestampTargetName); + + if (this->Moc.ExecutableTarget != nullptr) { + dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName()); + } + if (this->Uic.ExecutableTarget != nullptr) { + dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName()); + } + + // Create the custom command that outputs the timestamp file. const char timestampFileName[] = "timestamp"; const std::string outputFile = cmStrCat(this->Dir.Build, "/", timestampFileName); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 9adcabb..f6cccfb 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2163,7 +2163,9 @@ std::string escapeDependencyPath(cm::string_view path) void cmQtAutoMocUicT::JobDepFilesMergeT::Process() { if (Log().Verbose()) { - Log().Info(GenT::MOC, "Merging MOC dependencies"); + Log().Info(GenT::MOC, + cmStrCat("Merging MOC dependencies into ", + MessagePath(BaseConst().DepFile.c_str()))); } auto processDepFile = [](const std::string& mocOutputFile) -> std::vector<std::string> { diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 254131b..4ff81c1 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -261,7 +261,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( this->VariableMappings["CMAKE_" + compIt->second + "_COMPILE_OPTIONS_SYSROOT"]; - // if there is a required first argument to the compiler add it + // if there are required arguments to the compiler add it // to the compiler string if (!compilerArg1.empty()) { ret += " "; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1e688ed..dcb96f8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1390,8 +1390,13 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) save.key = *i; warning << *i << "= "; i++; - save.value = *i; - warning << *i << "\n"; + if (i != argsSplit.end()) { + save.value = *i; + warning << *i << "\n"; + } else { + warning << "\n"; + i -= 1; + } cmProp existingValue = this->State->GetCacheEntryValue(save.key); if (existingValue) { save.type = this->State->GetCacheEntryType(save.key); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 7c66c5c..4600fc5 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -71,7 +71,7 @@ const char* cmDocumentationOptions[][2] = { { "--open <dir>", "Open generated project in the associated application." }, { "-N", "View mode only." }, { "-P <file>", "Process script mode." }, - { "--find-package", "Run in pkg-config like mode." }, + { "--find-package", "Legacy pkg-config like mode. Do not use." }, { "--graphviz=[file]", "Generate graphviz of dependencies, see " "CMakeGraphVizOptions.cmake for more." }, diff --git a/Source/kwsys/CTestConfig.cmake b/Source/kwsys/CTestConfig.cmake index 33ea84c..12347b6 100644 --- a/Source/kwsys/CTestConfig.cmake +++ b/Source/kwsys/CTestConfig.cmake @@ -3,7 +3,9 @@ set(CTEST_PROJECT_NAME "KWSys") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DROP_METHOD "http") +if (NOT CTEST_DROP_METHOD STREQUAL "https") + set(CTEST_DROP_METHOD "http") +endif () set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 5452f73..c6d4b19 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -27,7 +27,7 @@ #include <cstdio> #include <cstring> namespace KWSYS_NAMESPACE { -#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__APPLE__) // On Windows and Apple, no difference between lower and upper case # define KWSYS_GLOB_CASE_INDEPENDENT #endif diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index ed1cdc0..9c34a56 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -863,7 +863,7 @@ void SystemInformation::RunMemoryCheck() // Hide implementation details in an anonymous namespace. namespace { // ***************************************************************************** -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) int LoadLines(FILE* file, std::vector<std::string>& lines) { // Load each line in the given file into a the vector. @@ -893,7 +893,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines) return nRead; } -# if defined(__linux) +# if defined(__linux) || defined(__CYGWIN__) // ***************************************************************************** int LoadLines(const char* fileName, std::vector<std::string>& lines) { @@ -926,7 +926,7 @@ int NameValue(std::vector<std::string> const& lines, std::string const& name, } #endif -#if defined(__linux) +#if defined(__linux) || defined(__CYGWIN__) // **************************************************************************** template <typename T> int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values) @@ -3393,7 +3393,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() pos = buffer.find("processor\t", pos + 1); } -#ifdef __linux +#if defined(__linux) || defined(__CYGWIN__) // Count sockets. std::set<int> PhysicalIDs; std::string idc = this->ExtractValueFromCpuInfoFile(buffer, "physical id"); @@ -3414,8 +3414,8 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() this->NumberOfPhysicalCPU = NumberOfCoresPerSocket * (unsigned int)NumberOfSockets; -#else // __CYGWIN__ - // does not have "physical id" entries, neither "cpu cores" +#else + // For systems which do not have "physical id" entries, neither "cpu cores" // this has to be fixed for hyper-threading. std::string cpucount = this->ExtractValueFromCpuInfoFile(buffer, "cpu count"); @@ -3597,7 +3597,7 @@ long long SystemInformationImplementation::GetHostMemoryTotal() GlobalMemoryStatusEx(&statex); return statex.ullTotalPhys / 1024; # endif -#elif defined(__linux) +#elif defined(__linux) || defined(__CYGWIN__) long long memTotal = 0; int ierr = GetFieldFromFile("/proc/meminfo", "MemTotal:", memTotal); if (ierr) { @@ -3712,6 +3712,16 @@ long long SystemInformationImplementation::GetHostMemoryUsed() GlobalMemoryStatusEx(&statex); return (statex.ullTotalPhys - statex.ullAvailPhys) / 1024; # endif +#elif defined(__CYGWIN__) + const char* names[3] = { "MemTotal:", "MemFree:", nullptr }; + long long values[2] = { 0 }; + int ierr = GetFieldsFromFile("/proc/meminfo", names, values); + if (ierr) { + return ierr; + } + long long& memTotal = values[0]; + long long& memFree = values[1]; + return memTotal - memFree; #elif defined(__linux) // First try to use MemAvailable, but it only works on newer kernels const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr }; @@ -3773,7 +3783,7 @@ long long SystemInformationImplementation::GetProcMemoryUsed() return -2; } return pmc.WorkingSetSize / 1024; -#elif defined(__linux) +#elif defined(__linux) || defined(__CYGWIN__) long long memUsed = 0; int ierr = GetFieldFromFile("/proc/self/status", "VmRSS:", memUsed); if (ierr) { @@ -3850,7 +3860,8 @@ long long SystemInformationImplementation::GetProcessId() #if defined(_WIN32) return GetCurrentProcessId(); #elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \ - defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) + defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ + defined(__CYGWIN__) return getpid(); #else return -1; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 2c39b91..6144d9c 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -96,19 +96,12 @@ # if defined(_MSC_VER) && _MSC_VER >= 1800 # define KWSYS_WINDOWS_DEPRECATED_GetVersionEx # endif -#elif defined(__CYGWIN__) -# include <windows.h> -# undef _WIN32 #endif #if !KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H extern char** environ; #endif -#ifdef __CYGWIN__ -# include <sys/cygwin.h> -#endif - // getpwnam doesn't exist on Windows and Cray Xt3/Catamount // same for TIOCGWINSZ #if defined(_WIN32) || defined(__LIBCATAMOUNT__) || \ @@ -1290,15 +1283,7 @@ bool SystemTools::PathExists(const std::string& path) if (path.empty()) { return false; } -#if defined(__CYGWIN__) - // Convert path to native windows path if possible. - char winpath[MAX_PATH]; - if (SystemTools::PathCygwinToWin32(path.c_str(), winpath)) { - return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); - } - struct stat st; - return lstat(path.c_str(), &st) == 0; -#elif defined(_WIN32) +#if defined(_WIN32) return (GetFileAttributesW(Encoding::ToWindowsExtendedPath(path).c_str()) != INVALID_FILE_ATTRIBUTES); #else @@ -1320,14 +1305,7 @@ bool SystemTools::FileExists(const std::string& filename) if (filename.empty()) { return false; } -#if defined(__CYGWIN__) - // Convert filename to native windows path if possible. - char winpath[MAX_PATH]; - if (SystemTools::PathCygwinToWin32(filename.c_str(), winpath)) { - return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); - } - return access(filename.c_str(), R_OK) == 0; -#elif defined(_WIN32) +#if defined(_WIN32) DWORD attr = GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { @@ -1433,24 +1411,6 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf) #endif } -#ifdef __CYGWIN__ -bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path) -{ - auto itr = SystemToolsStatics->Cyg2Win32Map.find(path); - if (itr != SystemToolsStatics->Cyg2Win32Map.end()) { - strncpy(win32_path, itr->second.c_str(), MAX_PATH); - } else { - if (cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, win32_path, MAX_PATH) != - 0) { - win32_path[0] = 0; - } - SystemToolsStatics->Cyg2Win32Map.insert( - SystemToolsStatic::StringMap::value_type(path, win32_path)); - } - return win32_path[0] != 0; -} -#endif - bool SystemTools::Touch(const std::string& filename, bool create) { if (!SystemTools::FileExists(filename)) { diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 5dbb726..74dc176 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -331,15 +331,6 @@ public: static int Stat(const char* path, Stat_t* buf); static int Stat(const std::string& path, Stat_t* buf); -/** - * Converts Cygwin path to Win32 path. Uses dictionary container for - * caching and calls to cygwin_conv_to_win32_path from Cygwin dll - * for actual translation. Returns true on success, else false. - */ -#ifdef __CYGWIN__ - static bool PathCygwinToWin32(const char* path, char* win32_path); -#endif - /** * Return file length */ diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 4d2a53c..e08b30a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -142,6 +142,9 @@ if(CMAKE_GENERATOR MATCHES "Ninja") if(CMAKE_Fortran_COMPILER) list(APPEND Ninja_ARGS -DTEST_Fortran=1) endif() + if(CMake_TEST_Qt5 AND Qt5Core_FOUND) + list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) + endif() add_RunCMake_test(Ninja) set(NinjaMultiConfig_ARGS -DCYGWIN=${CYGWIN} @@ -623,6 +626,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") set_property(TEST RunCMake.CompilerLauncher APPEND PROPERTY LABELS "CUDA") add_RunCMake_test(ctest_labels_for_subprojects) + add_RunCMake_test(CompilerArgs) endif() set(cpack_tests diff --git a/Tests/RunCMake/CompilerArgs/C.cmake b/Tests/RunCMake/CompilerArgs/C.cmake new file mode 100644 index 0000000..96b004b --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/C.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.c) diff --git a/Tests/RunCMake/CompilerArgs/CMakeLists.txt b/Tests/RunCMake/CompilerArgs/CMakeLists.txt new file mode 100644 index 0000000..18dfd26 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerArgs/CXX.cmake b/Tests/RunCMake/CompilerArgs/CXX.cmake new file mode 100644 index 0000000..3d2ee00 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/CompilerArgs/FindCCompiler.cmake b/Tests/RunCMake/CompilerArgs/FindCCompiler.cmake new file mode 100644 index 0000000..aeaaf7f --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/FindCCompiler.cmake @@ -0,0 +1,2 @@ +enable_language(C) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/C_comp.cmake" "set(temp_CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerArgs/FindCXXCompiler.cmake b/Tests/RunCMake/CompilerArgs/FindCXXCompiler.cmake new file mode 100644 index 0000000..663ac83 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/FindCXXCompiler.cmake @@ -0,0 +1,2 @@ +enable_language(CXX) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CXX_comp.cmake" "set(temp_CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake new file mode 100644 index 0000000..9e5a18a --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake @@ -0,0 +1,58 @@ +include(RunCMake) + +function(find_compiler lang) + # Detect the compiler in use in the current environment. + run_cmake(Find${lang}Compiler) + # Use the detected compiler + include(${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/${lang}_comp.cmake) + if(NOT temp_CMAKE_${lang}_COMPILER) + message(FATAL_ERROR "FindCompiler provided no compiler!") + endif() + # Create a toolchain file + set(__test_compiler_var CMAKE_${lang}_COMPILER) + set(__test_compiler "${temp_CMAKE_${lang}_COMPILER}") + configure_file(${RunCMake_SOURCE_DIR}/toolchain.cmake.in + ${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake @ONLY) +endfunction() + +function(run_compiler_env lang) + # Use the correct compiler + include(${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/${lang}_comp.cmake) + + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-env-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + # Set the compiler + if(lang STREQUAL "C") + set(ENV{CC} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") + else() + set(ENV{${lang}} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") + endif() + + run_cmake(${lang}) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +function(run_compiler_tc lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-tc-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(RunCMake_TEST_OPTIONS + -DCMAKE_TOOLCHAIN_FILE=${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake) + run_cmake(${lang}) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +set(langs C CXX) + +foreach(lang ${langs}) + find_compiler(${lang}) + run_compiler_env(${lang}) + run_compiler_tc(${lang}) +endforeach() diff --git a/Tests/RunCMake/CompilerArgs/main.c b/Tests/RunCMake/CompilerArgs/main.c new file mode 100644 index 0000000..b526135 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/main.c @@ -0,0 +1,10 @@ +#ifndef FOO1 +# error Missing FOO1 +#endif +#ifndef FOO2 +# error Missing FOO2 +#endif +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CompilerArgs/main.cxx b/Tests/RunCMake/CompilerArgs/main.cxx new file mode 100644 index 0000000..db90e93 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/main.cxx @@ -0,0 +1,10 @@ +#ifndef FOO1 +# error Missing FOO1 +#endif +#ifndef FOO2 +# error Missing FOO2 +#endif +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/CompilerArgs/toolchain.cmake.in b/Tests/RunCMake/CompilerArgs/toolchain.cmake.in new file mode 100644 index 0000000..ff77639 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/toolchain.cmake.in @@ -0,0 +1 @@ +set(@__test_compiler_var@ "@__test_compiler@" -DFOO1 -DFOO2) diff --git a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake new file mode 100644 index 0000000..d69a119 --- /dev/null +++ b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) + +find_package(Qt5Core REQUIRED) + +set(CMAKE_AUTOMOC ON) + +add_library(simple_lib SHARED simple_lib.cpp) +add_executable(app_with_qt app.cpp app_qt.cpp) +target_link_libraries(app_with_qt PRIVATE simple_lib Qt5::Core) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 8f9c263..d43023b 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -138,6 +138,7 @@ ${ninja_stderr} message(FATAL_ERROR "top ninja build failed exited with status ${ninja_result}") endif() + set(ninja_stdout "${ninja_stdout}" PARENT_SCOPE) endfunction(run_ninja) function (run_LooseObjectDepends) @@ -322,3 +323,23 @@ function (run_ChangeBuildType) run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) endfunction() run_ChangeBuildType() + +function(run_Qt5AutoMocDeps) + if(CMake_TEST_Qt5 AND CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5AutoMocDeps-build) + run_cmake(Qt5AutoMocDeps) + unset(RunCMake_TEST_OPTIONS) + # Build the project. + run_ninja("${RunCMake_TEST_BINARY_DIR}") + # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC + # for app_with_qt target. + touch("${RunCMake_SOURCE_DIR}/simple_lib.cpp") + # Build and assert that AUTOMOC was not run for app_with_qt. + run_ninja("${RunCMake_TEST_BINARY_DIR}") + if(ninja_stdout MATCHES "Automatic MOC for target app_with_qt") + message(FATAL_ERROR + "AUTOMOC should not have executed for 'app_with_qt' target:\nstdout:\n${ninja_stdout}") + endif() + endif() +endfunction() +run_Qt5AutoMocDeps() diff --git a/Tests/RunCMake/Ninja/app.cpp b/Tests/RunCMake/Ninja/app.cpp new file mode 100644 index 0000000..57380e4 --- /dev/null +++ b/Tests/RunCMake/Ninja/app.cpp @@ -0,0 +1,6 @@ +int main(int argc, char* argv[]) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Tests/RunCMake/Ninja/app_qt.cpp b/Tests/RunCMake/Ninja/app_qt.cpp new file mode 100644 index 0000000..302c672 --- /dev/null +++ b/Tests/RunCMake/Ninja/app_qt.cpp @@ -0,0 +1,11 @@ +#include <QObject> + +class Mango : public QObject +{ + Q_OBJECT +public: +Q_SIGNALS: + void eatFruit(); +}; + +#include "app_qt.moc" diff --git a/Tests/RunCMake/Ninja/simple_lib.cpp b/Tests/RunCMake/Ninja/simple_lib.cpp new file mode 100644 index 0000000..cf8d689 --- /dev/null +++ b/Tests/RunCMake/Ninja/simple_lib.cpp @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void dummy_symbol() +{ +} diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index d102846..7046fab 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -33,6 +33,16 @@ if (CMAKE_CSharp_COMPILER) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) endif() +add_test(NAME UseSWIG.NamespaceCsharp COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/NamespaceCsharp" + "${CMake_BINARY_DIR}/Tests/UseSWIG/NamespaceCsharp" + ${build_generator_args} + --build-project TestNamespaceCsharp + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) add_test(NAME UseSWIG.BasicPython COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> diff --git a/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt new file mode 100644 index 0000000..39566a8 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.12...3.13) + +project(TestNamsespaceCsharp CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +set(UseSWIG_MODULE_VERSION 2) + + +add_library(ns_example STATIC ns_example.cpp) +target_include_directories(ns_example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +set_property(SOURCE ns_example.i PROPERTY CPLUSPLUS ON) + +swig_add_library(ns_csharp TYPE SHARED LANGUAGE csharp SOURCES ns_example.i) +set_target_properties(ns_csharp PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE) + +target_link_libraries(ns_csharp PRIVATE ns_example) + +get_target_property(NS_CSHARP_SUPPORT_FILES_DIR ns_csharp SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME NamespaceCsharp COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_DIRECTORY=${NS_CSHARP_SUPPORT_FILES_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") diff --git a/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake b/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake new file mode 100644 index 0000000..828d54c --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake @@ -0,0 +1,8 @@ + +file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_DIRECTORY}" "${SUPPORT_FILES_DIRECTORY}/*") + +list(SORT files) + +if (NOT files STREQUAL "NSExample.cs;NSExamplePINVOKE.cs;ns;ns/my_class_in_namespace.cs") + message (FATAL_ERROR "Support files not correctly collected.") +endif() diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp b/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp new file mode 100644 index 0000000..a03dbad --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp @@ -0,0 +1,14 @@ +#include "ns_example.hpp" + +namespace ns { + +void my_class_in_namespace::add(int value) +{ + Sum += value; +} + +int my_class_in_namespace::get_sum() const +{ + return Sum; +} +} diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp b/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp new file mode 100644 index 0000000..65b9ab5 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp @@ -0,0 +1,19 @@ +#pragma once + +namespace ns { + +class my_class_in_namespace +{ +public: + my_class_in_namespace() + : Sum(0) + { + } + + void add(int value); + int get_sum() const; + +private: + int Sum; +}; +} diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.i b/Tests/UseSWIG/NamespaceCsharp/ns_example.i new file mode 100644 index 0000000..036f7ca --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.i @@ -0,0 +1,8 @@ +%module NSExample + +%{ +#include "ns_example.hpp" +%} + +%nspace ns::my_class_in_namespace; +%include "ns_example.hpp" |