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:
Scanning dependencies of target MIFF Linking Fortran shared library libMIFF.so gfortran: fatal error: no input files; unwilling to write output files compilation terminated. make[2]: *** [src/libMIFF.so] Error 4 make[1]: *** [src/CMakeFiles/MIFF.dir/all] Error 2 make: *** [all] Error 2 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.) Here's what my project looks like: Directory structure: MIFF - src/ - - CMakeLists.txt - - MIFFTest.f08 - - MIFFTestMessage.f08 - - MpiIocBaseMessage.f08 - - MpiIocControlMessage.f08 - - MpiIocFramework.f08 - - MpiIocLinkedListItem.f08 - CMakeLists.txt My system is: Ubuntu 14.04.4 LTS The mpif90 compiler is: GNU Fortran (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4 CMake reports: cmake version 2.8.12.2 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. The CMakeLists.txt file in the MIFF directory is: cmake_minimum_required (VERSION 2.8.6) project( MIFF_Project ) add_subdirectory( src ) the CMakeLists.txt file in the MIFF/src directory is: cmake_minimum_required( VERSION 2.8.8 ) project( MIFF_Project ) enable_language( Fortran ) set( CMAKE_FORTRAN_COMPILER mpif90 ) file( GLOB MIFF_Code *.f* ) message( STATUS "MIFF_Code: ${MIFF_Code}" ) add_library( MIFF SHARED ${MIFF_Code} ) set_target_properties( MIFF PROPERTIES LINKER_LANGUAGE Fortran ) # OUTPUT_NAME MIFF ) I think I've exhausted Google looking for a solution, and I have a standard Makefile that seems to work fine: .PHONY : all clean run COMPILER = mpif90 FFLAGS = -shared -fPIC -g -I/usr/include LIBRARY = MIFF.so EXECUTABLE = MIFFTest EXESOURCES = src/MIFFTest.f08 \ src/MIFFTestMessage.f08 LIBSOURCES = src/MpiIocBaseMessage.f08 \ src/MpiIocControlMessage.f08 \ src/MpiIocLinkedListItem.f08 \ src/MpiIocFramework.f08 src/MIFFTest.o : src/MIFFTest.f08 src/MIFFTestMessage.f08 all : $(LIBRARY) $(EXECUTABLE) clean : - rm -f *.o *.so *.mod $(EXECUTABLE) run : export LD_LIBRARY_PATH=~/workspace/MIFF mpiexec -n 2 $(EXECUTABLE) $(LIBRARY) : $(LIBSOURCES) $(COMPILER) $(FFLAGS) $(LIBSOURCES) -o $(LIBRARY) $(EXECUTABLE) : $(EXESOURCES) $(LIBRARY) export LD_LIBRARY_PATH=~/workspace/MIFF $(COMPILER) -o $(EXECUTABLE) $(EXESOURCES) $(LIBRARY) 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. I'd appreciate any assistance getting cmake to work for my project.
-- 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: http://public.kitware.com/mailman/listinfo/cmake