diff options
119 files changed, 1634 insertions, 140 deletions
diff --git a/.gitlab/ci/configure_fedora31_common.cmake b/.gitlab/ci/configure_fedora31_common.cmake index dc068d5..90b9d90 100644 --- a/.gitlab/ci/configure_fedora31_common.cmake +++ b/.gitlab/ci/configure_fedora31_common.cmake @@ -1,4 +1,5 @@ set(BUILD_CursesDialog ON CACHE BOOL "") set(BUILD_QtDialog ON CACHE BOOL "") + include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_makefiles.cmake b/.gitlab/ci/configure_fedora31_makefiles.cmake index 20863a2..efb4b84 100644 --- a/.gitlab/ci/configure_fedora31_makefiles.cmake +++ b/.gitlab/ci/configure_fedora31_makefiles.cmake @@ -1 +1,2 @@ +set(CMake_TEST_ISPC "ON" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_fedora31_ninja.cmake b/.gitlab/ci/configure_fedora31_ninja.cmake index 74768b7..dad6d45 100644 --- a/.gitlab/ci/configure_fedora31_ninja.cmake +++ b/.gitlab/ci/configure_fedora31_ninja.cmake @@ -1 +1,2 @@ +set(CMake_TEST_ISPC "ON" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora31_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_ninja_multi.cmake b/.gitlab/ci/configure_fedora31_ninja_multi.cmake index 20863a2..efb4b84 100644 --- a/.gitlab/ci/configure_fedora31_ninja_multi.cmake +++ b/.gitlab/ci/configure_fedora31_ninja_multi.cmake @@ -1 +1,2 @@ +set(CMake_TEST_ISPC "ON" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/docker/fedora31/Dockerfile b/.gitlab/ci/docker/fedora31/Dockerfile index 5588a85..4ad8d45 100644 --- a/.gitlab/ci/docker/fedora31/Dockerfile +++ b/.gitlab/ci/docker/fedora31/Dockerfile @@ -3,3 +3,6 @@ MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> COPY install_deps.sh /root/install_deps.sh RUN sh /root/install_deps.sh + +COPY install_ispc.sh /root/install_ispc.sh +RUN sh /root/install_ispc.sh diff --git a/.gitlab/ci/docker/fedora31/install_ispc.sh b/.gitlab/ci/docker/fedora31/install_ispc.sh new file mode 100755 index 0000000..fdc14b5 --- /dev/null +++ b/.gitlab/ci/docker/fedora31/install_ispc.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +readonly version="1.13.0" +readonly sha256sum="8ab1189bd5db596b3eee9d9465d3528b6626a7250675d67102761bb0d284cd21" + +readonly filename="ispc-v$version-linux" +readonly tarball="$filename.tar.gz" + +echo "$sha256sum $tarball" > ispc.sha256sum +curl -OL "https://github.com/ispc/ispc/releases/download/v$version/$tarball" +sha256sum --check ispc.sha256sum +tar --strip-components=1 -C /usr/local -xf "$tarball" "$filename/bin/ispc" diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 9ad8fc7..dfd94f5 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -30,7 +30,7 @@ ### Fedora .fedora31: - image: "kitware/cmake:ci-fedora31-x86_64-2020-06-01" + image: "kitware/cmake:ci-fedora31-x86_64-2020-08-18" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 2d63eb0..2dd3174 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -1048,6 +1048,7 @@ syn keyword cmakeVariable contained \ CMAKE_HOST_UNIX \ CMAKE_HOST_WIN32 \ CMAKE_IGNORE_PATH + \ CMAKE_ISPC_HEADER_DIRECTORY \ CMAKE_IMPORT_LIBRARY_PREFIX \ CMAKE_IMPORT_LIBRARY_SUFFIX \ CMAKE_INCLUDE_CURRENT_DIR diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst index fdc44f2..e8640ea 100644 --- a/Help/command/enable_language.rst +++ b/Help/command/enable_language.rst @@ -9,7 +9,8 @@ Enable a language (CXX/C/OBJC/OBJCXX/Fortran/etc) Enables support for the named language in CMake. This is the same as the :command:`project` command but does not create any of the extra variables that are created by the project command. Example languages -are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``, and ``ASM``. +are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``, +``ISPC``, and ``ASM``. If enabling ``ASM``, enable it last so that CMake can check whether compilers for other languages like ``C`` work for assembly too. diff --git a/Help/command/project.rst b/Help/command/project.rst index b6093d3..c325050 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -88,7 +88,7 @@ The options are: Selects which programming languages are needed to build the project. Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``, - ``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, and ``ASM``. + ``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, ``ISPC``, and ``ASM``. By default ``C`` and ``CXX`` are enabled if no language options are given. Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages, to skip enabling any languages. diff --git a/Help/envvar/ISPC.rst b/Help/envvar/ISPC.rst new file mode 100644 index 0000000..bcd6260 --- /dev/null +++ b/Help/envvar/ISPC.rst @@ -0,0 +1,13 @@ +ISPC +------- + +.. versionadded:: 3.19 + +.. include:: ENV_VAR.txt + +Preferred executable for compiling ``ISPC`` language files. Will only be used by +CMake on the first configuration to determine ``ISPC`` compiler, after which the +value for ``ISPC`` is stored in the cache as +:variable:`CMAKE_ISPC_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration +run (including the first), the environment variable will be ignored if the +:variable:`CMAKE_ISPC_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined. diff --git a/Help/envvar/ISPCFLAGS.rst b/Help/envvar/ISPCFLAGS.rst new file mode 100644 index 0000000..21df037 --- /dev/null +++ b/Help/envvar/ISPCFLAGS.rst @@ -0,0 +1,15 @@ +ISPCFLAGS +--------- + +.. versionadded:: 3.19 + +.. include:: ENV_VAR.txt + +Default compilation flags to be used when compiling ``ISPC`` files. Will only be +used by CMake on the first configuration to determine ``ISPC`` default +compilation flags, after which the value for ``ISPCFLAGS`` is stored in the +cache as :variable:`CMAKE_ISPC_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration +run (including the first), the environment variable will be ignored if +the :variable:`CMAKE_ISPC_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined. + +See also :variable:`CMAKE_ISPC_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst index 401845d..5b319bb 100644 --- a/Help/generator/Visual Studio 14 2015.rst +++ b/Help/generator/Visual Studio 14 2015.rst @@ -45,3 +45,19 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. By default this generator uses the 32-bit variant even on a 64-bit host. .. include:: VS_TOOLSET_HOST_ARCH.txt + +.. _`Windows 10 SDK Maximum Version for VS 2015`: + +Windows 10 SDK Maximum Version for VS 2015 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Microsoft stated in a "Windows 10 October 2018 Update" blog post that Windows +10 SDK versions (15063, 16299, 17134, 17763) are not supported by VS 2015 and +are only supported by VS 2017 and later. Therefore by default CMake +automatically ignores Windows 10 SDKs beyond ``10.0.14393.0``. + +However, there are other recommendations for certain driver/Win32 builds that +indicate otherwise. A user can override this behavior by either setting the +:variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` to a false value +or setting the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` to +the string value of the required maximum (e.g. ``10.0.15063.0``). diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index ce1e360..13e0d39 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -63,6 +63,8 @@ Environment Variables for Languages /envvar/CXXFLAGS /envvar/FC /envvar/FFLAGS + /envvar/ISPC + /envvar/ISPCFLAGS /envvar/OBJC /envvar/OBJCXX /envvar/RC diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index c7f6b27..b9c238d 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -146,6 +146,11 @@ Variable Queries ``1`` if the CMake's compiler id of the Fortran compiler matches any one of the entries in ``compiler_ids``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +``$<ISPC_COMPILER_ID:compiler_ids>`` + where ``compiler_ids`` is a comma-separated list. + ``1`` if the CMake's compiler id of the ISPC compiler matches any one + of the entries in ``compiler_ids``, otherwise ``0``. + See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. ``$<C_COMPILER_VERSION:version>`` ``1`` if the version of the C compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. @@ -164,6 +169,9 @@ Variable Queries ``$<Fortran_COMPILER_VERSION:version>`` ``1`` if the version of the Fortran compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. +``$<ISPC_COMPILER_VERSION:version>`` + ``1`` if the version of the ISPC compiler matches ``version``, otherwise ``0``. + See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. ``$<TARGET_POLICY:policy>`` ``1`` if the ``policy`` was NEW when the 'head' target was created, else ``0``. If the ``policy`` was not set, the warning message for the policy @@ -543,6 +551,9 @@ Variable Queries ``$<Fortran_COMPILER_ID>`` The CMake's compiler id of the Fortran compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +``$<ISPC_COMPILER_ID>`` + The CMake's compiler id of the ISPC compiler used. + See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. ``$<C_COMPILER_VERSION>`` The version of the C compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. @@ -561,6 +572,9 @@ Variable Queries ``$<Fortran_COMPILER_VERSION>`` The version of the Fortran compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. +``$<ISPC_COMPILER_VERSION>`` + The version of the ISPC compiler used. + See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. ``$<COMPILE_LANGUAGE>`` The compile language of source files when evaluating compile options. See :ref:`the related boolean expression diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index afdf78c..644e87b 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -258,6 +258,7 @@ Properties on Targets /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_tgt/INTERPROCEDURAL_OPTIMIZATION /prop_tgt/IOS_INSTALL_COMBINED + /prop_tgt/ISPC_HEADER_DIRECTORY /prop_tgt/JOB_POOL_COMPILE /prop_tgt/JOB_POOL_LINK /prop_tgt/JOB_POOL_PRECOMPILE_HEADER diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 4b40917..082e2d5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -124,6 +124,7 @@ Variables that Provide Information /variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE /variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION + /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM /variable/CMAKE_XCODE_GENERATE_SCHEME /variable/CMAKE_XCODE_PLATFORM_TOOLSET /variable/PROJECT-NAME_BINARY_DIR @@ -509,6 +510,7 @@ Variables for Languages /variable/CMAKE_Fortran_MODDIR_DEFAULT /variable/CMAKE_Fortran_MODDIR_FLAG /variable/CMAKE_Fortran_MODOUT_FLAG + /variable/CMAKE_ISPC_HEADER_DIRECTORY /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX diff --git a/Help/prop_sf/LANGUAGE.rst b/Help/prop_sf/LANGUAGE.rst index 88d438e..1dd2554 100644 --- a/Help/prop_sf/LANGUAGE.rst +++ b/Help/prop_sf/LANGUAGE.rst @@ -6,6 +6,6 @@ What programming language is the file. A property that can be set to indicate what programming language the source file is. If it is not set the language is determined based on the file extension. Typical values are ``CXX`` (i.e. C++), ``C``, -``CSharp``, ``CUDA``, ``Fortran``, and ``ASM``. Setting this +``CSharp``, ``CUDA``, ``Fortran``, ``ISPC``, and ``ASM``. Setting this property for a file means this file will be compiled. Do not set this for headers or files that should not be compiled. diff --git a/Help/prop_tgt/ISPC_HEADER_DIRECTORY.rst b/Help/prop_tgt/ISPC_HEADER_DIRECTORY.rst new file mode 100644 index 0000000..2a3a8bc --- /dev/null +++ b/Help/prop_tgt/ISPC_HEADER_DIRECTORY.rst @@ -0,0 +1,13 @@ +ISPC_HEADER_DIRECTORY +--------------------- + +.. versionadded:: 3.19 + +Specify relative output directory for ISPC headers provided by the target. + +If the target contains ISPC source files, this specifies the directory in which +the generated headers will be placed. Relative paths are treated with respect to +the value of :variable:`CMAKE_CURRENT_BINARY_DIR`. When this property is not set, the +headers will be placed a generator defined build directory. If the variable +:variable:`CMAKE_ISPC_HEADER_DIRECTORY` is set when a target is created +its value is used to initialize this property. diff --git a/Help/release/dev/ispc-language-support.rst b/Help/release/dev/ispc-language-support.rst new file mode 100644 index 0000000..254442e --- /dev/null +++ b/Help/release/dev/ispc-language-support.rst @@ -0,0 +1,11 @@ +cmake-ispc-support +------------------ + + +* CMake learned to support ``ISPC`` as a first-class language that can be + enabled via the :command:`project` and :command:`enable_language` commands. + +* ``ISPC`` is currently supported by the :ref:`Makefile Generators` + and the :generator:`Ninja` generator on Linux, macOS, and Windows. + +* The Intel ISPC compiler (``ispc``) is supported. diff --git a/Help/release/dev/vs-win-sdk-custom-max.rst b/Help/release/dev/vs-win-sdk-custom-max.rst new file mode 100644 index 0000000..bd19fc8 --- /dev/null +++ b/Help/release/dev/vs-win-sdk-custom-max.rst @@ -0,0 +1,6 @@ +vs-win-sdk-custom-max +--------------------- + +* A :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` variable + was added to tell the :ref:`Visual Studio Generators` what maximumm + version of the Windows SDK to choose. diff --git a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst index 07342b5..d5fcb7d 100644 --- a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst +++ b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst @@ -3,9 +3,9 @@ CMAKE_CUDA_HOST_COMPILER .. versionadded:: 3.10 -When :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>` is set to -NVIDIA ``nvcc``, ``CMAKE_CUDA_HOST_COMPILER`` selects the compiler -executable to use when compiling host code for ``CUDA`` language files. +When :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is +``NVIDIA``, ``CMAKE_CUDA_HOST_COMPILER`` selects the compiler executable to use +when compiling host code for ``CUDA`` language files. This maps to the ``nvcc -ccbin`` option. The ``CMAKE_CUDA_HOST_COMPILER`` variable may be set explicitly before CUDA is @@ -20,6 +20,6 @@ is read-only and changes to it are undefined behavior. .. note:: Since ``CMAKE_CUDA_HOST_COMPILER`` is meaningful only when the - ``CMAKE_CUDA_COMPILER`` is ``nvcc``, it does not make sense to - set ``CMAKE_CUDA_HOST_COMPILER`` explicitly without also setting - ``CMAKE_CUDA_COMPILER`` explicitly to be sure it is ``nvcc``. + :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``, + it does not make sense to set ``CMAKE_CUDA_HOST_COMPILER`` without also + setting ``CMAKE_CUDA_COMPILER`` to NVCC. diff --git a/Help/variable/CMAKE_ISPC_HEADER_DIRECTORY.rst b/Help/variable/CMAKE_ISPC_HEADER_DIRECTORY.rst new file mode 100644 index 0000000..a7c9cf6 --- /dev/null +++ b/Help/variable/CMAKE_ISPC_HEADER_DIRECTORY.rst @@ -0,0 +1,10 @@ +CMAKE_ISPC_HEADER_DIRECTORY +---------------------------- + +.. versionadded:: 3.19 + +ISPC generated header output directory. + +This variable is used to initialize the :prop_tgt:`ISPC_HEADER_DIRECTORY` +property on all the targets. See the target property for additional +information. diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst index cb55bc2..eb71049 100644 --- a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst +++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst @@ -17,3 +17,5 @@ One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable* to an absolute path to tell CMake to look for Windows 10 SDKs in a custom location. The specified directory is expected to contain ``Include/10.0.*`` directories. + +See also :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM`. diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst new file mode 100644 index 0000000..591ea91 --- /dev/null +++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst @@ -0,0 +1,14 @@ +CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM +------------------------------------------------ + +.. versionadded:: 3.19 + +Override the :ref:`Windows 10 SDK Maximum Version for VS 2015`. + +The :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` variable may +be set to a false value (e.g. ``OFF``, ``FALSE``, or ``0``) or the SDK version +to use as the maximum (e.g. ``10.0.14393.0``). If unset, the default depends +on which version of Visual Studio is targeted by the current generator. + +This can be used in conjunction with :variable:`CMAKE_SYSTEM_VERSION`, which +CMake uses to select :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`. diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index acd15df..a0f0dfa 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -13,7 +13,8 @@ endfunction() function(compiler_id_detection outvar lang) - if (NOT lang STREQUAL Fortran AND NOT lang STREQUAL CSharp) + if (NOT lang STREQUAL Fortran AND NOT lang STREQUAL CSharp + AND NOT lang STREQUAL ISPC) file(GLOB lang_files "${CMAKE_ROOT}/Modules/Compiler/*-DetermineCompiler.cmake") set(nonlang CXX) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index d7a35e1..8724ed8 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -110,6 +110,28 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() endif() + # For ISPC we need to explicitly query the version. + if(lang STREQUAL "ISPC" + AND CMAKE_${lang}_COMPILER + AND NOT CMAKE_${lang}_COMPILER_VERSION) + execute_process( + COMMAND "${CMAKE_${lang}_COMPILER}" + --version + OUTPUT_VARIABLE output ERROR_VARIABLE output + RESULT_VARIABLE result + TIMEOUT 10 + ) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n" + "${output}\n" + ) + + if(output MATCHES [[ISPC\), ([0-9]+\.[0-9]+(\.[0-9]+)?)]]) + set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}") + endif() + endif() + + if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" diff --git a/Modules/CMakeDetermineISPCCompiler.cmake b/Modules/CMakeDetermineISPCCompiler.cmake new file mode 100644 index 0000000..ff2bf20 --- /dev/null +++ b/Modules/CMakeDetermineISPCCompiler.cmake @@ -0,0 +1,96 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# determine the compiler to use for ISPC programs + +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) + +if( NOT (("${CMAKE_GENERATOR}" MATCHES "Make") OR ("${CMAKE_GENERATOR}" MATCHES "Ninja")) ) + message(FATAL_ERROR "ISPC language not currently supported by \"${CMAKE_GENERATOR}\" generator") +endif() + +# Load system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-ISPC OPTIONAL) +include(Platform/${CMAKE_SYSTEM_NAME}-ISPC OPTIONAL) +if(NOT CMAKE_ISPC_COMPILER_NAMES) + set(CMAKE_ISPC_COMPILER_NAMES ispc) +endif() + + +if(NOT CMAKE_ISPC_COMPILER) + + set(CMAKE_ISPC_COMPILER_INIT NOTFOUND) + + # prefer the environment variable CC + if(NOT $ENV{ISPC} STREQUAL "") + get_filename_component(CMAKE_ISPC_COMPILER_INIT $ENV{ISPC} PROGRAM PROGRAM_ARGS CMAKE_ISPC_FLAGS_ENV_INIT) + if(CMAKE_ISPC_FLAGS_ENV_INIT) + set(CMAKE_ISPC_COMPILER_ARG1 "${CMAKE_ISPC_FLAGS_ENV_INIT}" CACHE STRING "First argument to ISPC compiler") + endif() + if(NOT EXISTS ${CMAKE_ISPC_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable ISPC:\n$ENV{ISPC}.") + endif() + endif() + + # next try prefer the compiler specified by the generator + if(CMAKE_GENERATOR_ISPC) + if(NOT CMAKE_ISPC_COMPILER_INIT) + set(CMAKE_ISPC_COMPILER_INIT ${CMAKE_GENERATOR_ISPC}) + endif() + endif() + + # finally list compilers to try + if(NOT CMAKE_ISPC_COMPILER_INIT) + set(CMAKE_ISPC_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}ispc ispc) + endif() + + # Find the compiler. + _cmake_find_compiler(ISPC) + +else() + _cmake_find_compiler_path(ISPC) +endif() +mark_as_advanced(CMAKE_ISPC_COMPILER) + +if(NOT CMAKE_ISPC_COMPILER_ID_RUN) +set(CMAKE_ISPC_COMPILER_ID_RUN 1) + + # Try to identify the compiler. + set(CMAKE_ISPC_COMPILER_ID) + set(CMAKE_ISPC_PLATFORM_ID) + + + set(CMAKE_ISPC_COMPILER_ID_TEST_FLAGS_FIRST + # setup logic to make sure ISPC outputs a file + "-o cmake_ispc_output" + ) + + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(ISPC ISPCFLAGS CMakeISPCCompilerId.ispc) + + _cmake_find_compiler_sysroot(ISPC) +endif() + +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ISPC_COMPILER}" PATH) +endif () + +set(_CMAKE_PROCESSING_LANGUAGE "ISPC") +include(CMakeFindBinUtils) +include(Compiler/${CMAKE_ISPC_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + +if(CMAKE_ISPC_COMPILER_ID_VENDOR_MATCH) + set(_SET_CMAKE_ISPC_COMPILER_ID_VENDOR_MATCH + "set(CMAKE_ISPC_COMPILER_ID_VENDOR_MATCH [==[${CMAKE_ISPC_COMPILER_ID_VENDOR_MATCH}]==])") +else() + set(_SET_CMAKE_ISPC_COMPILER_ID_VENDOR_MATCH "") +endif() + + +# configure variables set in this file for fast reload later on +configure_file(${CMAKE_ROOT}/Modules/CMakeISPCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeISPCCompiler.cmake @ONLY) + +set(CMAKE_ISPC_COMPILER_ENV_VAR "ISPC") diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index b2004f1..66adafa 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -66,6 +66,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC" OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xPGI") OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xNVIDIA") + OR (CMAKE_HOST_WIN32 AND "x${_CMAKE_PROCESSING_LANGUAGE}" STREQUAL "xISPC") OR (CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) diff --git a/Modules/CMakeISPCCompiler.cmake.in b/Modules/CMakeISPCCompiler.cmake.in new file mode 100644 index 0000000..28c31cc --- /dev/null +++ b/Modules/CMakeISPCCompiler.cmake.in @@ -0,0 +1,30 @@ +set(CMAKE_ISPC_COMPILER "@CMAKE_ISPC_COMPILER@") +set(CMAKE_ISPC_COMPILER_ARG1 "@CMAKE_ISPC_COMPILER_ARG1@") +set(CMAKE_ISPC_COMPILER_ID "@CMAKE_ISPC_COMPILER_ID@") +set(CMAKE_ISPC_COMPILER_VERSION "@CMAKE_ISPC_COMPILER_VERSION@") +set(CMAKE_ISPC_COMPILER_VERSION_INTERNAL "@CMAKE_ISPC_COMPILER_VERSION_INTERNAL@") + +set(CMAKE_ISPC_PLATFORM_ID "@CMAKE_ISPC_PLATFORM_ID@") +set(CMAKE_ISPC_SIMULATE_ID "@CMAKE_ISPC_SIMULATE_ID@") +set(CMAKE_ISPC_COMPILER_FRONTEND_VARIANT "@CMAKE_ISPC_COMPILER_FRONTEND_VARIANT@") +set(CMAKE_ISPC_SIMULATE_VERSION "@CMAKE_ISPC_SIMULATE_VERSION@") + +set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_ISPC_COMPILER_AR "@CMAKE_ISPC_COMPILER_AR@") +set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_ISPC_COMPILER_RANLIB "@CMAKE_ISPC_COMPILER_RANLIB@") + +set(CMAKE_ISPC_COMPILER_LOADED 1) +set(CMAKE_ISPC_COMPILER_WORKS @CMAKE_ISPC_COMPILER_WORKS@) +set(CMAKE_ISPC_ABI_COMPILED @CMAKE_ISPC_ABI_COMPILED@) + +set(CMAKE_ISPC_COMPILER_ENV_VAR "ISPC") + +set(CMAKE_ISPC_COMPILER_ID_RUN 1) +set(CMAKE_ISPC_SOURCE_FILE_EXTENSIONS ispc) +set(CMAKE_ISPC_IGNORE_EXTENSIONS o;O) + +set(CMAKE_ISPC_LINKER_PREFERENCE 0) +set(CMAKE_ISPC_LINKER_PREFERENCE_PROPAGATES 0) + +@CMAKE_ISPC_COMPILER_CUSTOM_CODE@ diff --git a/Modules/CMakeISPCCompilerABI.ispc b/Modules/CMakeISPCCompilerABI.ispc new file mode 100644 index 0000000..e23abce --- /dev/null +++ b/Modules/CMakeISPCCompilerABI.ispc @@ -0,0 +1,20 @@ + +export void ispcCompilerABI() { + +#if defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__) + print("INFO:abi[ELF ARMEABI]"); + static char const info_abi[] = +#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEB__) + print("INFO:abi[ELF ARM]"); +#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__) + print("INFO:abi[ELF ARM]"); + +#elif defined(__linux__) && defined(__ELF__) && defined(__amd64__) && \ + defined(__ILP32__) +print("INFO:abi[ELF X32]"); + +#elif defined(__ELF__) +print("INFO:abi[ELF]"); +#endif + +} diff --git a/Modules/CMakeISPCCompilerId.ispc.in b/Modules/CMakeISPCCompilerId.ispc.in new file mode 100644 index 0000000..03380f3 --- /dev/null +++ b/Modules/CMakeISPCCompilerId.ispc.in @@ -0,0 +1,62 @@ + +export void ispcCompilerId() { + +// Identify the compiler +#if defined(ISPC) + print("INFO:compiler[Intel]"); +#endif + +// Identify the platform +#if defined(__linux) || defined(__linux__) || defined(linux) + print("INFO:platform[Linux]"); +#elif defined(__CYGWIN__) + print("INFO:platform[Cygwin]"); +#elif defined(__MINGW32__) + print("INFO:platform[MinGW]"); +#elif defined(__APPLE__) + print("INFO:platform[Darwin]"); +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) + print("INFO:platform[Windows]"); +#elif defined(__FreeBSD__) || defined(__FreeBSD) + print("INFO:platform[FreeBSD]"); +#elif defined(__NetBSD__) || defined(__NetBSD) + print("INFO:platform[NetBSD]"); +#elif defined(__OpenBSD__) || defined(__OPENBSD) + print("INFO:platform[OpenBSD]"); +#elif defined(__sun) || defined(sun) + print("INFO:platform[SunOS]"); +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) + print("INFO:platform[AIX]"); +#elif defined(__hpux) || defined(__hpux__) + print("INFO:platform[HP-UX]"); +#elif defined(__HAIKU__) + print("INFO:platform[Haiku]"); +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) + print("INFO:platform[BeOS]"); +#elif defined(__QNX__) || defined(__QNXNTO__) + print("INFO:platform[QNX]"); +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) + print("INFO:platform[Tru64]"); +#elif defined(__riscos) || defined(__riscos__) + print("INFO:platform[RISCos]"); +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) + print("INFO:platform[SINIX]"); +#elif defined(__UNIX_SV__) + print("INFO:platform[UNIX_SV]"); +#elif defined(__bsdos__) + print("INFO:platform[BSDOS]"); +#elif defined(_MPRAS) || defined(MPRAS) + print("INFO:platform[MP-RAS]"); +#elif defined(__osf) || defined(__osf__) + print("INFO:platform[OSF1]"); +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) + print("INFO:platform[SCO_SV]"); +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) + print("INFO:platform[ULTRIX]"); +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) + print("INFO:platform[Xenix]"); +#else + print("INFO:platform[]"); +#endif + +} diff --git a/Modules/CMakeISPCInformation.cmake b/Modules/CMakeISPCInformation.cmake new file mode 100644 index 0000000..514036e --- /dev/null +++ b/Modules/CMakeISPCInformation.cmake @@ -0,0 +1,56 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set(CMAKE_ISPC_OUTPUT_EXTENSION .o) +set(CMAKE_INCLUDE_FLAG_ISPC "-I") + +# Load compiler-specific information. +if(CMAKE_ISPC_COMPILER_ID) + include(Compiler/${CMAKE_ISPC_COMPILER_ID}-ISPC OPTIONAL) +endif() + +# load the system- and compiler specific files +if(CMAKE_ISPC_COMPILER_ID) + # load a hardware specific file, mostly useful for embedded compilers + if(CMAKE_SYSTEM_PROCESSOR) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_ISPC_COMPILER_ID}-ISPC-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + endif() + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_ISPC_COMPILER_ID}-ISPC OPTIONAL) +endif() + +# add the flags to the cache based +# on the initial values computed in the platform/*.cmake files +# use _INIT variables so that this only happens the first time +# and you can set these flags in the cmake cache +set(CMAKE_ISPC_FLAGS_INIT "$ENV{ISPCFLAGS} ${CMAKE_ISPC_FLAGS_INIT}") + +cmake_initialize_per_config_variable(CMAKE_ISPC_FLAGS "Flags used by the ISPC compiler") + +if(CMAKE_ISPC_STANDARD_LIBRARIES_INIT) + set(CMAKE_ISPC_STANDARD_LIBRARIES "${CMAKE_ISPC_STANDARD_LIBRARIES_INIT}" + CACHE STRING "Libraries linked by default with all ISPC applications.") + mark_as_advanced(CMAKE_ISPC_STANDARD_LIBRARIES) +endif() + +include(CMakeCommonLanguageInclude) + +# now define the following rules: +# CMAKE_ISPC_COMPILE_OBJECT + +# Create a static archive incrementally for large object file counts. +if(NOT DEFINED CMAKE_ISPC_ARCHIVE_CREATE) + set(CMAKE_ISPC_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") +endif() +if(NOT DEFINED CMAKE_ISPC_ARCHIVE_APPEND) + set(CMAKE_ISPC_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") +endif() +if(NOT DEFINED CMAKE_ISPC_ARCHIVE_FINISH) + set(CMAKE_ISPC_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") +endif() + +if(NOT CMAKE_ISPC_COMPILE_OBJECT) + set(CMAKE_ISPC_COMPILE_OBJECT + "<CMAKE_ISPC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> --emit-obj <SOURCE> -h <ISPC_HEADER>") +endif() + +set(CMAKE_ISPC_INFORMATION_LOADED 1) diff --git a/Modules/CMakeTestISPCCompiler.cmake b/Modules/CMakeTestISPCCompiler.cmake new file mode 100644 index 0000000..6b16393 --- /dev/null +++ b/Modules/CMakeTestISPCCompiler.cmake @@ -0,0 +1,43 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + + +if(CMAKE_ISPC_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + set(CMAKE_ISPC_COMPILER_WORKS TRUE) + return() +endif() + +include(CMakeTestCompilerCommon) + +# Make sure we try to compile as a STATIC_LIBRARY +set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +# # Try to identify the ABI and configure it into CMakeISPCCompiler.cmake +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) +CMAKE_DETERMINE_COMPILER_ABI(ISPC ${CMAKE_ROOT}/Modules/CMakeISPCCompilerABI.ispc) +if(CMAKE_ISPC_ABI_COMPILED) +# # The compiler worked so skip dedicated test below. + set(CMAKE_ISPC_COMPILER_WORKS TRUE) + message(STATUS "Check for working ISPC compiler: ${CMAKE_ISPC_COMPILER} - skipped") +endif() + +# Re-configure to save learned information. +configure_file( + ${CMAKE_ROOT}/Modules/CMakeISPCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeISPCCompiler.cmake + @ONLY + ) +include(${CMAKE_PLATFORM_INFO_DIR}/CMakeISPCCompiler.cmake) + +if(CMAKE_ISPC_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_ISPC_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_ISPC_ABI_FILES) +endif() + +set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) diff --git a/Modules/Compiler/Intel-ISPC.cmake b/Modules/Compiler/Intel-ISPC.cmake new file mode 100644 index 0000000..2e9792a --- /dev/null +++ b/Modules/Compiler/Intel-ISPC.cmake @@ -0,0 +1,22 @@ +include(Compiler/CMakeCommonCompilerMacros) + +# Not aware of any verbose flag for ISPC +#set(CMAKE_ISPC_VERBOSE_FLAG ) + +set(CMAKE_DEPFILE_FLAGS_ISPC "-M -MT <OBJECT> -MF <DEPFILE>") + +string(APPEND CMAKE_ISPC_FLAGS_INIT " ") +string(APPEND CMAKE_ISPC_FLAGS_DEBUG_INIT "-O0 -g") +string(APPEND CMAKE_ISPC_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") +string(APPEND CMAKE_ISPC_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG") +string(APPEND CMAKE_ISPC_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") + +set(CMAKE_ISPC_COMPILE_OPTIONS_PIE --pic) +set(CMAKE_ISPC_COMPILE_OPTIONS_PIC --pic) + +set(CMAKE_INCLUDE_SYSTEM_FLAG_ISPC -isystem=) + +set(CMAKE_ISPC_RESPONSE_FILE_FLAG "@") +set(CMAKE_ISPC_USE_RESPONSE_FILE_FOR_INCLUDES 1) +set(CMAKE_ISPC_USE_RESPONSE_FILE_FOR_LIBRARIES 1) +set(CMAKE_ISPC_USE_RESPONSE_FILE_FOR_OBJECTS 1) diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index feb5ecc..3187294 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -68,20 +68,22 @@ if(UNIX) endif() if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") + # MSVC requires c++14 as the minimum level set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "") set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "") + # MSVC requires c++14 as the minimum level set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "") set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "") if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0) - set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "") - set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14") endif() if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0) - set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "") - set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17") endif() else() diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 3a5bd31..eff815d 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -59,6 +59,8 @@ macro(java_append_library_directories _var) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") set(_java_libarch "i386") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + set(_java_libarch "arm64") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") set(_java_libarch "alpha") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 7a75004..c8c91de 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -97,6 +97,27 @@ macro(__windows_compiler_clang_gnu lang) enable_language(RC) endmacro() +macro(__enable_llvm_rc_preprocessing clang_option_prefix) + # Feed the preprocessed rc file to llvm-rc + if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc" OR CMAKE_RC_COMPILER MATCHES "llvm-rc") + if(DEFINED CMAKE_C_COMPILER_ID) + set(CMAKE_RC_PREPROCESSOR CMAKE_C_COMPILER) + elseif(DEFINED CMAKE_CXX_COMPILER_ID) + set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) + endif() + if(DEFINED CMAKE_RC_PREPROCESSOR) + set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}<DEPFILE>") + set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") + if(CMAKE_GENERATOR MATCHES "Ninja") + set(CMAKE_NINJA_CMCLDEPS_RC 0) + set(CMAKE_NINJA_DEP_TYPE_RC gcc) + endif() + unset(CMAKE_RC_PREPROCESSOR) + endif() + endif() +endmacro() + + if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") @@ -124,7 +145,10 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if(__RC_COMPILER_PATH) set(CMAKE_RC_COMPILER_INIT rc) else() - set(CMAKE_RC_COMPILER_INIT llvm-rc) + find_program(__RC_COMPILER_PATH NAMES llvm-rc) + if(__RC_COMPILER_PATH) + set(CMAKE_RC_COMPILER_INIT llvm-rc) + endif() endif() unset(__RC_COMPILER_PATH CACHE) @@ -132,25 +156,8 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) include(Platform/Windows-MSVC) - - # Feed the preprocessed rc file to llvm-rc - if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc") - if(DEFINED CMAKE_C_COMPILER_ID) - set(CMAKE_RC_PREPROCESSOR CMAKE_C_COMPILER) - elseif(DEFINED CMAKE_CXX_COMPILER_ID) - set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) - endif() - if(DEFINED CMAKE_RC_PREPROCESSOR) - set(CMAKE_DEPFILE_FLAGS_RC "-clang:-MD -clang:-MF -clang:<DEPFILE>") - set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") - if(CMAKE_GENERATOR STREQUAL "Ninja") - set(CMAKE_NINJA_CMCLDEPS_RC 0) - set(CMAKE_NINJA_DEP_TYPE_RC gcc) - endif() - unset(CMAKE_RC_PREPROCESSOR) - endif() - endif() - + # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage + __enable_llvm_rc_preprocessing("-clang:") macro(__windows_compiler_clang lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) @@ -166,6 +173,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" set(CMAKE_BUILD_TYPE_INIT Debug) + __enable_llvm_rc_preprocessing("") macro(__windows_compiler_clang lang) __windows_compiler_clang_gnu(${lang}) endmacro() @@ -173,6 +181,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" else() include(Platform/Windows-GNU) + __enable_llvm_rc_preprocessing("") macro(__windows_compiler_clang lang) __windows_compiler_gnu(${lang}) endmacro() diff --git a/Modules/Platform/Windows-Intel-ISPC.cmake b/Modules/Platform/Windows-Intel-ISPC.cmake new file mode 100644 index 0000000..cd26302 --- /dev/null +++ b/Modules/Platform/Windows-Intel-ISPC.cmake @@ -0,0 +1,8 @@ + +if(CMAKE_VERBOSE_MAKEFILE) + set(CMAKE_CL_NOLOGO) +else() + set(CMAKE_CL_NOLOGO "/nologo") +endif() + +set(CMAKE_ISPC_CREATE_STATIC_LIBRARY "<CMAKE_AR> ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b75eb5e..59a0707 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -496,7 +496,8 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() endif() if (SWIG_MODULE_${name}_LANGUAGE STREQUAL "PYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY) - if(NOT ("-interface" IN_LIST swig_source_file_flags OR "-interface" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS)) + if(SWIG_USE_INTERFACE AND + NOT ("-interface" IN_LIST swig_source_file_flags OR "-interface" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS)) # This makes sure that the name used in the proxy code # matches the library name created by CMake list (APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-interface" "$<TARGET_FILE_PREFIX:${target_name}>$<TARGET_FILE_BASE_NAME:${target_name}>") @@ -724,6 +725,13 @@ function(SWIG_ADD_LIBRARY name) set(swig_generated_sources) set(swig_generated_timestamps) + list(LENGTH swig_dot_i_sources swig_sources_count) + if (swig_sources_count GREATER "1") + # option -interface cannot be used + set(SWIG_USE_INTERFACE FALSE) + else() + set(SWIG_USE_INTERFACE TRUE) + endif() foreach(swig_it IN LISTS swig_dot_i_sources) SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source "${swig_it}") list (APPEND swig_generated_sources "${swig_generated_source}") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c529eec..af25ce6 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 20200825) +set(CMake_VERSION_PATCH 20200901) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 70e84ee..abd1207 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -819,14 +819,16 @@ void cmCTestTestHandler::CheckLabelFilter(cmCTestTestProperties& it) this->CheckLabelFilterExclude(it); } -void cmCTestTestHandler::ComputeTestList() +bool cmCTestTestHandler::ComputeTestList() { this->TestList.clear(); // clear list of test - this->GetListOfTests(); + if (!this->GetListOfTests()) { + return false; + } if (this->RerunFailed) { this->ComputeTestListForRerunFailed(); - return; + return true; } cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size(); @@ -882,6 +884,7 @@ void cmCTestTestHandler::ComputeTestList() this->TestList = finalList; this->UpdateMaxTestNameWidth(); + return true; } void cmCTestTestHandler::ComputeTestListForRerunFailed() @@ -1260,7 +1263,10 @@ bool cmCTestTestHandler::GetValue(const char* tag, std::string& value, bool cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, std::vector<std::string>& failed) { - this->ComputeTestList(); + if (!this->ComputeTestList()) { + return false; + } + this->StartTest = this->CTest->CurrentTime(); this->StartTestTime = std::chrono::system_clock::now(); auto elapsed_time_start = std::chrono::steady_clock::now(); @@ -1695,7 +1701,7 @@ bool cmCTestTestHandler::ParseResourceGroupsProperty( return lexer.ParseString(val); } -void cmCTestTestHandler::GetListOfTests() +bool cmCTestTestHandler::GetListOfTests() { if (!this->IncludeLabelRegExp.empty()) { this->IncludeLabelRegularExpression.compile( @@ -1748,14 +1754,15 @@ void cmCTestTestHandler::GetListOfTests() // does the DartTestfile.txt exist ? testFilename = "DartTestfile.txt"; } else { - return; + return true; } if (!mf.ReadListFile(testFilename)) { - return; + return false; } if (cmSystemTools::GetErrorOccuredFlag()) { - return; + // SEND_ERROR or FATAL_ERROR in CTestTestfile or TEST_INCLUDE_FILES + return false; } const char* specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE"); if (this->ResourceSpecFile.empty() && specFile) { @@ -1764,6 +1771,7 @@ void cmCTestTestHandler::GetListOfTests() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Done constructing a list of tests" << std::endl, this->Quiet); + return true; } void cmCTestTestHandler::UseIncludeRegExp() diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index b26f8a6..f9e9391 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -286,10 +286,10 @@ private: /** * Get the list of tests in directory and subdirectories. */ - void GetListOfTests(); + bool GetListOfTests(); // compute the lists of tests that will actually run // based on union regex and -I stuff - void ComputeTestList(); + bool ComputeTestList(); // compute the lists of tests that will actually run // based on LastTestFailed.log diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index a5fde89..f0ae8de 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -704,8 +704,7 @@ bool cmCTest::UpdateCTestConfiguration() if (!cmSystemTools::FileExists(fileName)) { // No need to exit if we are not producing XML if (this->Impl->ProduceXML) { - cmCTestLog(this, ERROR_MESSAGE, - "Cannot find file: " << fileName << std::endl); + cmCTestLog(this, WARNING, "Cannot find file: " << fileName << std::endl); return false; } } else { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 63c1484..b9b91f6 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -192,6 +192,8 @@ SETUP_LANGUAGE(objc_properties, OBJC); // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) SETUP_LANGUAGE(objcxx_properties, OBJCXX); // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) +SETUP_LANGUAGE(ispc_properties, ISPC); +// NOLINTNEXTLINE(bugprone-suspicious-missing-comma) SETUP_LANGUAGE(swift_properties, Swift); #undef SETUP_LANGUAGE @@ -499,6 +501,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } } + // when the only language is ISPC we know that the output + // type must by a static library + if (testLangs.size() == 1 && testLangs.count("ISPC") == 1) { + targetType = cmStateEnums::STATIC_LIBRARY; + } + std::string const tcConfig = this->Makefile->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); @@ -702,6 +710,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert( &objcxx_properties[lang_property_start], &objcxx_properties[lang_property_start + lang_property_size]); + vars.insert(&ispc_properties[lang_property_start], + &ispc_properties[lang_property_start + lang_property_size]); vars.insert(&swift_properties[lang_property_start], &swift_properties[lang_property_start + lang_property_size]); vars.insert(kCMAKE_CUDA_ARCHITECTURES); @@ -744,6 +754,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert( &objcxx_properties[pie_property_start], &objcxx_properties[pie_property_start + pie_property_size]); + vars.insert(&ispc_properties[pie_property_start], + &ispc_properties[pie_property_start + pie_property_size]); vars.insert(&swift_properties[pie_property_start], &swift_properties[pie_property_start + pie_property_size]); } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index fdc8f29..83e9aac 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -715,7 +715,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode static const CompilerIdNode cCompilerIdNode("C"), cxxCompilerIdNode("CXX"), cudaCompilerIdNode("CUDA"), objcCompilerIdNode("OBJC"), - objcxxCompilerIdNode("OBJCXX"), fortranCompilerIdNode("Fortran"); + objcxxCompilerIdNode("OBJCXX"), fortranCompilerIdNode("Fortran"), + ispcCompilerIdNode("ISPC"); struct CompilerVersionNode : public cmGeneratorExpressionNode { @@ -780,7 +781,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode static const CompilerVersionNode cCompilerVersionNode("C"), cxxCompilerVersionNode("CXX"), cudaCompilerVersionNode("CUDA"), objcCompilerVersionNode("OBJC"), objcxxCompilerVersionNode("OBJCXX"), - fortranCompilerVersionNode("Fortran"); + fortranCompilerVersionNode("Fortran"), ispcCompilerVersionNode("ISPC"); struct PlatformIdNode : public cmGeneratorExpressionNode { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7c526a0..dc5265f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1363,18 +1363,25 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( } namespace { -std::string AddSwiftInterfaceIncludeDirectories( + +enum class IncludeDirectoryFallBack +{ + BINARY, + OBJECT +}; + +std::string AddLangSpecificInterfaceIncludeDirectories( const cmGeneratorTarget* root, const cmGeneratorTarget* target, - const std::string& config, cmGeneratorExpressionDAGChecker* context) + const std::string& lang, const std::string& config, + const std::string& propertyName, IncludeDirectoryFallBack mode, + cmGeneratorExpressionDAGChecker* context) { cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(), target, - "Swift_MODULE_DIRECTORY", nullptr, - context }; + propertyName, nullptr, context }; switch (dag.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: - dag.ReportError(nullptr, - "$<TARGET_PROPERTY:" + target->GetName() + - ",Swift_MODULE_DIRECTORY>"); + dag.ReportError( + nullptr, "$<TARGET_PROPERTY:" + target->GetName() + ",propertyName"); CM_FALLTHROUGH; case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: // No error. We just skip cyclic references. @@ -1390,13 +1397,16 @@ std::string AddSwiftInterfaceIncludeDirectories( target->GetLinkInterfaceLibraries(config, root, true)) { for (const cmLinkItem& library : interface->Libraries) { if (const cmGeneratorTarget* dependency = library.Target) { - if (cm::contains(dependency->GetAllConfigCompileLanguages(), - "Swift")) { - std::string value = - dependency->GetSafeProperty("Swift_MODULE_DIRECTORY"); + if (cm::contains(dependency->GetAllConfigCompileLanguages(), lang)) { + auto* lg = dependency->GetLocalGenerator(); + std::string value = dependency->GetSafeProperty(propertyName); if (value.empty()) { - value = - dependency->GetLocalGenerator()->GetCurrentBinaryDirectory(); + if (mode == IncludeDirectoryFallBack::BINARY) { + value = lg->GetCurrentBinaryDirectory(); + } else if (mode == IncludeDirectoryFallBack::OBJECT) { + value = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', + lg->GetTargetDirectory(dependency)); + } } if (!directories.empty()) { @@ -1410,35 +1420,39 @@ std::string AddSwiftInterfaceIncludeDirectories( return directories; } -void AddSwiftImplicitIncludeDirectories( - const cmGeneratorTarget* target, const std::string& config, - EvaluatedTargetPropertyEntries& entries) +void AddLangSpecificImplicitIncludeDirectories( + const cmGeneratorTarget* target, const std::string& lang, + const std::string& config, const std::string& propertyName, + IncludeDirectoryFallBack mode, EvaluatedTargetPropertyEntries& entries) { if (const auto* libraries = target->GetLinkImplementationLibraries(config)) { cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(), target, - "Swift_MODULE_DIRECTORY", nullptr, - nullptr }; + propertyName, nullptr, nullptr }; for (const cmLinkImplItem& library : libraries->Libraries) { if (const cmGeneratorTarget* dependency = library.Target) { if (!dependency->IsInBuildSystem()) { continue; } - if (cm::contains(dependency->GetAllConfigCompileLanguages(), - "Swift")) { + if (cm::contains(dependency->GetAllConfigCompileLanguages(), lang)) { + auto* lg = dependency->GetLocalGenerator(); EvaluatedTargetPropertyEntry entry{ library, library.Backtrace }; - if (cmProp val = dependency->GetProperty("Swift_MODULE_DIRECTORY")) { + if (cmProp val = dependency->GetProperty(propertyName)) { entry.Values.emplace_back(*val); } else { - entry.Values.emplace_back( - dependency->GetLocalGenerator()->GetCurrentBinaryDirectory()); + if (mode == IncludeDirectoryFallBack::BINARY) { + entry.Values.emplace_back(lg->GetCurrentBinaryDirectory()); + } else if (mode == IncludeDirectoryFallBack::OBJECT) { + entry.Values.emplace_back( + dependency->GetObjectDirectory(config)); + } } - cmExpandList(AddSwiftInterfaceIncludeDirectories(target, dependency, - config, &dag), - entry.Values); - + cmExpandList( + AddLangSpecificInterfaceIncludeDirectories( + target, dependency, lang, config, propertyName, mode, &dag), + entry.Values); entries.Entries.emplace_back(std::move(entry)); } } @@ -3482,7 +3496,28 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( this, config, lang, &dagChecker, this->IncludeDirectoriesEntries); if (lang == "Swift") { - AddSwiftImplicitIncludeDirectories(this, config, entries); + AddLangSpecificImplicitIncludeDirectories( + this, lang, config, "Swift_MODULE_DIRECTORY", + IncludeDirectoryFallBack::BINARY, entries); + } + + if (this->CanCompileSources() && (lang != "Swift" && lang != "Fortran")) { + + const std::string propertyName = "ISPC_HEADER_DIRECTORY"; + + // If this target has ISPC sources make sure to add the header + // directory to other compilation units + if (cm::contains(this->GetAllConfigCompileLanguages(), "ISPC")) { + if (cmProp val = this->GetProperty(propertyName)) { + includes.emplace_back(*val); + } else { + includes.emplace_back(this->GetObjectDirectory(config)); + } + } + + AddLangSpecificImplicitIncludeDirectories( + this, "ISPC", config, propertyName, IncludeDirectoryFallBack::OBJECT, + entries); } AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES", lang, @@ -5976,6 +6011,37 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory( return mod_dir; } +void cmGeneratorTarget::AddISPCGeneratedHeader(std::string const& header, + std::string const& config) +{ + std::string config_upper; + if (!config.empty()) { + config_upper = cmSystemTools::UpperCase(config); + } + auto iter = this->ISPCGeneratedHeaders.find(config_upper); + if (iter == this->ISPCGeneratedHeaders.end()) { + std::vector<std::string> headers; + headers.emplace_back(header); + this->ISPCGeneratedHeaders.insert({ config_upper, headers }); + } else { + iter->second.emplace_back(header); + } +} + +std::vector<std::string> cmGeneratorTarget::GetGeneratedISPCHeaders( + std::string const& config) const +{ + std::string config_upper; + if (!config.empty()) { + config_upper = cmSystemTools::UpperCase(config); + } + auto iter = this->ISPCGeneratedHeaders.find(config_upper); + if (iter == this->ISPCGeneratedHeaders.end()) { + return std::vector<std::string>{}; + } + return iter->second; +} + std::string cmGeneratorTarget::GetFrameworkVersion() const { assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 544b27a..246eede 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -816,6 +816,11 @@ public: const std::string& GetSourcesProperty() const; + void AddISPCGeneratedHeader(std::string const& header, + std::string const& config); + std::vector<std::string> GetGeneratedISPCHeaders( + std::string const& config) const; + private: void AddSourceCommon(const std::string& src, bool before = false); @@ -994,6 +999,9 @@ private: std::unordered_set<std::string> UnityBatchedSourceFiles; + std::unordered_map<std::string, std::vector<std::string>> + ISPCGeneratedHeaders; + bool IsLinkLookupScope(std::string const& n, cmLocalGenerator const*& lg) const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a192ffd..a550b50 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1601,6 +1601,7 @@ bool cmGlobalGenerator::AddAutomaticSources() continue; } lg->AddUnityBuild(gt.get()); + lg->AddISPCDependencies(gt.get()); // Targets that re-use a PCH are handled below. if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) { lg->AddPchDependencies(gt.get()); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f0fa1f4..ed61021 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -680,6 +680,9 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() this->NinjaSupportsRestatTool = !cmSystemTools::VersionCompare( cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), RequiredNinjaVersionForRestatTool().c_str()); + this->NinjaSupportsMultipleOutputs = !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForMultipleOutputs().c_str()); } bool cmGlobalNinjaGenerator::CheckLanguages( @@ -688,6 +691,9 @@ bool cmGlobalNinjaGenerator::CheckLanguages( if (cm::contains(languages, "Fortran")) { return this->CheckFortran(mf); } + if (cm::contains(languages, "ISPC")) { + return this->CheckISPC(mf); + } if (cm::contains(languages, "Swift")) { const std::string architectures = mf->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES"); @@ -721,6 +727,25 @@ bool cmGlobalNinjaGenerator::CheckFortran(cmMakefile* mf) const return false; } +bool cmGlobalNinjaGenerator::CheckISPC(cmMakefile* mf) const +{ + if (this->NinjaSupportsMultipleOutputs) { + return true; + } + + std::ostringstream e; + /* clang-format off */ + e << + "The Ninja generator does not support ISPC using Ninja version\n" + " " << this->NinjaVersion << "\n" + "due to lack of required features. Ninja 1.10 or higher is required." + ; + /* clang-format on */ + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; +} + void cmGlobalNinjaGenerator::EnableLanguage( std::vector<std::string> const& langs, cmMakefile* mf, bool optional) { @@ -1127,6 +1152,21 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( } } else { cmNinjaDeps outs; + + auto computeISPCOuputs = [](cmGlobalNinjaGenerator* gg, + cmGeneratorTarget const* depTarget, + cmNinjaDeps& outputDeps, + const std::string& targetConfig) { + if (depTarget->CanCompileSources()) { + auto headers = depTarget->GetGeneratedISPCHeaders(targetConfig); + if (!headers.empty()) { + std::transform(headers.begin(), headers.end(), headers.begin(), + gg->MapToNinjaPath()); + outputDeps.insert(outputDeps.end(), headers.begin(), headers.end()); + } + } + }; + for (cmTargetDepend const& targetDep : this->GetTargetDirectDepends(target)) { if (!targetDep->IsInBuildSystem()) { @@ -1134,8 +1174,10 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( } if (targetDep.IsCross()) { this->AppendTargetOutputs(targetDep, outs, fileConfig, depends); + computeISPCOuputs(this, targetDep, outs, fileConfig); } else { this->AppendTargetOutputs(targetDep, outs, config, depends); + computeISPCOuputs(this, targetDep, outs, config); } } std::sort(outs.begin(), outs.end()); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 10f5cf6..0881ce0 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -370,6 +370,10 @@ public: return "1.10"; } static std::string RequiredNinjaVersionForCleanDeadTool() { return "1.10"; } + static std::string RequiredNinjaVersionForMultipleOutputs() + { + return "1.10"; + } bool SupportsConsolePool() const; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; @@ -447,6 +451,7 @@ private: bool CheckLanguages(std::vector<std::string> const& languages, cmMakefile* mf) const override; bool CheckFortran(cmMakefile* mf) const; + bool CheckISPC(cmMakefile* mf) const; void CloseCompileCommandsStream(); @@ -533,6 +538,7 @@ private: bool NinjaSupportsRestatTool = false; bool NinjaSupportsUnconditionalRecompactTool = false; bool NinjaSupportsCleanDeadTool = false; + bool NinjaSupportsMultipleOutputs = false; private: void InitOutputPathPrefix(); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 451d448..aa1b7ad 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -169,7 +169,8 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, bool required) { // Find the default version of the Windows 10 SDK. - std::string const version = this->GetWindows10SDKVersion(); + std::string const version = this->GetWindows10SDKVersion(mf); + if (required && version.empty()) { std::ostringstream e; e << "Could not find an appropriate version of the Windows 10 SDK" @@ -233,8 +234,25 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const cmSystemTools::KeyWOW64_32); } -std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion() const +std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion( + cmMakefile* mf) const { + // if the given value is set, it can either be OFF/FALSE or a valid SDK + // string + if (std::string const* value = + mf->GetDef("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM")) { + + // If the value is some off/false value, then there is NO maximum set. + if (cmIsOff(value)) { + return std::string(); + } + // If the value is something else, trust that it is a valid SDK value. + else if (value) { + return *value; + } + // If value is an invalid pointer, leave result unchanged. + } + // The last Windows 10 SDK version that VS 2015 can target is 10.0.14393.0. // // "VS 2015 Users: The Windows 10 SDK (15063, 16299, 17134, 17763) is @@ -267,7 +285,8 @@ public: }; #endif -std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() +std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( + cmMakefile* mf) { #if defined(_WIN32) && !defined(__CYGWIN__) std::vector<std::string> win10Roots; @@ -317,8 +336,10 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() i = cmSystemTools::GetFilenameName(i); } - // Skip SDKs that cannot be used with our toolset. - std::string maxVersion = this->GetWindows10SDKMaxVersion(); + // Skip SDKs that cannot be used with our toolset, unless the user does not + // want to limit the highest supported SDK according to the Microsoft + // documentation. + std::string maxVersion = this->GetWindows10SDKMaxVersion(mf); if (!maxVersion.empty()) { cm::erase_if(sdks, WindowsSDKTooRecent(maxVersion)); } diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 39353f2..2b9a649 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -43,7 +43,7 @@ protected: // Used to make sure that the Windows 10 SDK selected can work with the // version of the toolset. - virtual std::string GetWindows10SDKMaxVersion() const; + virtual std::string GetWindows10SDKMaxVersion(cmMakefile* mf) const; virtual bool SelectWindows10SDK(cmMakefile* mf, bool required); @@ -54,7 +54,7 @@ protected: // installed on the machine. bool IsWindowsDesktopToolsetInstalled() const override; - std::string GetWindows10SDKVersion(); + std::string GetWindows10SDKVersion(cmMakefile* mf); private: class Factory; diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index e2e045c..4b877ce 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -540,8 +540,8 @@ bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const return false; } -std::string cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersion() - const +std::string cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersion( + cmMakefile*) const { return std::string(); } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index d5b8337..289c35c 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -57,7 +57,7 @@ protected: // Check for a Win 8 SDK known to the registry or VS installer tool. bool IsWin81SDKInstalled() const; - std::string GetWindows10SDKMaxVersion() const override; + std::string GetWindows10SDKMaxVersion(cmMakefile*) const override; std::string FindMSBuildCommand() override; std::string FindDevEnvCommand() override; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 40010fc..300bb26 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2426,6 +2426,38 @@ void cmLocalGenerator::AppendFlagEscape(std::string& flags, this->EscapeForShell(rawFlag, false, false, false, this->IsNinjaMulti())); } +void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target) +{ + // + std::vector<std::string> configsList = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + for (std::string const& config : configsList) { + + std::string perConfigDir = target->GetObjectDirectory(config); + if (cmProp prop = target->GetProperty("ISPC_HEADER_DIRECTORY")) { + perConfigDir = cmSystemTools::CollapseFullPath( + cmStrCat(this->GetBinaryDirectory(), '/', *prop)); + } + + std::vector<cmSourceFile*> sources; + target->GetSourceFiles(sources, config); + + // build up the list of ispc headers that this target is generating + for (cmSourceFile const* sf : sources) { + // Generate this object file's rule file. + const std::string& lang = sf->GetLanguage(); + if (lang == "ISPC") { + std::string const& objectName = target->GetObjectName(sf); + std::string ispcSource = + cmSystemTools::GetFilenameWithoutLastExtension(objectName); + + auto headerPath = cmStrCat(perConfigDir, '/', ispcSource, ".h"); + target->AddISPCGeneratedHeader(headerPath, config); + } + } + } +} + void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) { std::vector<std::string> configsList = diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 0c51a65..cf2bce1 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -133,6 +133,7 @@ public: const std::vector<BT<std::string>>& newFlags) const; virtual void AppendFlagEscape(std::string& flags, const std::string& rawFlag) const; + void AddISPCDependencies(cmGeneratorTarget* target); void AddPchDependencies(cmGeneratorTarget* target); void AddUnityBuild(cmGeneratorTarget* target); void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 8acd1e3..26b0989 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -235,7 +235,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() for (LocalObjectEntry const& entry : localObjectFile.second) { if (entry.Language == "C" || entry.Language == "CXX" || - entry.Language == "CUDA" || entry.Language == "Fortran") { + entry.Language == "CUDA" || entry.Language == "Fortran" || + entry.Language == "ISPC") { // Right now, C, C++, Fortran and CUDA have both a preprocessor and the // ability to generate assembly code lang_has_preprocessor = true; @@ -1444,7 +1445,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // Create the scanner for this language std::unique_ptr<cmDepends> scanner; if (lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM" || - lang == "OBJC" || lang == "OBJCXX" || lang == "CUDA") { + lang == "OBJC" || lang == "OBJCXX" || lang == "CUDA" || + lang == "ISPC") { // TODO: Handle RC (resource files) dependencies correctly. scanner = cm::make_unique<cmDependsC>(this, targetDir, lang, &validDeps); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index fae1d76..afbbbd4 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -268,6 +268,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->ExternalObjects.push_back(objectFileName); } } + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources, this->GetConfigName()); @@ -525,6 +526,14 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } } + if (lang != "ISPC") { + auto const& headers = + this->GeneratorTarget->GetGeneratedISPCHeaders(config); + if (!headers.empty()) { + depends.insert(depends.end(), headers.begin(), headers.end()); + } + } + std::string relativeObj = cmStrCat(this->LocalGenerator->GetHomeRelativeOutputPath(), obj); // Write the build rule. @@ -552,6 +561,23 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( this->AppendFortranPreprocessFlags(flags, source); } + std::string ispcHeaderRelative; + std::string ispcHeaderForShell; + if (lang == "ISPC") { + std::string ispcSource = + cmSystemTools::GetFilenameWithoutLastExtension(objectName); + + std::string directory = this->GeneratorTarget->GetObjectDirectory(config); + if (cmProp prop = + this->GeneratorTarget->GetProperty("ISPC_HEADER_DIRECTORY")) { + directory = + cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', *prop); + } + ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, ".h"); + ispcHeaderForShell = this->LocalGenerator->ConvertToOutputFormat( + ispcHeaderRelative, cmOutputConverter::SHELL); + } + // Add flags from source file properties. const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (cmProp cflags = source.GetProperty(COMPILE_FLAGS)) { @@ -717,6 +743,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( cmOutputConverter::SHELL); vars.ObjectFileDir = objectFileDir.c_str(); vars.Flags = flags.c_str(); + vars.ISPCHeader = ispcHeaderForShell.c_str(); std::string definesString = cmStrCat("$(", lang, "_DEFINES)"); @@ -735,7 +762,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // ability to export compile commands bool lang_has_preprocessor = ((lang == "C") || (lang == "CXX") || (lang == "OBJC") || - (lang == "OBJCXX") || (lang == "Fortran") || (lang == "CUDA")); + (lang == "OBJCXX") || (lang == "Fortran") || (lang == "CUDA") || + lang == "ISPC"); bool const lang_has_assembly = lang_has_preprocessor; bool const lang_can_export_cmds = lang_has_preprocessor; @@ -910,9 +938,16 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( if (!evaluated_outputs.empty()) { // Register these as extra files to clean. cmExpandList(evaluated_outputs, outputs); - this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); } } + if (!ispcHeaderRelative + .empty()) { // can't move ispcHeader as vars is using it + outputs.emplace_back(ispcHeaderRelative); + } + + if (outputs.size() > 1) { + this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); + } // Write the rule. this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends, diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 57f526e..96e0c69 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -631,6 +631,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, vars.TargetCompilePDB = "$TARGET_COMPILE_PDB"; vars.ObjectDir = "$OBJECT_DIR"; vars.ObjectFileDir = "$OBJECT_FILE_DIR"; + vars.ISPCHeader = "$ISPC_HEADER_FILE"; cmMakefile* mf = this->GetMakefile(); @@ -1369,6 +1370,42 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( objBuild.RspFile = cmStrCat(objectFileName, ".rsp"); + if (language == "ISPC") { + std::string const& objectName = + this->GeneratorTarget->GetObjectName(source); + std::string ispcSource = + cmSystemTools::GetFilenameWithoutLastExtension(objectName); + + std::string ispcDirectory = objectFileDir; + if (cmProp prop = + this->GeneratorTarget->GetProperty("ISPC_HEADER_DIRECTORY")) { + ispcDirectory = *prop; + } + ispcDirectory = + cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', ispcDirectory); + + std::string ispcHeader = cmStrCat(ispcDirectory, '/', ispcSource, ".h"); + ispcHeader = this->ConvertToNinjaPath(ispcHeader); + + // Make sure ninja knows what command generates the header + objBuild.ImplicitOuts.push_back(ispcHeader); + + // Make sure ninja knows how to clean the generated header + this->GetGlobalGenerator()->AddAdditionalCleanFile(ispcHeader, config); + + vars["ISPC_HEADER_FILE"] = + this->GetLocalGenerator()->ConvertToOutputFormat( + ispcHeader, cmOutputConverter::SHELL); + } else { + auto headers = this->GeneratorTarget->GetGeneratedISPCHeaders(config); + if (!headers.empty()) { + std::transform(headers.begin(), headers.end(), headers.begin(), + MapToNinjaPath()); + objBuild.OrderOnlyDeps.insert(objBuild.OrderOnlyDeps.end(), + headers.begin(), headers.end()); + } + } + if (language == "Swift") { this->EmitSwiftDependencyInfo(source, config); } else { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 8c2cacd..187b256 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1517,6 +1517,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() info.SetConfig("PARSE_CACHE_FILE", this->AutogenTarget.ParseCacheFile); info.Set("DEP_FILE", this->AutogenTarget.DepFile); info.Set("DEP_FILE_RULE_NAME", this->AutogenTarget.DepFileRuleName); + info.SetArray("CMAKE_LIST_FILES", this->Makefile->GetListFiles()); info.SetArray("HEADER_EXTENSIONS", this->Makefile->GetCMakeInstance()->GetHeaderExtensions()); info.SetArrayArray( diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index f6cccfb..71c288c 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -184,6 +184,7 @@ public: std::string DepFile; std::string DepFileRuleName; std::vector<std::string> HeaderExtensions; + std::vector<std::string> ListFiles; }; /** Shared common variables. */ @@ -2176,7 +2177,7 @@ void cmQtAutoMocUicT::JobDepFilesMergeT::Process() return dependenciesFromDepFile(f.c_str()); }; - std::vector<std::string> dependencies; + std::vector<std::string> dependencies = BaseConst().ListFiles; ParseCacheT& parseCache = BaseEval().ParseCache; auto processMappingEntry = [&](const MappingMapT::value_type& m) { auto cacheEntry = parseCache.GetOrInsert(m.first); @@ -2257,6 +2258,7 @@ bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info) !info.GetString("DEP_FILE_RULE_NAME", BaseConst_.DepFileRuleName, false) || !info.GetStringConfig("SETTINGS_FILE", SettingsFile_, true) || + !info.GetArray("CMAKE_LIST_FILES", BaseConst_.ListFiles, true) || !info.GetArray("HEADER_EXTENSIONS", BaseConst_.HeaderExtensions, true) || !info.GetString("QT_MOC_EXECUTABLE", MocConst_.Executable, false) || !info.GetString("QT_UIC_EXECUTABLE", UicConst_.Executable, false)) { diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 4ff81c1..6f40ec6 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -90,6 +90,11 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return replaceValues.AIXExports; } } + if (replaceValues.ISPCHeader) { + if (variable == "ISPC_HEADER") { + return replaceValues.ISPCHeader; + } + } if (replaceValues.Defines && variable == "DEFINES") { return replaceValues.Defines; } diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index 09e8a3b..96e731f 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -64,6 +64,7 @@ public: const char* SwiftModuleName; const char* SwiftOutputFileMap; const char* SwiftSources; + const char* ISPCHeader; }; // Expand rule variables in CMake of the type found in language rules diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 798c29a..87176d6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -749,33 +749,140 @@ std::string cmSystemTools::FileExistsInParentDirectories( } #ifdef _WIN32 -cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry() +namespace { + +/* Helper class to save and restore the specified file (or directory) + attribute bits. Instantiate this class as an automatic variable on the + stack. Its constructor saves a copy of the file attributes, and then its + destructor restores the original attribute settings. */ +class SaveRestoreFileAttributes { - static WindowsFileRetry retry = { 0, 0 }; - if (!retry.Count) { - unsigned int data[2] = { 0, 0 }; - HKEY const keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }; - wchar_t const* const values[2] = { L"FilesystemRetryCount", - L"FilesystemRetryDelay" }; - for (int k = 0; k < 2; ++k) { - HKEY hKey; - if (RegOpenKeyExW(keys[k], L"Software\\Kitware\\CMake\\Config", 0, - KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - for (int v = 0; v < 2; ++v) { - DWORD dwData, dwType, dwSize = 4; - if (!data[v] && - RegQueryValueExW(hKey, values[v], 0, &dwType, (BYTE*)&dwData, - &dwSize) == ERROR_SUCCESS && - dwType == REG_DWORD && dwSize == 4) { - data[v] = static_cast<unsigned int>(dwData); - } +public: + SaveRestoreFileAttributes(std::wstring const& path, + uint32_t file_attrs_to_set); + ~SaveRestoreFileAttributes(); + + SaveRestoreFileAttributes(SaveRestoreFileAttributes const&) = delete; + SaveRestoreFileAttributes& operator=(SaveRestoreFileAttributes const&) = + delete; + + void SetPath(std::wstring const& path) { path_ = path; } + +private: + std::wstring path_; + uint32_t original_attr_bits_; +}; + +SaveRestoreFileAttributes::SaveRestoreFileAttributes( + std::wstring const& path, uint32_t file_attrs_to_set) + : path_(path) + , original_attr_bits_(0) +{ + // Set the specified attributes for the source file/directory. + original_attr_bits_ = GetFileAttributesW(path_.c_str()); + if ((INVALID_FILE_ATTRIBUTES != original_attr_bits_) && + ((file_attrs_to_set & original_attr_bits_) != file_attrs_to_set)) { + SetFileAttributesW(path_.c_str(), original_attr_bits_ | file_attrs_to_set); + } +} + +// We set attribute bits. Now we need to restore their original state. +SaveRestoreFileAttributes::~SaveRestoreFileAttributes() +{ + DWORD last_error = GetLastError(); + // Verify or restore the original attributes. + const DWORD source_attr_bits = GetFileAttributesW(path_.c_str()); + if (INVALID_FILE_ATTRIBUTES != source_attr_bits) { + if (original_attr_bits_ != source_attr_bits) { + // The file still exists, and its attributes aren't our saved values. + // Time to restore them. + SetFileAttributesW(path_.c_str(), original_attr_bits_); + } + } + SetLastError(last_error); +} + +struct WindowsFileRetryInit +{ + cmSystemTools::WindowsFileRetry Retry; + bool Explicit; +}; + +WindowsFileRetryInit InitWindowsFileRetry(wchar_t const* const values[2], + unsigned int const defaults[2]) +{ + unsigned int data[2] = { 0, 0 }; + HKEY const keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }; + for (int k = 0; k < 2; ++k) { + HKEY hKey; + if (RegOpenKeyExW(keys[k], L"Software\\Kitware\\CMake\\Config", 0, + KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { + for (int v = 0; v < 2; ++v) { + DWORD dwData, dwType, dwSize = 4; + if (!data[v] && + RegQueryValueExW(hKey, values[v], 0, &dwType, (BYTE*)&dwData, + &dwSize) == ERROR_SUCCESS && + dwType == REG_DWORD && dwSize == 4) { + data[v] = static_cast<unsigned int>(dwData); } - RegCloseKey(hKey); } + RegCloseKey(hKey); } - retry.Count = data[0] ? data[0] : 5; - retry.Delay = data[1] ? data[1] : 500; } + WindowsFileRetryInit init; + init.Explicit = data[0] || data[1]; + init.Retry.Count = data[0] ? data[0] : defaults[0]; + init.Retry.Delay = data[1] ? data[1] : defaults[1]; + return init; +} + +WindowsFileRetryInit InitWindowsFileRetry() +{ + static wchar_t const* const values[2] = { L"FilesystemRetryCount", + L"FilesystemRetryDelay" }; + static unsigned int const defaults[2] = { 5, 500 }; + return InitWindowsFileRetry(values, defaults); +} + +WindowsFileRetryInit InitWindowsDirectoryRetry() +{ + static wchar_t const* const values[2] = { L"FilesystemDirectoryRetryCount", + L"FilesystemDirectoryRetryDelay" }; + static unsigned int const defaults[2] = { 120, 500 }; + WindowsFileRetryInit dirInit = InitWindowsFileRetry(values, defaults); + if (dirInit.Explicit) { + return dirInit; + } + WindowsFileRetryInit fileInit = InitWindowsFileRetry(); + if (fileInit.Explicit) { + return fileInit; + } + return dirInit; +} + +cmSystemTools::WindowsFileRetry GetWindowsRetry(std::wstring const& path) +{ + // If we are performing a directory operation, then try and get the + // appropriate timing info. + DWORD const attrs = GetFileAttributesW(path.c_str()); + if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) { + return cmSystemTools::GetWindowsDirectoryRetry(); + } + return cmSystemTools::GetWindowsFileRetry(); +} + +} // end of anonymous namespace + +cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry() +{ + static WindowsFileRetry retry = InitWindowsFileRetry().Retry; + return retry; +} + +cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsDirectoryRetry() +{ + static cmSystemTools::WindowsFileRetry retry = + InitWindowsDirectoryRetry().Retry; return retry; } #endif @@ -836,6 +943,21 @@ void cmSystemTools::InitializeLibUV() #endif } +#ifdef _WIN32 +namespace { +bool cmMoveFile(std::wstring const& oldname, std::wstring const& newname) +{ + // Not only ignore any previous error, but clear any memory of it. + SetLastError(0); + + // Use MOVEFILE_REPLACE_EXISTING to replace an existing destination file. + // Use MOVEFILE_WRITE_THROUGH to flush the change to disk before returning. + return MoveFileExW(oldname.c_str(), newname.c_str(), + MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); +} +} +#endif + bool cmSystemTools::RenameFile(const std::string& oldname, const std::string& newname) { @@ -843,35 +965,63 @@ bool cmSystemTools::RenameFile(const std::string& oldname, # ifndef INVALID_FILE_ATTRIBUTES # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) # endif + std::wstring const oldname_wstr = + SystemTools::ConvertToWindowsExtendedPath(oldname); + std::wstring const newname_wstr = + SystemTools::ConvertToWindowsExtendedPath(newname); + /* Windows MoveFileEx may not replace read-only or in-use files. If it fails then remove the read-only attribute from any existing destination. Try multiple times since we may be racing against another process creating/opening the destination file just before our MoveFileEx. */ - WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry(); - while ( - !MoveFileExW(SystemTools::ConvertToWindowsExtendedPath(oldname).c_str(), - SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), - MOVEFILE_REPLACE_EXISTING) && - --retry.Count) { - DWORD last_error = GetLastError(); + WindowsFileRetry retry = GetWindowsRetry(oldname_wstr); + + // Use RAII to set the attribute bit blocking Microsoft Search Indexing, + // and restore the previous value upon return. + SaveRestoreFileAttributes save_restore_file_attributes( + oldname_wstr, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED); + + DWORD move_last_error = 0; + while (!cmMoveFile(oldname_wstr, newname_wstr) && --retry.Count) { + move_last_error = GetLastError(); + + // There was no error ==> the operation is not yet complete. + if (move_last_error == NO_ERROR) { + break; + } + // Try again only if failure was due to access/sharing permissions. - if (last_error != ERROR_ACCESS_DENIED && - last_error != ERROR_SHARING_VIOLATION) { + // Most often ERROR_ACCESS_DENIED (a.k.a. I/O error) for a directory, and + // ERROR_SHARING_VIOLATION for a file, are caused by one of the following: + // 1) Anti-Virus Software + // 2) Windows Search Indexer + // 3) Windows Explorer has an associated directory already opened. + if (move_last_error != ERROR_ACCESS_DENIED && + move_last_error != ERROR_SHARING_VIOLATION) { return false; } - DWORD attrs = GetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(newname).c_str()); + + DWORD const attrs = GetFileAttributesW(newname_wstr.c_str()); if ((attrs != INVALID_FILE_ATTRIBUTES) && - (attrs & FILE_ATTRIBUTE_READONLY)) { + (attrs & FILE_ATTRIBUTE_READONLY) && + // FILE_ATTRIBUTE_READONLY is not honored on directories. + !(attrs & FILE_ATTRIBUTE_DIRECTORY)) { // Remove the read-only attribute from the destination file. - SetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), - attrs & ~FILE_ATTRIBUTE_READONLY); + SetFileAttributesW(newname_wstr.c_str(), + attrs & ~FILE_ATTRIBUTE_READONLY); } else { // The file may be temporarily in use so wait a bit. cmSystemTools::Delay(retry.Delay); } } + + // If we were successful, then there was no error. + if (retry.Count > 0) { + move_last_error = 0; + // Restore the attributes on the new name. + save_restore_file_attributes.SetPath(newname_wstr); + } + SetLastError(move_last_error); return retry.Count > 0; #else /* On UNIX we have an OS-provided call to do this atomically. */ diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index b886c58..3e30b40 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -434,6 +434,7 @@ public: unsigned int Delay; }; static WindowsFileRetry GetWindowsFileRetry(); + static WindowsFileRetry GetWindowsDirectoryRetry(); #endif /** Get the real path for a given path, removing all symlinks. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bea9001..a30c9e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -366,6 +366,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("JOB_POOL_COMPILE"); initProp("JOB_POOL_LINK"); initProp("JOB_POOL_PRECOMPILE_HEADER"); + initProp("ISPC_HEADER_DIRECTORY"); initProp("LINK_SEARCH_START_STATIC"); initProp("LINK_SEARCH_END_STATIC"); initProp("Swift_LANGUAGE_VERSION"); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f630a7e..1bee728 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -205,6 +205,7 @@ cmake::cmake(Role role, cmState::Mode mode) setupExts(this->CudaFileExtensions, { "cu" }); setupExts(this->FortranFileExtensions, { "f", "F", "for", "f77", "f90", "f95", "f03" }); + setupExts(this->ISPCFileExtensions, { "ispc" }); } } @@ -1978,6 +1979,8 @@ std::vector<std::string> cmake::GetAllExtensions() const // cuda extensions are also in SourceFileExtensions so we ignore it here allExt.insert(allExt.end(), this->FortranFileExtensions.ordered.begin(), this->FortranFileExtensions.ordered.end()); + allExt.insert(allExt.end(), this->ISPCFileExtensions.ordered.begin(), + this->ISPCFileExtensions.ordered.end()); return allExt; } diff --git a/Source/cmake.h b/Source/cmake.h index 0c4f429..06ab8ac 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -268,7 +268,8 @@ public: { return this->CLikeSourceFileExtensions.Test(ext) || this->CudaFileExtensions.Test(ext) || - this->FortranFileExtensions.Test(ext); + this->FortranFileExtensions.Test(ext) || + this->ISPCFileExtensions.Test(ext); } bool IsACLikeSourceExtension(cm::string_view ext) const @@ -617,6 +618,7 @@ private: FileExtensions CLikeSourceFileExtensions; FileExtensions HeaderFileExtensions; FileExtensions CudaFileExtensions; + FileExtensions ISPCFileExtensions; FileExtensions FortranFileExtensions; bool ClearBuildSystem = false; bool DebugTryCompile = false; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5d4ffae..95162ec 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1483,6 +1483,10 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_subdirectory(CudaOnly) endif() + if(CMake_TEST_ISPC) + add_subdirectory(ISPC) + endif() + if(CMake_TEST_FindGTest) add_subdirectory(FindGTest) add_subdirectory(GoogleTest) diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt new file mode 100644 index 0000000..ca5a79b --- /dev/null +++ b/Tests/ISPC/CMakeLists.txt @@ -0,0 +1,13 @@ + + +macro (add_ispc_test_macro name) + add_test_macro("${name}" ${ARGN}) + set_property(TEST "${name}" APPEND + PROPERTY LABELS "ISPC") +endmacro () + +add_ispc_test_macro(ISPC.Defines ISPCDefines) +add_ispc_test_macro(ISPC.ObjectLibrary ISPCObjectLibrary) +add_ispc_test_macro(ISPC.ResponseAndDefine ISPCResponseAndDefine) +add_ispc_test_macro(ISPC.StaticLibrary ISPCStaticLibrary) +add_ispc_test_macro(ISPC.TryCompile ISPCTryCompile) diff --git a/Tests/ISPC/Defines/CMakeLists.txt b/Tests/ISPC/Defines/CMakeLists.txt new file mode 100644 index 0000000..5155106 --- /dev/null +++ b/Tests/ISPC/Defines/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.18) +project(ISPCDefines CXX ISPC) + +set(CMAKE_ISPC_FLAGS -DM_PI=3.1415926535f) +add_compile_definitions([==[STRUCT_DEFINE=struct{uniform int a]==]) + +add_executable(ISPCDefines + main.cxx + simple.ispc + ) + +set_target_properties(ISPCDefines PROPERTIES POSITION_INDEPENDENT_CODE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set_source_files_properties(simple.ispc PROPERTIES COMPILE_OPTIONS "--arch=x86") +endif() diff --git a/Tests/ISPC/Defines/main.cxx b/Tests/ISPC/Defines/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/Defines/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/Defines/simple.ispc b/Tests/ISPC/Defines/simple.ispc new file mode 100644 index 0000000..d8d6465 --- /dev/null +++ b/Tests/ISPC/Defines/simple.ispc @@ -0,0 +1,15 @@ + +//textual error if STRUCT_DEFINE not set +STRUCT_DEFINE;}; + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ObjectLibrary/CMakeLists.txt b/Tests/ISPC/ObjectLibrary/CMakeLists.txt new file mode 100644 index 0000000..333ad66 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,17 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCObjectLibrary CXX ISPC) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + +add_library(ispc_objects OBJECT simple.ispc extra.ispc) + +target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>") + +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_executable(ISPCObjectLibrary main.cxx extra.cxx) +target_link_libraries(ISPCObjectLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/ObjectLibrary/extra.cxx b/Tests/ISPC/ObjectLibrary/extra.cxx new file mode 100644 index 0000000..88ef3a7 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/extra.cxx @@ -0,0 +1,17 @@ +#include <stdio.h> + +#include "extra.ispc.h" + +int extra() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::extra(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/ObjectLibrary/extra.ispc b/Tests/ISPC/ObjectLibrary/extra.ispc new file mode 100644 index 0000000..5a4a442 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ObjectLibrary/simple.ispc b/Tests/ISPC/ObjectLibrary/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ResponseAndDefine/CMakeLists.txt b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt new file mode 100644 index 0000000..7539209 --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.18) +project(ispc_spaces_in_path ISPC CXX) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) + +# Make sure we can handle an arg file with tricky defines including spaces in -I include +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/path with spaces/simple_include.h" +" + typedef float FLOAT_TYPE; +" +) + +add_executable(ISPCResponseAndDefine main.cxx simple.ispc) +set_target_properties(ISPCResponseAndDefine PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(ISPCResponseAndDefine PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +target_compile_options(ISPCResponseAndDefine PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ISPCResponseAndDefine PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--arch=x86>") +endif() + + + +target_compile_definitions(ISPCResponseAndDefine PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:STRUCT_DEFINE=struct{uniform int a>;M_PI=3.14159f") +target_include_directories(ISPCResponseAndDefine PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:${CMAKE_CURRENT_BINARY_DIR}/fake path with spaces>" + "$<$<COMPILE_LANGUAGE:ISPC>:${CMAKE_CURRENT_BINARY_DIR}/path with spaces>") diff --git a/Tests/ISPC/ResponseAndDefine/main.cxx b/Tests/ISPC/ResponseAndDefine/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ResponseAndDefine/simple.ispc b/Tests/ISPC/ResponseAndDefine/simple.ispc new file mode 100644 index 0000000..81fd7ca --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/simple.ispc @@ -0,0 +1,16 @@ + +STRUCT_DEFINE;}; + +#include "simple_include.h" + +export void simple(uniform FLOAT_TYPE vin[], uniform FLOAT_TYPE vout[], + uniform int count) { + foreach (index = 0 ... count) { + FLOAT_TYPE v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/StaticLibrary/CMakeLists.txt b/Tests/ISPC/StaticLibrary/CMakeLists.txt new file mode 100644 index 0000000..ebe5960 --- /dev/null +++ b/Tests/ISPC/StaticLibrary/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCStaticLibrary CXX ISPC) + +add_library(ispc_objects STATIC simple.ispc) + +target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--arch=x86>") +endif() + +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_executable(ISPCStaticLibrary main.cxx) +target_link_libraries(ISPCStaticLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/StaticLibrary/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/StaticLibrary/simple.ispc b/Tests/ISPC/StaticLibrary/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/StaticLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/TryCompile/CMakeLists.txt b/Tests/ISPC/TryCompile/CMakeLists.txt new file mode 100644 index 0000000..742f511 --- /dev/null +++ b/Tests/ISPC/TryCompile/CMakeLists.txt @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCTryCompile ISPC CXX) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + +#Verify we can use try_compile with ISPC +try_compile(result "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/simple.ispc" + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/result.o") + +add_executable(ISPCTryCompile main.cxx ) +target_link_libraries(ISPCTryCompile "${CMAKE_CURRENT_BINARY_DIR}/result.o") diff --git a/Tests/ISPC/TryCompile/main.cxx b/Tests/ISPC/TryCompile/main.cxx new file mode 100644 index 0000000..c8d1ed6 --- /dev/null +++ b/Tests/ISPC/TryCompile/main.cxx @@ -0,0 +1,19 @@ +#include <stdio.h> + +namespace ispc { +extern "C" { +void simple(float*, float*, int); +} +} + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/TryCompile/simple.ispc b/Tests/ISPC/TryCompile/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/TryCompile/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt new file mode 100644 index 0000000..2677659 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt @@ -0,0 +1,96 @@ +# This test checks whether adding a source file to the project triggers an AUTOMOC re-run. + +cmake_minimum_required(VERSION 3.10) +project(RerunMocOnAddFile) +include("../AutogenCoreTest.cmake") + +# Create an executable to generate a clean target +set(main_source "${CMAKE_CURRENT_BINARY_DIR}/generated_main.cpp") +file(WRITE "${main_source}" "int main() {}") +add_executable(exe "${main_source}") + +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") +set(testProjectTemplateDir "${CMAKE_CURRENT_SOURCE_DIR}/MocOnAddFile") +set(testProjectSrc "${CMAKE_CURRENT_BINARY_DIR}/MocOnAddFile") +set(testProjectBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocOnAddFile-build") + +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamp When) + file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${testProjectBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change) + if (timeAfter VERSION_GREATER timeBefore) + message(STATUS "As expected the file ${mocBasicBin} changed.") + else() + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + endif() +endmacro() + +macro(require_change_not) + if (timeAfter VERSION_GREATER timeBefore) + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + else() + message(STATUS "As expected the file ${mocBasicBin} did not change.") + endif() +endmacro() + +# Create the test project from the template +unset(additional_project_sources) +unset(main_cpp_includes) +configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt") +configure_file("${testProjectTemplateDir}/main.cpp.in" "${testProjectSrc}/main.cpp") + +# Initial build +try_compile(MOC_RERUN + "${testProjectBinDir}" + "${testProjectSrc}" + MocOnAddFile + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT MOC_RERUN) + message(FATAL_ERROR "Initial build of mocOnAddFile failed. Output: ${output}") +endif() + +# Sleep to ensure new timestamps +sleep() + +# Add a QObject class (defined in header) to the project and build +set(additional_project_sources myobject.cpp) +set(main_cpp_includes "#include \"myobject.h\"") +configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt" + @ONLY) +configure_file("${testProjectTemplateDir}/main.cpp.in" "${testProjectSrc}/main.cpp" @ONLY) +configure_file("${testProjectTemplateDir}/myobject.h" "${testProjectSrc}/myobject.h" COPYONLY) +configure_file("${testProjectTemplateDir}/myobject.cpp" "${testProjectSrc}/myobject.cpp" COPYONLY) +rebuild(2) + +# Sleep to ensure new timestamps +sleep() + +# Add a QObject class (defined in source) to the project and build +set(additional_project_sources myobject.cpp anotherobject.cpp) +configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt" + @ONLY) +configure_file("${testProjectTemplateDir}/anotherobject.cpp" "${testProjectSrc}/anotherobject.cpp" + COPYONLY) +rebuild(3) diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in new file mode 100644 index 0000000..9e5e21c --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(MocOnAddFile) +include("@CMAKE_CURRENT_LIST_DIR@/../AutogenCoreTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +add_executable(mocOnAddFile main.cpp @additional_project_sources@) +target_link_libraries(mocOnAddFile ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/anotherobject.cpp b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/anotherobject.cpp new file mode 100644 index 0000000..45c5af6 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/anotherobject.cpp @@ -0,0 +1,15 @@ +#include <qobject.h> + +class AnotherObject : public QObject +{ + Q_OBJECT +public: + AnotherObject() {} +}; + +AnotherObject* createAnotherObject() +{ + return new AnotherObject(); +} + +#include "anotherobject.moc" diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/main.cpp.in b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/main.cpp.in new file mode 100644 index 0000000..f62027a --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/main.cpp.in @@ -0,0 +1,6 @@ +@main_cpp_includes@ + +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.cpp b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.cpp new file mode 100644 index 0000000..7a15300 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.cpp @@ -0,0 +1,6 @@ +#include "myobject.h" + +MyObject::MyObject(QObject* parent) + : QObject(parent) +{ +} diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.h b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.h new file mode 100644 index 0000000..e373ee8 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.h @@ -0,0 +1,13 @@ +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <qobject.h> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject* parent = 0); +}; + +#endif diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index dfa5ea0..0c7bd79 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -20,6 +20,7 @@ ADD_AUTOGEN_TEST(RccOffMocLibrary) ADD_AUTOGEN_TEST(RccOnly rccOnly) ADD_AUTOGEN_TEST(RccSkipSource) ADD_AUTOGEN_TEST(RerunMocBasic) +ADD_AUTOGEN_TEST(RerunMocOnAddFile) ADD_AUTOGEN_TEST(RerunRccConfigChange) ADD_AUTOGEN_TEST(RerunRccDepends) ADD_AUTOGEN_TEST(SameName sameName) diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake index 761224a..62606f8 100644 --- a/Tests/RunCMake/CTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake @@ -18,3 +18,12 @@ function(run_CMakeCTestArguments) run_cmake_command(CMakeCTestArguments-test ${CMAKE_COMMAND} --build . --config Debug --target "${test}") endfunction() run_CMakeCTestArguments() + +function(run_TestfileErrors) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestfileErrors-build) + run_cmake(TestfileErrors) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(TestfileErrors-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(TestfileErrors-test ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() +run_TestfileErrors() diff --git a/Tests/RunCMake/CTest/TestfileErrors-Script.cmake b/Tests/RunCMake/CTest/TestfileErrors-Script.cmake new file mode 100644 index 0000000..d9fc7c8 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-Script.cmake @@ -0,0 +1,4 @@ +message(SEND_ERROR "SEND_ERROR") +message(FATAL_ERROR "FATAL_ERROR") +# This shouldn't get printed because the script aborts on FATAL_ERROR +message(SEND_ERROR "reaching the unreachable") diff --git a/Tests/RunCMake/CTest/TestfileErrors-test-result.txt b/Tests/RunCMake/CTest/TestfileErrors-test-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-test-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt b/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt new file mode 100644 index 0000000..a3a476b --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at [^ +]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:1 \(message\): + SEND_ERROR +Call Stack \(most recent call first\): + CTestTestfile.cmake:[0-9]+ \(include\) ++ +CMake Error at [^ +]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:2 \(message\): + FATAL_ERROR +Call Stack \(most recent call first\): + CTestTestfile.cmake:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CTest/TestfileErrors.cmake b/Tests/RunCMake/CTest/TestfileErrors.cmake new file mode 100644 index 0000000..676eb47 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors.cmake @@ -0,0 +1,3 @@ +include(CTest) +add_test(NAME "unreachable" COMMAND ${CMAKE_COMMAND} -E true) +set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/TestfileErrors-Script.cmake) diff --git a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt index d95bb33..97e2a10 100644 --- a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at CTestTestfile.cmake:[0-9]+ \(subdirs\): subdirs called with incorrect number of arguments + -No tests were found!!!$ +Errors while running CTest$ diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt index ba4235d..19310b8 100644 --- a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt @@ -1 +1,2 @@ +^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputSize/DartConfiguration.tcl Errors while running CTest diff --git a/Tests/RunCMake/ExternalProject/DownloadServer.py b/Tests/RunCMake/ExternalProject/DownloadServer.py index ac0769f..3738317 100644 --- a/Tests/RunCMake/ExternalProject/DownloadServer.py +++ b/Tests/RunCMake/ExternalProject/DownloadServer.py @@ -4,6 +4,7 @@ import time import subprocess import sys import os +import threading args = None outerthread = None @@ -25,6 +26,13 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): self.wfile.write(data) self.close_connection = True +def runServer(fileName): + httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler) + with open(fileName,"w") as f: + f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1])) + httpd.handle_request() + os.remove(fileName) + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--speed_limit', help='transfer rate limitation', action='store_true',default=False) @@ -35,8 +43,7 @@ if __name__ == "__main__": if not args.subprocess: subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL) else: - httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler) - with open(args.file,"w") as f: - f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1])) - httpd.handle_request() - os.remove(args.file) + serverThread = threading.Thread(target=runServer,args=(args.file,)) + serverThread.daemon = True + serverThread.start() + serverThread.join(15) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt index ec2cf2c..296e426 100644 --- a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt @@ -2,4 +2,4 @@ CMake Error at CTestTestfile.cmake:[0-9]+: Parse error\. Function missing ending "\)"\. End of file reached\. -No tests were found!!! +Errors while running CTest diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt index ec2cf2c..296e426 100644 --- a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt @@ -2,4 +2,4 @@ CMake Error at CTestTestfile.cmake:[0-9]+: Parse error\. Function missing ending "\)"\. End of file reached\. -No tests were found!!! +Errors while running CTest diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index 7046fab..aee3338 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -101,6 +101,15 @@ add_test(NAME UseSWIG.MultiplePython COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +add_test(NAME UseSWIG.MultipleFiles COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleFiles" + "${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleFiles" + ${build_generator_args} + --build-project TestMultipleFiles + --build-options ${build_options} + ) add_test(NAME UseSWIG.ModuleVersion2 COMMAND diff --git a/Tests/UseSWIG/MultipleFiles/CMakeLists.txt b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt new file mode 100644 index 0000000..bf3d946 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.18) + +project(TestMultipleFiles CXX) + +find_package(SWIG REQUIRED) +include(UseSWIG) + +unset(SWIG_LANG_TYPE) +unset(SWIG_LANG_INCLUDE_DIRECTORIES) +unset(SWIG_LANG_DEFINITIONS) +unset(SWIG_LANG_OPTIONS) +unset(SWIG_LANG_LIBRARIES) + +find_package(Python3 REQUIRED COMPONENTS Development) + +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY SWIG_MODULE_NAME _add) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY SWIG_MODULE_NAME _sub) + + +swig_add_library(example + LANGUAGE python + TYPE MODULE + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/add.i" + "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" + "${CMAKE_CURRENT_SOURCE_DIR}/add.cxx" + "${CMAKE_CURRENT_SOURCE_DIR}/sub.cxx") +target_include_directories(example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(example PRIVATE Python3::Module) diff --git a/Tests/UseSWIG/MultipleFiles/add.cxx b/Tests/UseSWIG/MultipleFiles/add.cxx new file mode 100644 index 0000000..a4dcca3 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/add.cxx @@ -0,0 +1,6 @@ +#include "add.h" + +int add(int a, int b) +{ + return a + b; +} diff --git a/Tests/UseSWIG/MultipleFiles/add.h b/Tests/UseSWIG/MultipleFiles/add.h new file mode 100644 index 0000000..6295ab9 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/add.h @@ -0,0 +1 @@ +int add(int a, int b); diff --git a/Tests/UseSWIG/MultipleFiles/add.i b/Tests/UseSWIG/MultipleFiles/add.i new file mode 100644 index 0000000..2046397 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/add.i @@ -0,0 +1,4 @@ +%{ +#include "add.h" +%} +%include "add.h" diff --git a/Tests/UseSWIG/MultipleFiles/sub.cxx b/Tests/UseSWIG/MultipleFiles/sub.cxx new file mode 100644 index 0000000..d6874ef --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/sub.cxx @@ -0,0 +1,6 @@ +#include "sub.h" + +int sub(int a, int b) +{ + return a - b; +} diff --git a/Tests/UseSWIG/MultipleFiles/sub.h b/Tests/UseSWIG/MultipleFiles/sub.h new file mode 100644 index 0000000..de77111 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/sub.h @@ -0,0 +1 @@ +int sub(int a, int b); diff --git a/Tests/UseSWIG/MultipleFiles/sub.i b/Tests/UseSWIG/MultipleFiles/sub.i new file mode 100644 index 0000000..fc70f10 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/sub.i @@ -0,0 +1,5 @@ +%{ +#include "sub.h" +%} + +%include "sub.h" |