summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/prop_tgt/ISPC_HEADER_SUFFIX.rst14
-rw-r--r--Help/release/3.19.rst4
-rw-r--r--Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst10
-rw-r--r--Source/cmCoreTryCompile.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx16
-rw-r--r--Source/cmMakefileTargetGenerator.cxx7
-rw-r--r--Source/cmNinjaTargetGenerator.cxx7
-rw-r--r--Source/cmTarget.cxx1
-rw-r--r--Tests/ISPC/CMakeLists.txt1
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/extra.cxx2
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/main.cxx2
-rw-r--r--Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt23
-rw-r--r--Tests/ISPC/CustomHeaderSuffix/extra.cxx17
-rw-r--r--Tests/ISPC/CustomHeaderSuffix/extra.ispc12
-rw-r--r--Tests/ISPC/CustomHeaderSuffix/main.cxx15
-rw-r--r--Tests/ISPC/CustomHeaderSuffix/simple.ispc12
-rw-r--r--Tests/ISPC/Defines/main.cxx2
-rw-r--r--Tests/ISPC/DynamicLibrary/extra.cxx2
-rw-r--r--Tests/ISPC/DynamicLibrary/simple.cxx2
-rw-r--r--Tests/ISPC/ObjectLibrary/extra.cxx2
-rw-r--r--Tests/ISPC/ObjectLibrary/main.cxx2
-rw-r--r--Tests/ISPC/ResponseAndDefine/main.cxx2
-rw-r--r--Tests/ISPC/StaticLibrary/main.cxx2
-rw-r--r--Tests/ISPC/SystemIncludes/CMakeLists.txt2
26 files changed, 148 insertions, 15 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index bd6e5c6..5c8a05a 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -259,6 +259,7 @@ Properties on Targets
/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG
/prop_tgt/IOS_INSTALL_COMBINED
/prop_tgt/ISPC_HEADER_DIRECTORY
+ /prop_tgt/ISPC_HEADER_SUFFIX
/prop_tgt/ISPC_INSTRUCTION_SETS
/prop_tgt/JOB_POOL_COMPILE
/prop_tgt/JOB_POOL_LINK
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 3f0fb03..56239ac 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -515,6 +515,7 @@ Variables for Languages
/variable/CMAKE_Fortran_MODDIR_FLAG
/variable/CMAKE_Fortran_MODOUT_FLAG
/variable/CMAKE_ISPC_HEADER_DIRECTORY
+ /variable/CMAKE_ISPC_HEADER_SUFFIX
/variable/CMAKE_ISPC_INSTRUCTION_SETS
/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE
/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX
diff --git a/Help/prop_tgt/ISPC_HEADER_SUFFIX.rst b/Help/prop_tgt/ISPC_HEADER_SUFFIX.rst
new file mode 100644
index 0000000..6397e55
--- /dev/null
+++ b/Help/prop_tgt/ISPC_HEADER_SUFFIX.rst
@@ -0,0 +1,14 @@
+ISPC_HEADER_SUFFIX
+------------------
+
+.. versionadded:: 3.19.2
+
+Specify output suffix to be used for ISPC generated headers provided by the target.
+
+This property is initialized by the value of the :variable:`CMAKE_ISPC_HEADER_SUFFIX`
+variable if it is set when a target is created.
+
+If the target contains ISPC source files, this specifies the header suffix to
+be used for the generated headers.
+
+The default value is ``_ispc.h``.
diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst
index 4f26058..60a8ecc 100644
--- a/Help/release/3.19.rst
+++ b/Help/release/3.19.rst
@@ -381,3 +381,7 @@ Changes made since CMake 3.19.0 include the following.
the invoking process tree, the :variable:`CMAKE_APPLE_SILICON_PROCESSOR`
variable or :envvar:`CMAKE_APPLE_SILICON_PROCESSOR` environment
variable may be set to specify a host architecture explicitly.
+
+* The :variable:`CMAKE_ISPC_HEADER_SUFFIX` variable and corresponding
+ :prop_tgt:`ISPC_HEADER_SUFFIX` target property were added to control
+ the header suffix used by ``ISPC`` compiler generated headers.
diff --git a/Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst b/Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst
new file mode 100644
index 0000000..c9fb709
--- /dev/null
+++ b/Help/variable/CMAKE_ISPC_HEADER_SUFFIX.rst
@@ -0,0 +1,10 @@
+CMAKE_ISPC_HEADER_SUFFIX
+------------------------
+
+.. versionadded:: 3.19.2
+
+Output suffix to be used for ISPC generated headers.
+
+This variable is used to initialize the :prop_tgt:`ISPC_HEADER_SUFFIX`
+property on all the targets. See the target property for additional
+information.
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 77a6d4b..6672aa6 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -201,6 +201,7 @@ std::string const kCMAKE_CUDA_ARCHITECTURES = "CMAKE_CUDA_ARCHITECTURES";
std::string const kCMAKE_CUDA_RUNTIME_LIBRARY = "CMAKE_CUDA_RUNTIME_LIBRARY";
std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS";
std::string const kCMAKE_ISPC_INSTRUCTION_SETS = "CMAKE_ISPC_INSTRUCTION_SETS";
+std::string const kCMAKE_ISPC_HEADER_SUFFIX = "CMAKE_ISPC_HEADER_SUFFIX";
std::string const kCMAKE_LINK_SEARCH_END_STATIC =
"CMAKE_LINK_SEARCH_END_STATIC";
std::string const kCMAKE_LINK_SEARCH_START_STATIC =
@@ -718,6 +719,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(kCMAKE_CUDA_RUNTIME_LIBRARY);
vars.insert(kCMAKE_ENABLE_EXPORTS);
vars.insert(kCMAKE_ISPC_INSTRUCTION_SETS);
+ vars.insert(kCMAKE_ISPC_HEADER_SUFFIX);
vars.insert(kCMAKE_LINK_SEARCH_END_STATIC);
vars.insert(kCMAKE_LINK_SEARCH_START_STATIC);
vars.insert(kCMAKE_OSX_ARCHITECTURES);
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 368f278..884d15d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2426,9 +2426,12 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target)
return;
}
- std::vector<std::string> ispcSuffixes =
+ cmProp ispcHeaderSuffixProp = target->GetProperty("ISPC_HEADER_SUFFIX");
+ assert(ispcHeaderSuffixProp != nullptr);
+
+ std::vector<std::string> ispcArchSuffixes =
detail::ComputeISPCObjectSuffixes(target);
- const bool extra_objects = (ispcSuffixes.size() > 1);
+ const bool extra_objects = (ispcArchSuffixes.size() > 1);
std::vector<std::string> configsList =
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
@@ -2451,14 +2454,19 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target)
const std::string& lang = sf->GetLanguage();
if (lang == "ISPC") {
std::string const& objectName = target->GetObjectName(sf);
+
+ // Drop both ".obj" and the source file extension
std::string ispcSource =
cmSystemTools::GetFilenameWithoutLastExtension(objectName);
+ ispcSource =
+ cmSystemTools::GetFilenameWithoutLastExtension(ispcSource);
- auto headerPath = cmStrCat(headerDir, '/', ispcSource, ".h");
+ auto headerPath =
+ cmStrCat(headerDir, '/', ispcSource, *ispcHeaderSuffixProp);
target->AddISPCGeneratedHeader(headerPath, config);
if (extra_objects) {
std::vector<std::string> objs = detail::ComputeISPCExtraObjects(
- objectName, rootObjectDir, ispcSuffixes);
+ objectName, rootObjectDir, ispcArchSuffixes);
target->AddISPCGeneratedObject(std::move(objs), config);
}
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 3776fec..c6d6c99 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -591,6 +591,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
if (lang == "ISPC") {
std::string ispcSource =
cmSystemTools::GetFilenameWithoutLastExtension(objectName);
+ ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource);
+
+ cmProp ispcSuffixProp =
+ this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX");
+ assert(ispcSuffixProp != nullptr);
std::string directory = this->GeneratorTarget->GetObjectDirectory(config);
if (cmProp prop =
@@ -598,7 +603,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
directory =
cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', *prop);
}
- ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, ".h");
+ ispcHeaderRelative = cmStrCat(directory, '/', ispcSource, *ispcSuffixProp);
ispcHeaderForShell = this->LocalGenerator->ConvertToOutputFormat(
ispcHeaderRelative, cmOutputConverter::SHELL);
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 662399e..d41cbd2 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1374,6 +1374,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->GeneratorTarget->GetObjectName(source);
std::string ispcSource =
cmSystemTools::GetFilenameWithoutLastExtension(objectName);
+ ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource);
+
+ cmProp ispcSuffixProp =
+ this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX");
+ assert(ispcSuffixProp != nullptr);
std::string ispcHeaderDirectory =
this->GeneratorTarget->GetObjectDirectory(config);
@@ -1384,7 +1389,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
std::string ispcHeader =
- cmStrCat(ispcHeaderDirectory, '/', ispcSource, ".h");
+ cmStrCat(ispcHeaderDirectory, '/', ispcSource, *ispcSuffixProp);
ispcHeader = this->ConvertToNinjaPath(ispcHeader);
// Make sure ninja knows what command generates the header
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index d26de9c..bda2b30 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -369,6 +369,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp("JOB_POOL_PRECOMPILE_HEADER");
initProp("ISPC_COMPILER_LAUNCHER");
initProp("ISPC_HEADER_DIRECTORY");
+ initPropValue("ISPC_HEADER_SUFFIX", "_ispc.h");
initProp("ISPC_INSTRUCTION_SETS");
initProp("LINK_SEARCH_START_STATIC");
initProp("LINK_SEARCH_END_STATIC");
diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt
index 2c3651d..c993275 100644
--- a/Tests/ISPC/CMakeLists.txt
+++ b/Tests/ISPC/CMakeLists.txt
@@ -7,6 +7,7 @@ macro (add_ispc_test_macro name)
endmacro ()
add_ispc_test_macro(ISPC.ChainedStaticLibraries ISPCChainedStaticLibraries)
+add_ispc_test_macro(ISPC.CustomHeaderSuffix ISPCCustomHeaderSuffix)
add_ispc_test_macro(ISPC.Defines ISPCDefines)
add_ispc_test_macro(ISPC.DynamicLibrary ISPCDynamicLibrary)
add_ispc_test_macro(ISPC.ObjectGenex ISPCObjectGenex)
diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.cxx b/Tests/ISPC/ChainedStaticLibraries/extra.cxx
index 88ef3a7..9f50df4 100644
--- a/Tests/ISPC/ChainedStaticLibraries/extra.cxx
+++ b/Tests/ISPC/ChainedStaticLibraries/extra.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "extra.ispc.h"
+#include "extra_ispc.h"
int extra()
{
diff --git a/Tests/ISPC/ChainedStaticLibraries/main.cxx b/Tests/ISPC/ChainedStaticLibraries/main.cxx
index 4f1c9be..a6b91a6 100644
--- a/Tests/ISPC/ChainedStaticLibraries/main.cxx
+++ b/Tests/ISPC/ChainedStaticLibraries/main.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple.ispc.h"
+#include "simple_ispc.h"
int main()
{
diff --git a/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt
new file mode 100644
index 0000000..d20f88e
--- /dev/null
+++ b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+cmake_minimum_required(VERSION 3.18)
+project(ISPCCustomHeaderSuffix CXX ISPC)
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(CMAKE_ISPC_FLAGS "--arch=x86")
+endif()
+
+set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16")
+
+set(CMAKE_ISPC_HEADER_SUFFIX ".ispc.h")
+
+add_library(ispc_suffix_1 OBJECT simple.ispc)
+add_library(ispc_suffix_2 OBJECT extra.ispc)
+
+set_target_properties(ispc_suffix_2 PROPERTIES ISPC_HEADER_SUFFIX "___ispc.h")
+
+set_target_properties(ispc_suffix_1 ispc_suffix_2
+ PROPERTIES POSITION_INDEPENDENT_CODE ON
+)
+
+add_executable(ISPCCustomHeaderSuffix main.cxx extra.cxx)
+target_link_libraries(ISPCCustomHeaderSuffix PRIVATE ispc_suffix_1 ispc_suffix_2)
diff --git a/Tests/ISPC/CustomHeaderSuffix/extra.cxx b/Tests/ISPC/CustomHeaderSuffix/extra.cxx
new file mode 100644
index 0000000..0354e2d
--- /dev/null
+++ b/Tests/ISPC/CustomHeaderSuffix/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/CustomHeaderSuffix/extra.ispc b/Tests/ISPC/CustomHeaderSuffix/extra.ispc
new file mode 100644
index 0000000..5a4a442
--- /dev/null
+++ b/Tests/ISPC/CustomHeaderSuffix/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/CustomHeaderSuffix/main.cxx b/Tests/ISPC/CustomHeaderSuffix/main.cxx
new file mode 100644
index 0000000..4f1c9be
--- /dev/null
+++ b/Tests/ISPC/CustomHeaderSuffix/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/CustomHeaderSuffix/simple.ispc b/Tests/ISPC/CustomHeaderSuffix/simple.ispc
new file mode 100644
index 0000000..70cb588
--- /dev/null
+++ b/Tests/ISPC/CustomHeaderSuffix/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/Defines/main.cxx b/Tests/ISPC/Defines/main.cxx
index 4f1c9be..a6b91a6 100644
--- a/Tests/ISPC/Defines/main.cxx
+++ b/Tests/ISPC/Defines/main.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple.ispc.h"
+#include "simple_ispc.h"
int main()
{
diff --git a/Tests/ISPC/DynamicLibrary/extra.cxx b/Tests/ISPC/DynamicLibrary/extra.cxx
index b3623d1..a3d89ed 100644
--- a/Tests/ISPC/DynamicLibrary/extra.cxx
+++ b/Tests/ISPC/DynamicLibrary/extra.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "extra.ispc.h"
+#include "extra_ispc.h"
#ifdef _WIN32
# define EXPORT __declspec(dllexport)
diff --git a/Tests/ISPC/DynamicLibrary/simple.cxx b/Tests/ISPC/DynamicLibrary/simple.cxx
index cb5a779..bc78bda 100644
--- a/Tests/ISPC/DynamicLibrary/simple.cxx
+++ b/Tests/ISPC/DynamicLibrary/simple.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple.ispc.h"
+#include "simple_ispc.h"
#ifdef _WIN32
# define EXPORT __declspec(dllexport)
diff --git a/Tests/ISPC/ObjectLibrary/extra.cxx b/Tests/ISPC/ObjectLibrary/extra.cxx
index 88ef3a7..9f50df4 100644
--- a/Tests/ISPC/ObjectLibrary/extra.cxx
+++ b/Tests/ISPC/ObjectLibrary/extra.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "extra.ispc.h"
+#include "extra_ispc.h"
int extra()
{
diff --git a/Tests/ISPC/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx
index 4f1c9be..a6b91a6 100644
--- a/Tests/ISPC/ObjectLibrary/main.cxx
+++ b/Tests/ISPC/ObjectLibrary/main.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple.ispc.h"
+#include "simple_ispc.h"
int main()
{
diff --git a/Tests/ISPC/ResponseAndDefine/main.cxx b/Tests/ISPC/ResponseAndDefine/main.cxx
index 4f1c9be..a6b91a6 100644
--- a/Tests/ISPC/ResponseAndDefine/main.cxx
+++ b/Tests/ISPC/ResponseAndDefine/main.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple.ispc.h"
+#include "simple_ispc.h"
int main()
{
diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx
index 4f1c9be..a6b91a6 100644
--- a/Tests/ISPC/StaticLibrary/main.cxx
+++ b/Tests/ISPC/StaticLibrary/main.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple.ispc.h"
+#include "simple_ispc.h"
int main()
{
diff --git a/Tests/ISPC/SystemIncludes/CMakeLists.txt b/Tests/ISPC/SystemIncludes/CMakeLists.txt
index 95959b2..d94e75e 100644
--- a/Tests/ISPC/SystemIncludes/CMakeLists.txt
+++ b/Tests/ISPC/SystemIncludes/CMakeLists.txt
@@ -4,8 +4,10 @@ project(ispc_spaces_in_path ISPC CXX)
add_executable(ISPCSystemIncludes main.cxx simple.ispc)
set_target_properties(ISPCSystemIncludes PROPERTIES POSITION_INDEPENDENT_CODE ON)
+set_target_properties(ISPCSystemIncludes PROPERTIES ISPC_HEADER_SUFFIX ".ispc.h")
target_include_directories(ISPCSystemIncludes SYSTEM PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
+
target_compile_options(ISPCSystemIncludes PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_compile_options(ISPCSystemIncludes PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--arch=x86>")