A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://uxlfoundation.github.io/oneMath/using_onemath_with_cmake.html below:

Using oneMath in your project with CMake — oneMath 0.1 documentation

Using oneMath in your project with CMake#

The CMake build tool can help you use oneMath in your own project. Instead of manually linking and including directories, you can use the CMake targets exported by the oneMath project. You can use oneMath in one of two forms, with the target names depending on the approach taken:

Using an installed oneMath#

If oneMath has been previously installed, either by building from source or as a distributed binary, they can be consumed using CMake using find_package(oneMath REQUIRED). The compiler used for the target library or application should match that used to build oneMath.

For example:

find_package(oneMath REQUIRED)
target_link_libraries(myTarget PRIVATE ONEMATH::onemath)

Different targets can be used depending on the requirements of oneMath. To link against the entire library with run-time dispatching, the ONEMATH::onemath target should be used. For specific backends with compile-time dispatching, ONEMATH::onemath_<domain>_<backend> should be used.

When using a binary, it may be useful to know the backends that were enabled during the build. To check for the existence of backends, CMake’s if(TARGET <target>) construct can be used. For example, with the cufft backend:

if(TARGET ONEMATH::onemath_dft_cufft)
    target_link_libraries(myTarget PRIVATE ONEMATH::onemath_dft_cufft)
else()
    message(FATAL_ERROR "oneMath was not built with CuFFT backend")
endif()
Using CMake’s FetchContent#

The FetchContent functionality of CMake can be used to download, build and install oneMath as part of the build.

For example:

include(FetchContent)
set(BUILD_FUNCTIONAL_TESTS False)
set(BUILD_EXAMPLES False)
set(ENABLE_<BACKEND_NAME>_BACKEND True)
FetchContent_Declare(
        onemath_library
        GIT_REPOSITORY https://github.com/uxlfoundation/oneMath.git
        GIT_TAG develop
)
FetchContent_MakeAvailable(onemath_library)

target_link_libraries(myTarget PRIVATE onemath)

The build parameters should be appropriately set before FetchContent_Declare. See Building the Project with DPC++ or Building the Project with AdaptiveCpp.

To link against the main library with run-time dispatching, use the target onemath. To link against particular backends with compile-time dispatching, use the target onemath_<domain>_<backend>. For example, onemath_dft_cufft.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4