Some checks failed
CI / lint (push) Successful in 1m37s
CI / test-python (push) Successful in 1m49s
CI / test-zig (push) Successful in 1m39s
CI / test-wasm (push) Successful in 1m54s
CI / test (push) Successful in 14m44s
CI / miri (push) Successful in 14m18s
CI / build (push) Successful in 1m9s
CI / fuzz-regression (push) Successful in 9m9s
CI / publish (push) Failing after 1m10s
CI / publish-python (push) Failing after 1m46s
CI / publish-wasm (push) Has been cancelled
Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
63 lines
1.8 KiB
CMake
63 lines
1.8 KiB
CMake
# Soliton CMake config — find_package(Soliton) support.
|
|
#
|
|
# Provides:
|
|
# Soliton::Soliton — imported target (static or shared, depending on what's installed)
|
|
# Soliton_FOUND — TRUE if found
|
|
# Soliton_INCLUDE_DIR — path to soliton.h
|
|
# Soliton_LIBRARY — path to libsoliton.a or libsoliton.so
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_path(Soliton_INCLUDE_DIR
|
|
NAMES soliton.h
|
|
HINTS
|
|
${CMAKE_INSTALL_PREFIX}/include
|
|
/usr/local/include
|
|
/usr/include
|
|
)
|
|
|
|
# Prefer static, fall back to shared.
|
|
find_library(Soliton_LIBRARY
|
|
NAMES soliton
|
|
HINTS
|
|
${CMAKE_INSTALL_PREFIX}/lib
|
|
/usr/local/lib
|
|
/usr/lib
|
|
)
|
|
|
|
find_package_handle_standard_args(Soliton
|
|
REQUIRED_VARS Soliton_LIBRARY Soliton_INCLUDE_DIR
|
|
)
|
|
|
|
if(Soliton_FOUND AND NOT TARGET Soliton::Soliton)
|
|
# Detect whether the found library is static (.a) or shared (.so/.dylib).
|
|
get_filename_component(_sol_ext "${Soliton_LIBRARY}" EXT)
|
|
if(_sol_ext STREQUAL ".a" OR _sol_ext STREQUAL ".lib")
|
|
set(_sol_type STATIC)
|
|
else()
|
|
set(_sol_type SHARED)
|
|
endif()
|
|
|
|
add_library(Soliton::Soliton ${_sol_type} IMPORTED)
|
|
set_target_properties(Soliton::Soliton PROPERTIES
|
|
IMPORTED_LOCATION "${Soliton_LIBRARY}"
|
|
INTERFACE_INCLUDE_DIRECTORIES "${Soliton_INCLUDE_DIR}"
|
|
)
|
|
|
|
# Static linking needs these system libs.
|
|
if(_sol_type STREQUAL "STATIC")
|
|
if(UNIX AND NOT APPLE)
|
|
set_property(TARGET Soliton::Soliton APPEND PROPERTY
|
|
INTERFACE_LINK_LIBRARIES m dl pthread)
|
|
elseif(APPLE)
|
|
set_property(TARGET Soliton::Soliton APPEND PROPERTY
|
|
INTERFACE_LINK_LIBRARIES m dl pthread "-framework Security")
|
|
elseif(WIN32)
|
|
set_property(TARGET Soliton::Soliton APPEND PROPERTY
|
|
INTERFACE_LINK_LIBRARIES ws2_32 userenv bcrypt ntdll)
|
|
endif()
|
|
endif()
|
|
|
|
unset(_sol_type)
|
|
unset(_sol_ext)
|
|
endif()
|