# Cmake 3.17 Visual Studio 2015 x64 MinGW64 fortran compilation issues

**URL:** <https://discourse.cmake.org/t/cmake-3-17-visual-studio-2015-x64-mingw64-fortran-compilation-issues/1076>\
**Category:** Code\
**Created:** [April 22, 2020, 6:24pm UTC](https://discourse.cmake.org/t/cmake-3-17-visual-studio-2015-x64-mingw64-fortran-compilation-issues/1076 "2020-04-22T18:24:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elm](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/57b2e6/32.png) [@elm](https://discourse.cmake.org/u/elm)\
**Post date:** [April 22, 2020, 6:24pm UTC](https://discourse.cmake.org/t/cmake-3-17-visual-studio-2015-x64-mingw64-fortran-compilation-issues/1076/1 "2020-04-22T18:24:12Z")

</div>

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

```auto
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
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
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)

```

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [April 27, 2020, 1:49pm UTC](https://discourse.cmake.org/t/cmake-3-17-visual-studio-2015-x64-mingw64-fortran-compilation-issues/1076/2 "2020-04-27T13:49:53Z")

</div>

@brad.king

---

<div class="post-metadata">

**Author:** ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)\
**Post date:** [April 28, 2020, 12:27pm UTC](https://discourse.cmake.org/t/cmake-3-17-visual-studio-2015-x64-mingw64-fortran-compilation-issues/1076/3 "2020-04-28T12:27:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![elm](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/57b2e6/32.png) [@elm](https://discourse.cmake.org/u/elm)\
**Post date:** [April 28, 2020, 2:37pm UTC](https://discourse.cmake.org/t/cmake-3-17-visual-studio-2015-x64-mingw64-fortran-compilation-issues/1076/4 "2020-04-28T14:37:05Z")

</div>

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
