CMake 无法识别混合 C++/FORTRAN 程序中的 FORTRAN 源
CMake not recognizing FORTRAN source in mixed C++/FORTRAN program
我正在将我的一个项目转移到CMake(因为语法的简单性),我曾经使用过自动工具(autoconf,automake等)。我遇到了一个小问题,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 代码。在自动化工具中,这不是问题。此外,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
尝试将 Fortran 指定为 cmake 项目的语言。默认情况下,仅启用 C 和 C++:
(可选)可以指定项目支持的语言。示例语言有C,CXX(即C++),Fortran等。默认情况下,如果未提供语言选项,则启用 C 和 CXX。指定语言 NONE,或使用 LANGUAGES 关键字并列出任何语言,以跳过启用任何语言。
http://www.cmake.org/cmake/help/v3.2/command/project.html
像这样:
project(foo C CXX Fortran)
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- C++,系统无法执行指定的程序
- 编译 Fortran 和C++程序并从英特尔编译器链接
- 在 Python-C++-C-Fortran 2003 程序中链接英特尔的 MKL
- 在Fortran程序中使用Boost Graph库(BGL)
- CMake 无法识别混合 C++/FORTRAN 程序中的 FORTRAN 源
- 调用 Fortran 函数会使程序挂起
- 在将程序与 Fortran 库链接时C++对 _rpoly_ 的未定义引用
- 如何在 C# 应用程序中使用 Fortran 文件
- 确保程序在运行时出错时在 C++/fortran 中的适当位置崩溃
- 使用Fortran 77子程序作为独立程序,从C++调用
- C++与Fortran混合程序的Makefile编译问题
- Fortran程序调用c++函数时发生编译错误
- 为fortran程序员在c++中传递多维数组
- 为什么我的C++程序无法正确加载我的 FORTRAN 库?
- Linux:系统保护,防止c++和FORTRAN程序经常崩溃
- 多线程c++应用程序中的Fortran 77通用块
- 为Fortran可分配程序在C中分配内存
- 使用 GDB 在 Fortran 中调试 MPI 程序
- 将Fortran程序的字符串转换为小写字母的C预处理器宏