0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

fpm (Fortran Package Manager)コマンドチートシート

0
Posted at

Help

それぞれのサブコマンドに--helpを加えることでオプションの詳細を表示する

fpm new --help
fpm build --help
fpm run --help
fpm test --help
fpm install --help

共通オプション

--flag FFLAGS

コンパイラに渡すフラグ

--link-flag LDFLAGS

リンカ(ld)に渡すフラグ

--profile debug
--profile release

debug: --flagオプションに加える形でコンパイル時にデバックに関するオプションを加える
release: --flagオプションに加える形でコンパイル時に最適化に関するオプションを加える

fpmプロジェクト作成

fpm new ${newproject}
# 実行ファイルの場合は`--app`を入れる
fpm new ${newproject} --app --src --test
fpm new ${newproject} --app --src --test --example
# ライブラリを作る場合は`--app`なし
fpm new ${newproject} --src --test
fpm new ${newproject} --src --test --example

デフォルトは内部でgitの実行とapp,src,testディレクトリを自動作成。必要なディレクトリに応じてオプションを加える。appにはメインルーチンを入れる。

ビルドについて

fpm build #bebugオプションを付けた時と同じ
fpm build --profile debug
fpm build --profile release
# testをビルドしたい場合
fpm build --tests

testについて

すべてのテストを実行

fpm test

target指定したtestだけを実行する

fpm test --target XXX

runについて

appの実行リストを出力

fpm run --list

すべてのappを実行する

fpm run

target指定したappだけを実行する

fpm run --target XXX

exampleの実行リストを出力

fpm run --example --list

target指定したexampleだけを実行する

fpm run --example XXX

install

fpmプロジェクトにincldeディレクトリとlibディレクトリを作成。それぞれに.modファイル、.aファイルを作成。(prefixで位置を変更可能)

fpm install --prefix .

fpm.tomlの書き方

デフォルト

fpm.toml
name = "sample"
version = "0.1.0"
license = "license"
author = "Jane Doe"
maintainer = "jane.doe@example.com"
copyright = "Copyright 2021, Jane Doe"
[build]
auto-executables = true
auto-tests = true
auto-examples = true
module-naming = false
[install]
library = false
[fortran]
implicit-typing = false
implicit-external = false
source-form = "free"
[build]
auto-executables = true
auto-tests = true
auto-examples = true

trueならapp,test,exampleからメインルーチンを探す。(基本動作)

app,test,exampleフォルダに入っているメインルーチンのプログラムはファイルがそのまま実行ファイル名になるが、実行ファイル名を変更したい、指定外のフォルダ名に入っている、依存する外部プログラムがある場合は個別に指定することが可能である。

[[executable]]
name = "app-name"
source-dir = "prog"
main = "program.f90"

[[executable]]
name = "app-tool"
link = "z"
[executable.dependencies]
helloff = { git = "https://gitlab.com/everythingfunctional/helloff.git" }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?