cmake,fortran 2008和.f08文件扩展名 [英] cmake, fortran 2008, and .f08 file extension

查看:136
本文介绍了cmake,fortran 2008和.f08文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置一个Fortran 2008项目以使用CMake。项目中的文件扩展名为 .f08。但是,即使有一个 hello world示例,我也无法使CMake正常工作。以下是我的CMakeLists.txt文件的相关部分:

I am trying to configure a Fortran 2008 project to use CMake; the files in the project have the ".f08" extension. However, I cannot get CMake to work even with a "hello world" example. Here are the relevant parts of my CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)

project (hello)
enable_language (Fortran)

set (CMAKE_Fortran_SOURCE_FILE_EXTENSIONS ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} "f08;F08")

add_executable ("hello-world" "hello-world.f08")
set_target_properties (hello-world PROPERTIES LINKER_LANGUAGE Fortran)

三个注意事项:


  1. 生成的Makefile无法将 hello-world.f08编译为目标文件。

  2. 需要 set_target_properties。否则,CMake报告它无法确定target:hello-world的链接器语言。

  3. 将文件重命名为 hello-world.f95,以及CMakeLists中的相应更改。 txt使一切正常。甚至不再需要 set_target_properties命令。


推荐答案

如果需要指定Fortran扩展名无法识别的文件,您可以设置源文件的 LANGUAGE 属性,例如:

If you need to specify Fortran files with unrecognized extensions, you can set the source file's LANGUAGE property, e.g.:

set_source_files_properties(hello-world.f08 PROPERTIES LANGUAGE Fortran)

这篇关于cmake,fortran 2008和.f08文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆