From 417e6cdb7cb875c4c884941353f153d5c988f813 Mon Sep 17 00:00:00 2001
From: Pradipta Samanta <samanta@dkrz.de>
Date: Mon, 24 Feb 2025 21:57:30 +0100
Subject: [PATCH] added openacc_fortran_options only for the compilation of
 Fortran codes

fixed a cmake style

added to two other components
---
 src/horizontal/CMakeLists.txt    | 4 +++-
 src/interpolation/CMakeLists.txt | 3 ++-
 src/support/CMakeLists.txt       | 4 +++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/horizontal/CMakeLists.txt b/src/horizontal/CMakeLists.txt
index d2abe7d..078a14d 100644
--- a/src/horizontal/CMakeLists.txt
+++ b/src/horizontal/CMakeLists.txt
@@ -39,7 +39,9 @@ if(IM_ENABLE_OPENACC)
   # If _OPENACC is defined, assume that the required compiler flags are already
   # provided, e.g. in CMAKE_Fortran_FLAGS:
   if(NOT HAS_OPENACC_MACRO)
-    target_compile_options(iconmath-horizontal PRIVATE ${OpenACC_Fortran_OPTIONS})
+    target_compile_options(iconmath-horizontal
+                           PRIVATE
+                           $<$<COMPILE_LANGUAGE:Fortran>:${OpenACC_Fortran_OPTIONS}>)
     # This make sures that unit tests (FortUTF) compiles without the need of
     # passing OpenACC compile option.
     target_link_libraries(iconmath-horizontal PRIVATE OpenACC::OpenACC_Fortran)
diff --git a/src/interpolation/CMakeLists.txt b/src/interpolation/CMakeLists.txt
index 346aaaa..f982f3b 100644
--- a/src/interpolation/CMakeLists.txt
+++ b/src/interpolation/CMakeLists.txt
@@ -41,7 +41,8 @@ if(IM_ENABLE_OPENACC)
   # provided, e.g. in CMAKE_Fortran_FLAGS:
   if(NOT HAS_OPENACC_MACRO)
     target_compile_options(iconmath-interpolation
-                           PRIVATE ${OpenACC_Fortran_OPTIONS})
+                           PRIVATE
+                           $<$<COMPILE_LANGUAGE:Fortran>:${OpenACC_Fortran_OPTIONS}>)
     # This make sures that unit tests (FortUTF) compiles without the need of
     # passing OpenACC compile option.
     target_link_libraries(iconmath-interpolation PRIVATE OpenACC::OpenACC_Fortran)
diff --git a/src/support/CMakeLists.txt b/src/support/CMakeLists.txt
index ed6a4d3..e78fc16 100644
--- a/src/support/CMakeLists.txt
+++ b/src/support/CMakeLists.txt
@@ -50,7 +50,9 @@ if(IM_ENABLE_OPENACC)
   # If _OPENACC is defined, assume that the required compiler flags are already
   # provided, e.g. in CMAKE_Fortran_FLAGS:
   if(NOT HAS_OPENACC_MACRO)
-    target_compile_options(iconmath-support PRIVATE ${OpenACC_Fortran_OPTIONS})
+    target_compile_options(iconmath-support
+                           PRIVATE
+                           $<$<COMPILE_LANGUAGE:Fortran>:${OpenACC_Fortran_OPTIONS}>)
     # This make sures that unit tests (FortUTF) compiles without the need of
     # passing OpenACC compile option.
     target_link_libraries(iconmath-support PRIVATE OpenACC::OpenACC_Fortran)
-- 
GitLab