Skip to content

Commit

Permalink
doc: explain a macro to link pre-built lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ToruNiina committed Jun 28, 2024
1 parent 5d23f4b commit d00c0c1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[日本語版](https://github.com/ToruNiina/toml11/blob/main/README_ja.md)

toml11 is a feature-rich TOML language library for C++.
toml11 is a feature-rich TOML language library for C++11/14/17/20.

- It complies with [the latest TOML language specification](https://toml.io/en/v1.0.0).
- It passes all the standard TOML language [test cases](https://github.com/toml-lang/toml-test).
Expand Down Expand Up @@ -124,6 +124,14 @@ $ cmake -B ./build/ -DTOML11_PRECOMPILE=ON -DCMAKE_CXX_STANDARD=11/14/17/20
$ cmake --build ./build/
```

When linking the library, use `target_link_libraries` in CMake

```cmake
target_link_libraries(your_target PUBLIC toml11::toml11)
```

or pass `-DTOML11_COMPILE_SOURCES` to the compiler.

### Building Example

To compile the examples in the `examples/` directory, set `-DTOML11_BUILD_EXAMPLES=ON`.
Expand Down
10 changes: 9 additions & 1 deletion README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![License](https://img.shields.io/github/license/ToruNiina/toml11.svg?style=flat)](LICENSE)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1209136.svg)](https://doi.org/10.5281/zenodo.1209136)

toml11は、C++のための豊富な機能を持つTOML言語ライブラリです
toml11は、C++11,14,17,20のための豊富な機能を持つTOML言語ライブラリです

- [TOML言語の最新規格](https://toml.io/ja/v1.0.0)に準拠しています。
- TOML言語標準のテストケースすべてにパスしています。
Expand Down Expand Up @@ -122,6 +122,14 @@ $ cmake -B ./build/ -DTOML11_PRECOMPILE=ON -DCMAKE_CXX_STANDARD=11/14/17/20
$ cmake --build ./build/
```

ライブラリをリンクする場合は、CMakeで

```cmake
target_link_libraries(your_target PUBLIC toml11::toml11)
```

とするか、コンパイラに`-DTOML11_COMPILE_SOURCES`を渡してください。

### Building example

`-DTOML11_BUILD_EXAMPLES=ON`とすることで、`examples/`をコンパイルできます。
Expand Down
8 changes: 8 additions & 0 deletions docs/content.en/docs/installation/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ By defining `-DTOML11_PRECOMPILE=ON` when running cmake, you can precompile some
$ cmake -B ./build/ -DTOML11_PRECOMPILE=ON
```

When linking the library, use `target_link_libraries` in CMake

```cmake
target_link_libraries(your_target PUBLIC toml11::toml11)
```

or pass `-DTOML11_COMPILE_SOURCES` to the compiler to suppress header-only features.

However, since toml11 supports multiple C++ versions and may switch types based on the value of `__cplusplus`,
there is a possibility of link failures if the version used during build differs from the version used during usage.
If you encounter issues, set the required version using `CMAKE_CXX_STANDARD` during compilation.
Expand Down
8 changes: 8 additions & 0 deletions docs/content.ja/docs/installation/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ target_link_libraries(main PRIVATE toml11::toml11)
$ cmake -B ./build/ -DTOML11_PRECOMPILE=ON
```

ライブラリをリンクする場合は、CMakeで

```cmake
target_link_libraries(your_target PUBLIC toml11::toml11)
```

とするか、ヘッダ内の関数の`inline`化を避けるためにコンパイラに`-DTOML11_COMPILE_SOURCES`を渡してください。

ただし、toml11は複数のC++バージョンに対応するため、`__cplusplus`の値などによって型を切り替えることがあります。
そのため、ビルドした際のバージョンと使用時のバージョンが異なる場合、リンクに失敗する可能性があります。
問題が生じた場合は`CMAKE_CXX_STANDARD`によって必要なバージョンを設定してコンパイルしてください。
Expand Down

0 comments on commit d00c0c1

Please sign in to comment.