mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
ISPC: DynamicLibrary test now passes on windows.
The MSVC linker needs to know what MSVC runtime a shared library needs. ISPC objects don't have a '/DIRECTIVE' entry for the MSVC runtime as they have no dependency on it. Therefore we need to add a C or C++ source to each shared library so the MSVC linker knows what runtime to embed
This commit is contained in:
committed by
Brad King
parent
a83521e082
commit
8de145cae1
@@ -9,12 +9,14 @@ endif()
|
||||
|
||||
add_library(ispc_objects1 STATIC extra.ispc extra.cxx)
|
||||
add_library(ispc_objects2 SHARED simple.ispc)
|
||||
target_sources(ispc_objects2 PRIVATE simple.cxx)
|
||||
|
||||
set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4")
|
||||
set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4")
|
||||
|
||||
target_link_libraries(ispc_objects2 PRIVATE ispc_objects1)
|
||||
target_link_libraries(ispc_objects2 PUBLIC ispc_objects1)
|
||||
|
||||
add_executable(ISPCDynamicLibrary main.cxx)
|
||||
target_link_libraries(ISPCDynamicLibrary PUBLIC ispc_objects2)
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
#include "extra.ispc.h"
|
||||
|
||||
int extra()
|
||||
#ifdef _WIN32
|
||||
# define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define EXPORT
|
||||
#endif
|
||||
|
||||
EXPORT int extra()
|
||||
{
|
||||
float vin[16], vout[16];
|
||||
for (int i = 0; i < 16; ++i)
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "simple.ispc.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# define IMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define IMPORT
|
||||
#endif
|
||||
|
||||
IMPORT int simple();
|
||||
int extra();
|
||||
|
||||
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]);
|
||||
extra();
|
||||
simple();
|
||||
return 0;
|
||||
}
|
||||
|
||||
0
Tests/ISPC/DynamicLibrary/shim.cxx
Normal file
0
Tests/ISPC/DynamicLibrary/shim.cxx
Normal file
23
Tests/ISPC/DynamicLibrary/simple.cxx
Normal file
23
Tests/ISPC/DynamicLibrary/simple.cxx
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "simple.ispc.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define EXPORT
|
||||
#endif
|
||||
|
||||
EXPORT int simple()
|
||||
{
|
||||
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: extra(%f) = %f\n", i, vin[i], vout[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user