I would like to try to use 64-bit gfortran to compile a project in which the rest of the code is compiled with Visual C++ 2017. I've read the netlib article (http://www.netlib.org/lapack/lawnspdf/lawn270.pdf) but it doesn't address my problem, which is how to help CMake select the right Fortran compiler. The CMakeLists.txt file is launched from within Qt Creator.
My CMakeLists.txt file (which I've tested thoroughly using gfortran in Linux and MinGW gfortran on Windows) begins: cmake_minimum_required(VERSION 3.12) project(myProj LANGUAGES Fortran) ...and if I set Qt Creator to parse it with the MSVC compiler option selected, the output is: Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_C_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.9.7/msvc2017_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.9.7/msvc2017_64/bin/qmake.exe". The Fortran compiler identification is unknown CMake Error at CMakeLists.txt:2 (project): No CMAKE_Fortran_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. Fair enough; here's my second attempt: cmake_minimum_required(VERSION 3.12) set(CMAKE_Fortran_COMPILER "C:/Qt/Tools/mingw730_64/bin/gfortran.exe") project(myProj LANGUAGES Fortran) ...and this gives me: Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_C_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX86/x64/cl.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.9.7/msvc2017_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.9.7/msvc2017_64/bin/qmake.exe". The Fortran compiler identification is unknown Check for working Fortran compiler: C:/Qt/Tools/mingw730_64/bin/gfortran.exe CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_Fortran_PREPROCESS_SOURCE CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestFortranCompiler.cmake:30 (try_compile): Failed to generate test project build system. Call Stack (most recent call first): CMakeLists.txt:3 (project) In place of the "set(CMAKE_Fortran_COMPILER..." line I've also tried set($ENV{FC} "C:/Qt/Tools/mingw730_64/bin/gfortran.exe") ...which gave me the error message Could not find compiler set in environment variable FC: CMAKE_Fortran_COMPILER-NOTFOUND ..and set($ENV{FC} "C:/Qt/Tools/mingw730_64/bin") ... which gave me exactly the same error as I got in the first case. So what am I doing wrong here?
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake