<div dir="ltr"><div><div><div><div>I would like to use CMake for a personal project instead of make (which does work), but I can't seem to get CMake to work the way I think it should. The command "cmake ." runs fine, but the make produces this:<br><br><span style="font-family:monospace,monospace">Scanning dependencies of target MIFF<br>Linking Fortran shared library libMIFF.so<br>gfortran: fatal error: no input files; unwilling to write output files<br>compilation terminated.<br>make[2]: *** [src/libMIFF.so] Error 4<br>make[1]: *** [src/CMakeFiles/MIFF.dir/all] Error 2<br>make: *** [all] Error 2<br></span><br></div><div>This surprises me because I don't think I should see "gfortran" - I expected to see "mpif90". And that particular message seems to happen when there are insufficient arguments to "gfortran". (the wrapper "mpif90" is configured to use "gfortran", but all compilation should use the "mpif90" - which doesn't appear to be the case when looking through the generated makefiles.)<br><br></div><div>Here's what my project looks like:<br></div><div><br></div>Directory structure:<br></div>MIFF<br></div> - src/<br></div><div> - - CMakeLists.txt<br></div><div> - - MIFFTest.f08<br> - - MIFFTestMessage.f08<br> - - MpiIocBaseMessage.f08<br> - - MpiIocControlMessage.f08<br> - - MpiIocFramework.f08<br> - - MpiIocLinkedListItem.f08<br></div> - CMakeLists.txt<br><div><br></div><div>My system is:<br>Ubuntu 14.04.4 LTS<br>The mpif90 compiler is:<br>GNU Fortran (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4<br>CMake reports:<br>cmake version 2.8.12.2<br><br></div><div>Hopefully this is already fixed in newer versions of cmake - but this is the version currently installed - but that's difficult for me to test, as I'm working on a system that shouldn't deviate too far from our standard development platform.<br></div><div><br></div><div>The CMakeLists.txt file in the MIFF directory is:<br><span style="font-family:monospace,monospace">cmake_minimum_required (VERSION 2.8.6)<br>project( MIFF_Project )<br>add_subdirectory( src )<br></span><br></div><div>the CMakeLists.txt file in the MIFF/src directory is:<br><span style="font-family:monospace,monospace">cmake_minimum_required( VERSION 2.8.8 )<br>project( MIFF_Project )<br>enable_language( Fortran )<br>set( CMAKE_FORTRAN_COMPILER mpif90 )<br>file( GLOB MIFF_Code *.f* )<br>message( STATUS "MIFF_Code: ${MIFF_Code}" )<br>add_library( MIFF SHARED ${MIFF_Code} )<br>set_target_properties( MIFF PROPERTIES LINKER_LANGUAGE Fortran ) # OUTPUT_NAME MIFF )<br></span><br></div><div>I think I've exhausted Google looking for a solution, and I have a standard Makefile that seems to work fine:<br><br><span style="font-family:monospace,monospace">.PHONY : all clean run<br><br>COMPILER     = mpif90<br>FFLAGS       = -shared -fPIC -g -I/usr/include<br>LIBRARY      = MIFF.so<br>EXECUTABLE   = MIFFTest<br>EXESOURCES   = src/MIFFTest.f08 \<br>               src/MIFFTestMessage.f08<br>LIBSOURCES   = src/MpiIocBaseMessage.f08 \<br>               src/MpiIocControlMessage.f08 \<br>               src/MpiIocLinkedListItem.f08 \<br>               src/MpiIocFramework.f08<br><br>src/MIFFTest.o : src/MIFFTest.f08 src/MIFFTestMessage.f08<br><br>all : $(LIBRARY) $(EXECUTABLE)<br><br>clean :<br>    - rm -f *.o *.so *.mod $(EXECUTABLE)<br><br>run :<br>    export LD_LIBRARY_PATH=~/workspace/MIFF<br>    mpiexec -n 2 $(EXECUTABLE)<br><br><br>$(LIBRARY) : $(LIBSOURCES)<br>    $(COMPILER) $(FFLAGS) $(LIBSOURCES) -o $(LIBRARY)<br><br>$(EXECUTABLE) : $(EXESOURCES) $(LIBRARY)<br>    export LD_LIBRARY_PATH=~/workspace/MIFF<br>    $(COMPILER) -o $(EXECUTABLE) $(EXESOURCES) $(LIBRARY)<br></span><br><br>Except for the problem of having to issue the "make all" twice because of a dependency problem I haven't worked out, this hand-crafted Makefile works. It's bad enough that I'm pushing the boundaries of polymorphism in MPI+OpenMP+Fortran.<br><br></div><div>I'd appreciate any assistance getting cmake to work for my project.<br><br></div></div>