Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.49 KB

File metadata and controls

53 lines (40 loc) · 1.49 KB

C++20 modules support

Warning

Support for C++20 modules is considered experimental.

Requirements

To compile the library as a C++20 module, you need CMake 3.28.2 or newer, Ninja 1.11 or newer, and one of the following compilers:

  • GCC 15 or newer
  • LLVM/Clang 16.0 or newer (to build static library)
  • LLVM/Clang 19.1 or newer (to build static or shared library)
  • MSVC toolset 14.50 (Visual Studio 2026) or newer

CMake

To compile as a C++20 module, specify UPA_MODULE=ON. For example:

cmake -B build -G Ninja -DUPA_MODULE=ON -DUPA_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build build

Then install:

cmake --install build

Usage

To use library add find_package(upa REQUIRED) and link to upa::url-module target in your CMakeLists.txt:

find_package(upa REQUIRED)
...
target_link_libraries(exe-target PRIVATE upa::url-module)

In the C++ file you need to import upa.url. If you need to include other headers, they must be above the import directive. For example:

#include <iostream>

import upa.url;

int main() {
    upa::url url;

    if (upa::success(url.parse("https://example.com/p/a?q=Q#f")))
        std::cout << url.get_href() << '\n';
    return 0;
}

References: