summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Maynard <rmaynard@nvidia.com>2023-06-23 13:21:41 (GMT)
committerBrad King <brad.king@kitware.com>2023-06-23 16:14:09 (GMT)
commitf73ae7c510f30675ee3c6065b6411e19ca3ff04c (patch)
tree0a2853fbbb3d3d30887355224a21b8292fef5288
parentf58c7659d8652c1172fc15a0bae9d71ee477c1eb (diff)
downloadCMake-f73ae7c510f30675ee3c6065b6411e19ca3ff04c.zip
CMake-f73ae7c510f30675ee3c6065b6411e19ca3ff04c.tar.gz
CMake-f73ae7c510f30675ee3c6065b6411e19ca3ff04c.tar.bz2
NVHPC: Support nvfortran versions that don't support isystem
Fixes: #25019
-rw-r--r--Modules/Compiler/NVHPC-Fortran.cmake4
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/add_subdirectory/System.cmake3
-rw-r--r--Tests/RunCMake/add_subdirectory/System/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/System/zap.f0
7 files changed, 16 insertions, 1 deletions
diff --git a/Modules/Compiler/NVHPC-Fortran.cmake b/Modules/Compiler/NVHPC-Fortran.cmake
index 59755b3..ca5f1b2 100644
--- a/Modules/Compiler/NVHPC-Fortran.cmake
+++ b/Modules/Compiler/NVHPC-Fortran.cmake
@@ -1,3 +1,7 @@
include(Compiler/PGI-Fortran)
include(Compiler/NVHPC)
__compiler_nvhpc(Fortran)
+if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 21.7)
+ # Before NVHPC 21.7 nvfortran didn't support isystem
+ unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran)
+endif()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index f089a96..63b7568 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -452,7 +452,7 @@ add_RunCMake_test(add_custom_target)
add_RunCMake_test(add_dependencies)
add_RunCMake_test(add_executable)
add_RunCMake_test(add_library)
-add_RunCMake_test(add_subdirectory)
+add_RunCMake_test(add_subdirectory -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER})
add_RunCMake_test(add_test)
add_RunCMake_test(build_command)
add_executable(exit_code exit_code.c)
diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake
index ddf45af..3c70d07 100644
--- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake
@@ -3,7 +3,9 @@ include(RunCMake)
run_cmake(DoesNotExist)
run_cmake(Missing)
run_cmake(Function)
+set(RunCMake_TEST_OPTIONS -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER})
run_cmake(System)
+unset(RunCMake_TEST_OPTIONS)
macro(run_cmake_install case)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
diff --git a/Tests/RunCMake/add_subdirectory/System.cmake b/Tests/RunCMake/add_subdirectory/System.cmake
index 45d7d9a..1048a7a 100644
--- a/Tests/RunCMake/add_subdirectory/System.cmake
+++ b/Tests/RunCMake/add_subdirectory/System.cmake
@@ -1,4 +1,7 @@
enable_language(CXX)
+if(CMAKE_Fortran_COMPILER)
+ enable_language(Fortran)
+endif()
add_subdirectory(System SYSTEM)
diff --git a/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt
index ef74e80..8653b6f 100644
--- a/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt
+++ b/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt
@@ -4,6 +4,11 @@ add_subdirectory(SubSub1 SYSTEM)
add_subdirectory(SubSub2)
add_library(bar STATIC bar.cpp)
+if(CMAKE_Fortran_COMPILER)
+ target_sources(bar PRIVATE zap.f)
+endif()
+# Verify CMAKE_INCLUDE_SYSTEM_FLAG_<LANG> works
+target_link_libraries(bar PRIVATE subsub1bar)
add_library(foo STATIC foo.cpp)
set_target_properties(foo PROPERTIES SYSTEM OFF)
diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt
index 291339b..24105b0 100644
--- a/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt
+++ b/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt
@@ -1,4 +1,5 @@
add_library(subsub1bar STATIC bar.cpp)
+target_include_directories(subsub1bar PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
add_library(subsub1foo STATIC foo.cpp)
set_target_properties(subsub1foo PROPERTIES SYSTEM OFF)
diff --git a/Tests/RunCMake/add_subdirectory/System/zap.f b/Tests/RunCMake/add_subdirectory/System/zap.f
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/System/zap.f