mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 08:10:10 +01:00
Nix: add gtest, cmake: use default var to control tests
This commit is contained in:
parent
4d24b12a01
commit
c4757e57e5
2 changed files with 41 additions and 31 deletions
|
|
@ -53,9 +53,7 @@ set_target_properties(hyprutils PROPERTIES VERSION ${hyprutils_VERSION}
|
||||||
SOVERSION 9)
|
SOVERSION 9)
|
||||||
target_link_libraries(hyprutils PkgConfig::deps)
|
target_link_libraries(hyprutils PkgConfig::deps)
|
||||||
|
|
||||||
if (NOT DISABLE_TESTS)
|
if(BUILD_TESTING)
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
# GTest
|
# GTest
|
||||||
find_package(GTest CONFIG REQUIRED)
|
find_package(GTest CONFIG REQUIRED)
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|
@ -63,8 +61,12 @@ if (NOT DISABLE_TESTS)
|
||||||
target_compile_definitions(hyprutils_inline_tests PRIVATE HU_UNIT_TESTS=1)
|
target_compile_definitions(hyprutils_inline_tests PRIVATE HU_UNIT_TESTS=1)
|
||||||
target_compile_options(hyprutils_inline_tests PRIVATE --coverage)
|
target_compile_options(hyprutils_inline_tests PRIVATE --coverage)
|
||||||
target_link_options(hyprutils_inline_tests PRIVATE --coverage)
|
target_link_options(hyprutils_inline_tests PRIVATE --coverage)
|
||||||
target_include_directories(hyprutils_inline_tests PUBLIC "./include" PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")
|
target_include_directories(
|
||||||
target_link_libraries(hyprutils_inline_tests PRIVATE GTest::gtest_main PkgConfig::deps)
|
hyprutils_inline_tests
|
||||||
|
PUBLIC "./include"
|
||||||
|
PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")
|
||||||
|
target_link_libraries(hyprutils_inline_tests PRIVATE GTest::gtest_main
|
||||||
|
PkgConfig::deps)
|
||||||
gtest_discover_tests(hyprutils_inline_tests)
|
gtest_discover_tests(hyprutils_inline_tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
stdenvAdapters,
|
stdenvAdapters,
|
||||||
cmake,
|
cmake,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
|
gtest,
|
||||||
pixman,
|
pixman,
|
||||||
version ? "git",
|
version ? "git",
|
||||||
doCheck ? false,
|
doCheck ? false,
|
||||||
|
|
@ -11,10 +12,12 @@
|
||||||
# whether to use the mold linker
|
# whether to use the mold linker
|
||||||
# disable this for older machines without SSE4_2 and AVX2 support
|
# disable this for older machines without SSE4_2 and AVX2 support
|
||||||
withMold ? true,
|
withMold ? true,
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
inherit (builtins) foldl';
|
inherit (builtins) foldl';
|
||||||
inherit (lib.lists) flatten;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.lists) flatten optional;
|
||||||
|
inherit (lib.strings) cmakeBool optionalString;
|
||||||
|
|
||||||
adapters = flatten [
|
adapters = flatten [
|
||||||
(lib.optional withMold stdenvAdapters.useMoldLinker)
|
(lib.optional withMold stdenvAdapters.useMoldLinker)
|
||||||
|
|
@ -23,31 +26,36 @@
|
||||||
|
|
||||||
customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
|
customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
|
||||||
in
|
in
|
||||||
customStdenv.mkDerivation {
|
customStdenv.mkDerivation {
|
||||||
pname = "hyprutils" + optionalString debug "-debug";
|
pname = "hyprutils" + optionalString debug "-debug";
|
||||||
inherit version doCheck;
|
inherit version doCheck;
|
||||||
src = ../.;
|
src = ../.;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
pkg-config
|
pkg-config
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = flatten [
|
||||||
pixman
|
(optional doCheck gtest)
|
||||||
];
|
pixman
|
||||||
|
];
|
||||||
|
|
||||||
outputs = ["out" "dev"];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
cmakeBuildType =
|
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
|
||||||
if debug
|
|
||||||
then "Debug"
|
|
||||||
else "RelWithDebInfo";
|
|
||||||
|
|
||||||
meta = with lib; {
|
cmakeFlags = mapAttrsToList cmakeBool {
|
||||||
homepage = "https://github.com/hyprwm/hyprutils";
|
"DISABLE_TESTING" = !doCheck;
|
||||||
description = "Small C++ library for utilities used across the Hypr* ecosystem";
|
};
|
||||||
license = licenses.bsd3;
|
|
||||||
platforms = platforms.linux;
|
meta = with lib; {
|
||||||
};
|
homepage = "https://github.com/hyprwm/hyprutils";
|
||||||
}
|
description = "Small C++ library for utilities used across the Hypr* ecosystem";
|
||||||
|
license = licenses.bsd3;
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue