From d00c0c1b1503ebe8267cb044a666413634761fee Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 28 Jun 2024 23:52:58 +0900 Subject: [PATCH] doc: explain a macro to link pre-built lib --- README.md | 10 +++++++++- README_ja.md | 10 +++++++++- docs/content.en/docs/installation/_index.md | 8 ++++++++ docs/content.ja/docs/installation/_index.md | 8 ++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9e3afb..ed72f14 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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`. diff --git a/README_ja.md b/README_ja.md index 2c98aca..5af24f2 100644 --- a/README_ja.md +++ b/README_ja.md @@ -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言語標準のテストケースすべてにパスしています。 @@ -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/`をコンパイルできます。 diff --git a/docs/content.en/docs/installation/_index.md b/docs/content.en/docs/installation/_index.md index 462879a..d20be76 100644 --- a/docs/content.en/docs/installation/_index.md +++ b/docs/content.en/docs/installation/_index.md @@ -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. diff --git a/docs/content.ja/docs/installation/_index.md b/docs/content.ja/docs/installation/_index.md index a67be0f..1b326cc 100644 --- a/docs/content.ja/docs/installation/_index.md +++ b/docs/content.ja/docs/installation/_index.md @@ -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`によって必要なバージョンを設定してコンパイルしてください。