Fortran: Ninja generator fails on symlinked source dirs
I am on:
$ uname -a
FreeBSD deblndw011x.ad001.siemens.net 12.2-STABLE FreeBSD 12.2-STABLE #3 r369441: Fri Apr 9 14:09:31 CEST 2021
$ cmake --version
cmake version 3.20.1
$ ninja --version
1.10.2
Consider the following layout:
osipovmi@deblndw011x:~/DI-Programme-Portable
$ ll | grep lib
drwxr-xr-x 10 osipovmi cad 8192 2021-05-03 20:06 _libcafe/
lrwxr-xr-x 1 osipovmi cad 17 2021-05-08 20:26 libcafe_json@ -> _libcafe/CaFEJson
lrwxr-xr-x 1 osipovmi cad 16 2021-05-08 20:26 libcafe_ket@ -> _libcafe/CaFEKet
lrwxr-xr-x 1 osipovmi cad 18 2021-05-08 20:26 libcafe_plot@ -> _libcafe/CaFEPlot
lrwxr-xr-x 1 osipovmi cad 20 2021-05-08 20:26 libcafe_smartld@ -> _libcafe/CaFESmartLD
drwxr-x--- 6 osipovmi cad 8192 2021-05-11 17:12 libmath/
drwxr-x--- 6 osipovmi cad 8192 2021-05-11 17:12 libsblm/
drwxr-x--- 6 osipovmi cad 8192 2021-05-11 17:12 libsbm/
drwxr-xr-x 6 osipovmi cad 8192 2021-05-11 17:12 libsgram/
drwxr-x--- 7 osipovmi cad 8192 2021-05-11 17:12 libsm/
now try to generate Ninja files for libcafe_json:
osipovmi@deblndw011x:~/DI-Programme-Portable
$ cd libcafe_json/build/freebsd/
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ rm -rf *
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ echo $system_name
freebsd
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ echo $generator
Ninja
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ CC="gcc10" FC="gfortran10" cmake ../.. -G "$generator" "-DDIPROJ_CMAKE_MODULE_PATH=$HOME/DI-Programme-Portable/cmake" "-DCMAKE_INSTALL_PREFIX=$HOME/ldacafe/$system_name" -DDIPROJ_SYSTEM_TYPE=CaFE -DINSTALL_WITH_SUDO=OFF;
-- The C compiler identification is GNU 10.3.0
-- The Fortran compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/gcc10 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: /usr/local/bin/gfortran10
-- Check for working Fortran compiler: /usr/local/bin/gfortran10 - broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestFortranCompiler.cmake:51 (message):
The Fortran compiler
"/usr/local/bin/gfortran10"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /net/home/osipovmi/DI-Programme-Portable/libcafe_json/build/freebsd/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/local/bin/ninja cmTC_43608 && [1/4] Building Fortran preprocessed CMakeFiles/cmTC_43608.dir/testFortranCompiler.f-pp.f
[2/4] Generating Fortran dyndep file CMakeFiles/cmTC_43608.dir/Fortran.dd
ninja: build stopped: CMakeFiles/cmTC_43608.dir/Fortran.dd:2: no build statement exists for '/net/home/osipovmi/DI-Programme-Portable/_libcafe/CaFEJson/build/freebsd/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_43608.dir/testFortranCompiler.f.o'
.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
See also "/net/home/osipovmi/DI-Programme-Portable/libcafe_json/build/freebsd/CMakeFiles/CMakeOutput.log".
See also "/net/home/osipovmi/DI-Programme-Portable/libcafe_json/build/freebsd/CMakeFiles/CMakeError.log".
Lets do now the same for make (BSD make):
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ generator="Unix Makefiles"
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ CC="gcc10" FC="gfortran10" cmake ../.. -G "$generator" "-DDIPROJ_CMAKE_MODULE_PATH=$HOME/DI-Programme-Portable/cmake" "-DCMAKE_INSTALL_PREFIX=$HOME/ldacafe/$system_name" -DDIPROJ_SYSTEM_TYPE=CaFE -DINSTALL_WITH_SUDO=OFF;
-- The C compiler identification is GNU 10.3.0
-- The Fortran compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/gcc10 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/local/bin/gfortran10 - skipped
-- Checking whether /usr/local/bin/gfortran10 supports Fortran 90
-- Checking whether /usr/local/bin/gfortran10 supports Fortran 90 - yes
-- Setting build type to 'Debug' as none was specified on the command line
-- Configuring done
-- Generating done
-- Build files have been written to: /net/home/osipovmi/DI-Programme-Portable/libcafe_json/build/freebsd
Now go back to Ninja, and not use the symlink:
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ generator="Ninja"
osipovmi@deblndw011x:~/DI-Programme-Portable/libcafe_json/build/freebsd (portable=)
$ cd ../../..
osipovmi@deblndw011x:~/DI-Programme-Portable
$ cd _libcafe/CaFEJson/build/freebsd/
osipovmi@deblndw011x:~/DI-Programme-Portable/_libcafe/CaFEJson/build/freebsd (portable=)
$ rm -rf *
osipovmi@deblndw011x:~/DI-Programme-Portable/_libcafe/CaFEJson/build/freebsd (portable=)
$ CC="gcc10" FC="gfortran10" cmake ../.. -G "$generator" "-DDIPROJ_CMAKE_MODULE_PATH=$HOME/DI-Programme-Portable/cmake" "-DCMAKE_INSTALL_PREFIX=$HOME/ldacafe/$system_name" -DDIPROJ_SYSTEM_TYPE=CaFE -DINSTALL_WITH_SUDO=OFF;
-- The C compiler identification is GNU 10.3.0
-- The Fortran compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/gcc10 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/local/bin/gfortran10 - skipped
-- Checking whether /usr/local/bin/gfortran10 supports Fortran 90
-- Checking whether /usr/local/bin/gfortran10 supports Fortran 90 - yes
-- Setting build type to 'Debug' as none was specified on the command line
-- Configuring done
-- Generating done
-- Build files have been written to: /net/home/osipovmi/DI-Programme-Portable/_libcafe/CaFEJson/build/freebsd
osipovmi@deblndw011x:~/DI-Programme-Portable/_libcafe/CaFEJson/build/freebsd (portable=)
$ ls
build.ninja cmake_install.cmake CMakeCache.txt CMakeFiles/ dilib.version
I don't know whether CMake fails here or Ninja, since Unix Makefiles generator works. If this isn't an issue with CMake I'd be happy to take this to Ninja devs.
Edited by Brad King