A header only C++20 library. One seed colour gives a complete Material 3 style scheme, light or dark, with the tones, roles and contrast guarantees of the baseline scheme, computed in OKLCH as a light weight stand in for HCT. The seed colour and the light or dark preference come from a chain of sources: an environment override, the XDG desktop portal (GNOME 47+ and KDE Plasma 6), kdeglobals on KDE, gsettings on GNOME, GTK settings, and a fallback that is always appended and cannot be left out. Desktop specific sources are only asked on their own desktop, so a stale gsettings value on KDE never wins. Programs can put sources of their own in front. The tests run without a desktop through a fake Context. They cover colour conversions, tone accuracy, the contrast of every role pair over 300 random seeds in both modes, every parser against real portal output, the order of the sources per desktop, the fallback and external program timeouts. The test suite was checked by breaking the code 22 ways, all are caught. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
29 lines
1.2 KiB
CMake
29 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(libmonet VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
# Header only: nothing to build, nothing to link, only the include directory.
|
|
add_library(monet INTERFACE)
|
|
add_library(monet::monet ALIAS monet)
|
|
target_include_directories(monet INTERFACE
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>)
|
|
target_compile_features(monet INTERFACE cxx_std_20)
|
|
|
|
option(MONET_BUILD_TESTS "Build the tests" ${PROJECT_IS_TOP_LEVEL})
|
|
if(MONET_BUILD_TESTS)
|
|
enable_testing()
|
|
add_executable(monet_tests tests/test_monet.cpp)
|
|
target_link_libraries(monet_tests PRIVATE monet)
|
|
target_compile_options(monet_tests PRIVATE -Wall -Wextra -Wshadow)
|
|
add_test(NAME monet COMMAND monet_tests)
|
|
endif()
|
|
|
|
if(PROJECT_IS_TOP_LEVEL)
|
|
install(DIRECTORY include/ DESTINATION include)
|
|
install(TARGETS monet EXPORT monetTargets)
|
|
install(EXPORT monetTargets NAMESPACE monet:: DESTINATION lib/cmake/monet)
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/monetConfig.cmake
|
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/monetTargets.cmake\")\n")
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/monetConfig.cmake DESTINATION lib/cmake/monet)
|
|
endif()
|