【发布时间】:2015-04-10 17:39:59
【问题描述】:
我正在将我的一个项目转移到我曾经使用自动工具(autoconf、automake 等)的 CMake(因为语法简单)。我遇到了一个小问题,CMake 没有识别出我的源代码树中有 FORTRAN 代码。
我构建的其中一个库同时依赖于 C++ 和 FORTRAN 源代码。我使用以下语法来构建库
add_library(matrix
double/matrix_constructor_double.cpp
double/matrix_io_double.cpp
double/matrix_miscmath_double.cpp
double/matrix_miscop_double.cpp
double/matrix_overload_double.cpp
double/matrix_setters_double.cpp
double/eigsrt_double.f
double/pkconv_double.f)
CMake 运行得很好,但是当我尝试制作项目时,我得到以下信息:
Scanning dependencies of target matrix
[ 45%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_constructor_double.cpp.o
[ 50%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_io_double.cpp.o
[ 54%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_miscmath_double.cpp.o
[ 59%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_miscop_double.cpp.o
[ 63%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_overload_double.cpp.o
[ 68%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_setters_double.cpp.o
它完全忽略了我指定的 FORTRAN 代码。在 autotools 中,这不是问题。此外,CMake 也不识别我有 FORTRAN 代码,即
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dbwy/git_repo/chronusq/build
如果我尝试手动指定 FORTRAN 编译器,我会得到以下信息
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_Fortran_COMPILER
我的 CMake 中是否缺少一些与 FORTRAN 配合使用的功能?我正在使用 cmake 3.0.2
【问题讨论】: