Cmake 3.17 Visual Studio 2015 x64 MinGW64 fortran compilation issues

Good day,
I have a mixed C++/Fortran Project I am trying to compile on Windows 10 (latest update) with the latest version of cmake and running into an issue related to the fortran compilation.
Note that I have MINGW64 compilers installed on the system and point to MINGW’s fortran via the CMake variable MINGW_FORTRAN = C:/Program Files/mingw-w64/x86_64-6.4.0-posix-seh-rt_v5-rev0/mingw64/bin/gfortran.exe

Everything was working fine with a prior version of cmake (cannot remember which one)
I am using cmake with the target “Visual Studio 14 2015” -A x64.

I am getting the following error now

1>  Performing build step for 'strandf_build'
1>  mingw32-make.exe: *** No targets specified and no makefile found.  Stop.
1>  No install step for 'strandf_build'
1>  Completed 'strandf_build'
2>  Performing build step for 'nurbsf_build'
2>  mingw32-make.exe: *** No targets specified and no makefile found.  Stop.
2>  No install step for 'nurbsf_build'
2>  Completed 'nurbsf_build'

Any help would be appreciated.
Here are below CMakeList.txt codes

Thanks
Eric

I have some C/C++ code in a folder and the fortran in a subfolder.

Here is the code in the C/C++ folder

cmake_minimum_required (VERSION 2.8.11)

project(strand)

if(WIN32)
  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
endif()

set(SRC
   conjGrad.c
   edgeOpt.c
   elementFns.c
   emp.c
   emp.h
   strandOpt.c
   strandSmooth.c)

if(WIN32)
  set_source_files_properties(strandOpt.c PROPERTIES LANGUAGE CXX)
endif()

add_library(strand STATIC ${SRC} )

set_target_properties(strand PROPERTIES OUTPUT_NAME "${PREFIX}strand${LIBVERSION}${SUFFIX}")

set_property(TARGET strand APPEND PROPERTY
  INTERFACE_INCLUDE_DIRECTORIES
  "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
  )

if(NOT DEFINED CMAKE_INSTALL_BINARY_DIR)
  set(CMAKE_INSTALL_BINARY_DIR bin)
endif()

if(CREATE_BUILD_FORTRAN)
  include(CMakeAddFortranSubdirectory)
  cmake_add_fortran_subdirectory(fortran
    PROJECT strandf
    ARCHIVE_DIR fortran
    RUNTIME_DIR fortran
    LIBRARIES strandf
    LINK_LIBRARIES
    LINK_LIBS strandf
    NO_EXTERNAL_INSTALL)

  set(STRAND_FORTRAN_LIBS strandf)

  if(WIN32 AND NOT CMAKE_Fortran_COMPILER)
    # Copy the MinGW built dll to the bin directory.
    add_custom_command(TARGET strand POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy
        "${CMAKE_CURRENT_BINARY_DIR}/fortran/libstrandf.dll"
        "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(Configuration)")

    install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/fortran/libstrandf.dll"
        DESTINATION "${CMAKE_INSTALL_BINARY_DIR}" COMPONENT Runtime)
  endif()

else()

  find_package(StrandFortran)

  # Add the strand fortran library to the install.
  foreach(lib ${STRAND_FORTRAN_LIBS})
    get_property(thefile TARGET ${lib} PROPERTY IMPORTED_LOCATION)
    install(PROGRAMS "${thefile}"
        DESTINATION "${CMAKE_INSTALL_BINARY_DIR}" COMPONENT Runtime)
  endforeach()

endif()

target_link_libraries(strand ${STRAND_FORTRAN_LIBS})

include(TheMacros)
setup_fortran(STRAND)

The setup_fortran is just handling the name mangling modif to the code.

In the fortran directory, I have the following CMakeLists.txt

cmake_minimum_required(VERSION 2.8.11)

project(strandf Fortran C)

set(C_SRC
    adStack.c
    derfcb.c)

set(SRC
    adBuffer.f
    cross_b.f
    dotprod_b.f
    edgeObjFun.f
    fillex_b.f
    fillx_b.f
    objefun_b.f
    objfun_b.f
    strandObjFun.f)

add_library(strandf SHARED ${SRC} ${C_SRC})

if(CMAKE_SYSTEM_NAME MATCHES Linux)
  set_target_properties(strandf PROPERTIES INSTALL_RPATH "\$ORIGIN")
endif(CMAKE_SYSTEM_NAME MATCHES Linux)

if(CMAKE_SYSTEM_NAME MATCHES Darwin)
  set_target_properties(strandf PROPERTIES INSTALL_RPATH "@loader_path/")
endif(CMAKE_SYSTEM_NAME MATCHES Darwin)

if(NOT CMAKE_INSTALL_BINARY_DIR)
  set(CMAKE_INSTALL_BINARY_DIR bin)
endif()
  
install(TARGETS strandf
    DESTINATION "${CMAKE_INSTALL_BINARY_DIR}" COMPONENT Runtime)

@brad.king

Since the external project (Fortran subdirectory) fails to build with:

mingw32-make.exe: *** No targets specified and no makefile found. Stop

I suspect something is going wrong earlier.

In the Fortran subdirectory I see:

project(strandf Fortran C)

That will look for a mingw C compiler in addition to a mingw Fortran compiler. Is the C compiler installed?

Thanks Brad,

Fortran and C were installed.

I found the issue. It stems from me installing mingw-w64 in its default folder under c:\Program Files. The space character in the path is problematic. I solved this by installing mingw-w64 in my root c:\ming-w64 and that solved the issue.

I also tried to update to a newer version of mingw-w64 (fortran-5) but was not successful for other reason that Cmake. I needed to recompile lapack and blas with those new compilers. … which I will do in the near future.

Thanks for your help.

Eric