Reputation: 1
I am trying to use Cmake to manage the dependencies of the Fortran and C code when I compiled the spectral solver. But it seems that Cmake cannot find the compiler although I have downloaded the Fortran and GCC already. This is the error I am getting. I hope there is someone who can tell me how to solve it.
`CMake Error at /usr/share/cmake-3.16/Modules/CMakeDetermineCompiler.cmake:58 (set_property):
set_property could not find CACHE variable CMAKE_Fortran_COMPILER. Perhaps
it has not yet been created.
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/CMakeDetermineFortranCompiler.cmake:96 (_cmake_find_compiler)
CMakeLists.txt:109 (project)
-- The Fortran compiler identification is unknown
CMake Error at /usr/share/cmake-3.16/Modules/CMakeDetermineCompiler.cmake:58 (set_property):
set_property could not find CACHE variable CMAKE_C_COMPILER. Perhaps it
has not yet been created.
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:65 (_cmake_find_compiler)
CMakeLists.txt:109 (project)
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:109 (project):
No CMAKE_Fortran_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH.
CMake Error at CMakeLists.txt:109 (project):
No CMAKE_C_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.`
Upvotes: 0
Views: 4455
Reputation: 11
You need set the env variables. I used the following steps:
1: vim ~/.bashrc (to set the env variables)
2: Add the following statements
export CC=/usr/bin/gcc
(the path basically) and export FC=/usr/bin/gfortran
3 - Also make sure your path to PETSC_DIR and PETSC_ARCH is defined, add the following statements too, export PETSC_DIR = /path/to/petsc
and export PETSC_ARCH = gfortran
4 - save and close the file
5 - Run this on command line - to read and execute the bash script source ~/.bashrc
Upvotes: 1