summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2019-07-30 15:01:57 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-19 19:20:38 (GMT)
commitf4fc0667ae406c8f6b4c3e22a73ae4a7a075404b (patch)
treeaf34a92c3d13d3230f208b9f6f76513052e2d0b0 /Modules
parent9460501ad7353e6eecdf42d56568c1f909f64e27 (diff)
downloadCMake-f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b.zip
CMake-f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b.tar.gz
CMake-f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b.tar.bz2
FindOpenACC: Provide import targets and OpenACC_<lang>_OPTIONS variable
Previously the FindOpenACC module had issues where the contents of OpenACC_<lang>_FLAGS could not be used with target_compile_options when it contained multiple compiler flags.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindOpenACC.cmake28
1 files changed, 28 insertions, 0 deletions
diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake
index 1f0238e..743e0e2 100644
--- a/Modules/FindOpenACC.cmake
+++ b/Modules/FindOpenACC.cmake
@@ -22,6 +22,14 @@ project, where ``<lang>`` is one of C, CXX, or Fortran:
Variable indicating if OpenACC support for ``<lang>`` was detected.
``OpenACC_<lang>_FLAGS``
OpenACC compiler flags for ``<lang>``, separated by spaces.
+``OpenACC_<lang>_OPTIONS``
+ OpenACC compiler flags for ``<lang>``, as a list. Suitable for usage
+ with target_compile_options or target_link_options.
+
+Additionally, the module provides :prop_tgt:`IMPORTED` targets:
+
+``OpenACC::OpenACC_<lang>``
+ Target for using OpenACC from ``<lang>``.
The module will also try to provide the OpenACC version variables:
@@ -239,6 +247,9 @@ foreach (LANG IN ITEMS C CXX Fortran)
if(NOT DEFINED OpenACC_${LANG}_FLAGS)
_OPENACC_GET_FLAGS("${LANG}" OpenACC_${LANG}_FLAGS)
endif()
+ if(NOT DEFINED OpenACC_${LANG}_OPTIONS)
+ separate_arguments(OpenACC_${LANG}_OPTIONS NATIVE_COMMAND "${OpenACC_${LANG}_FLAGS}")
+ endif()
_OPENACC_GET_SPEC_DATE("${LANG}" OpenACC_${LANG}_SPEC_DATE)
_OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}")
@@ -249,6 +260,23 @@ foreach (LANG IN ITEMS C CXX Fortran)
endif()
endforeach()
+foreach (LANG IN ITEMS C CXX Fortran)
+ if(OpenACC_${LANG}_FOUND AND NOT TARGET OpenACC::OpenACC_${LANG})
+ add_library(OpenACC::OpenACC_${LANG} INTERFACE IMPORTED)
+ endif()
+ if(OpenACC_${LANG}_LIBRARIES)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_LIBRARIES "${OpenACC_${LANG}_LIBRARIES}")
+ endif()
+ if(OpenACC_${LANG}_FLAGS)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ unset(_OpenACC_${LANG}_OPTIONS)
+ endif()
+endforeach()
+
unset(OpenACC_C_CXX_TEST_SOURCE)
unset(OpenACC_Fortran_TEST_SOURCE)
unset(OpenACC_C_CXX_CHECK_VERSION_SOURCE)