瀏覽代碼

VS: Fix Fortran target type selection with RC sources

The Intel Fortran `.vfproj` files do support both Fortran and the
Windows Resource compiler (`.rc)` files.  Prior to CMake 3.9 we did not
support that, but commit 2c9f35789d (VS: Decide project type by linker
lang as fallback, 2017-03-30, v3.9.0-rc1~340^2) accidentally enabled it.
It was then broken by commit d3d2c3cd49 (VS: Fix Fortran target type
selection when linking C++ targets, 2019-02-04, v3.14.0-rc1~13^2).

Restore support for Fortran+RC in VS projects and add a test case.

Fixes: #19002
Brad King 6 年之前
父節點
當前提交
0b82f56ac6
共有 3 個文件被更改,包括 11 次插入1 次删除
  1. 4 0
      Source/cmGlobalVisualStudioGenerator.cxx
  2. 7 1
      Tests/FortranOnly/CMakeLists.txt
  3. 0 0
      Tests/FortranOnly/testRC.rc

+ 4 - 0
Source/cmGlobalVisualStudioGenerator.cxx

@@ -834,6 +834,10 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
   if (linkLang && *linkLang) {
     languages.insert(linkLang);
   }
+
+  // Intel Fortran .vfproj files do support the resource compiler.
+  languages.erase("RC");
+
   return languages.size() == 1 && *languages.begin() == "Fortran";
 }
 

+ 7 - 1
Tests/FortranOnly/CMakeLists.txt

@@ -12,6 +12,12 @@ add_executable(FortranOnly1 testf.f)
 set_property(TARGET FortranOnly1 PROPERTY OUTPUT_NAME FortranOnly)
 target_link_libraries(FortranOnly1 FortranOnlylib)
 
+# Test that Fortran+RC work together.
+# FIXME: Add .rc in more cases.
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+  set(test_rc testRC.rc)
+endif()
+
 # create a custom command that runs FortranOnly1 and puts
 # the output into the file testfhello.txt
 add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt
@@ -20,7 +26,7 @@ add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt
 # create a second executable FortranOnly2 that has
 # testfhello.txt has an source file so that it will
 # run the above custom command.
-add_executable(FortranOnly2 testfhello.txt testf.f)
+add_executable(FortranOnly2 testfhello.txt testf.f ${test_rc})
 target_link_libraries(FortranOnly2 FortranOnlylib)
 # create a custom target to check the content of testfhello.txt
 # by running the cmake script checktestf2.cmake

+ 0 - 0
Tests/FortranOnly/testRC.rc