summaryrefslogtreecommitdiff
path: root/Modules/CMakeHIPCompilerId.hip.in
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-08-28 15:03:39 -0400
committerZack Galbreath <zack.galbreath@kitware.com>2021-06-07 19:25:33 +0000
commitb50bfc89131e55685aa41146254b37d26049b4d5 (patch)
treee6ed45ba63b75decf4c9436fac6139174850370b /Modules/CMakeHIPCompilerId.hip.in
parentff0d2858e1e47af8e849318b411b1fbd8579a053 (diff)
downloadcmake-b50bfc89131e55685aa41146254b37d26049b4d5.tar.gz
HIP: Add language to CMake
Diffstat (limited to 'Modules/CMakeHIPCompilerId.hip.in')
-rw-r--r--Modules/CMakeHIPCompilerId.hip.in54
1 files changed, 54 insertions, 0 deletions
diff --git a/Modules/CMakeHIPCompilerId.hip.in b/Modules/CMakeHIPCompilerId.hip.in
new file mode 100644
index 0000000000..5258efba04
--- /dev/null
+++ b/Modules/CMakeHIPCompilerId.hip.in
@@ -0,0 +1,54 @@
+#ifndef __HIP__
+# error "A C or C++ compiler has been selected for HIP"
+#endif
+
+@CMAKE_HIP_COMPILER_ID_CONTENT@
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+@CMAKE_HIP_COMPILER_ID_PLATFORM_CONTENT@
+@CMAKE_HIP_COMPILER_ID_ERROR_FOR_TEST@
+
+const char* info_language_dialect_default = "INFO" ":" "dialect_default["
+#if __cplusplus > 202002L
+ "23"
+#elif __cplusplus > 201703L
+ "20"
+#elif __cplusplus >= 201703L
+ "17"
+#elif __cplusplus >= 201402L
+ "14"
+#elif __cplusplus >= 201103L
+ "11"
+#else
+ "98"
+#endif
+"]";
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+ require += info_language_dialect_default[argc];
+ (void)argv;
+ return require;
+}