summaryrefslogtreecommitdiffstats
path: root/Tests/CudaOnly/WithDefs
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-11 19:32:13 (GMT)
committerBrad King <brad.king@kitware.com>2018-01-12 19:27:37 (GMT)
commit506fda1cf026a88378589009b62ca8bf633c5197 (patch)
tree2095056002a42332f5e8f2741daa29eb8880db10 /Tests/CudaOnly/WithDefs
parentc2f79c98677d43fb8686f9e4309acddfae8f3dfd (diff)
downloadCMake-506fda1cf026a88378589009b62ca8bf633c5197.zip
CMake-506fda1cf026a88378589009b62ca8bf633c5197.tar.gz
CMake-506fda1cf026a88378589009b62ca8bf633c5197.tar.bz2
Genex: Enable COMPILE_LANGUAGE for INCLUDE_DIRECTORIES with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based on the linker language. By default this is always the C++ flags if any C++ sources appear in the target, and otherwise the C flags. Therefore we can define the `COMPILE_LANGUAGE` generator expression in `INCLUDE_DIRECTORIES` to match the selected language. This is not exactly the same as for other generators, but is the best VS and Xcode can do. It is also sufficient for many use cases since the set of include directories for C and C++ is frequently similar but may be distinct from those for other languages like CUDA. Fixes: #17435
Diffstat (limited to 'Tests/CudaOnly/WithDefs')
-rw-r--r--Tests/CudaOnly/WithDefs/CMakeLists.txt5
-rw-r--r--Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h1
-rw-r--r--Tests/CudaOnly/WithDefs/main.notcu5
3 files changed, 11 insertions, 0 deletions
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 1a5599b..ffe4859 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -45,6 +45,11 @@ target_compile_definitions(CudaOnlyWithDefs
-DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
)
+target_include_directories(CudaOnlyWithDefs
+ PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CURRENT_SOURCE_DIR}/inc_cuda>
+)
+
if(APPLE)
# Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
diff --git a/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
new file mode 100644
index 0000000..e228b58
--- /dev/null
+++ b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
@@ -0,0 +1 @@
+#define INC_CUDA
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index 426eb62..3793d74 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -2,6 +2,11 @@
#include <cuda_runtime.h>
#include <iostream>
+#include <inc_cuda.h>
+#ifndef INC_CUDA
+#error "INC_CUDA not defined!"
+#endif
+
#ifndef HOST_DEFINE
#error "HOST_DEFINE not defined!"
#endif