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

查看:25
本文介绍了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天全站免登陆