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)
|
||||
target_link_libraries(hyprutils PkgConfig::deps)
|
||||
|
||||
if (NOT DISABLE_TESTS)
|
||||
enable_testing()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
# GTest
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
include(GoogleTest)
|
||||
|
|
@ -63,8 +61,12 @@ if (NOT DISABLE_TESTS)
|
|||
target_compile_definitions(hyprutils_inline_tests PRIVATE HU_UNIT_TESTS=1)
|
||||
target_compile_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_link_libraries(hyprutils_inline_tests PRIVATE GTest::gtest_main PkgConfig::deps)
|
||||
target_include_directories(
|
||||
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)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
stdenvAdapters,
|
||||
cmake,
|
||||
pkg-config,
|
||||
gtest,
|
||||
pixman,
|
||||
version ? "git",
|
||||
doCheck ? false,
|
||||
|
|
@ -11,10 +12,12 @@
|
|||
# whether to use the mold linker
|
||||
# disable this for older machines without SSE4_2 and AVX2 support
|
||||
withMold ? true,
|
||||
}: let
|
||||
}:
|
||||
let
|
||||
inherit (builtins) foldl';
|
||||
inherit (lib.lists) flatten;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.lists) flatten optional;
|
||||
inherit (lib.strings) cmakeBool optionalString;
|
||||
|
||||
adapters = flatten [
|
||||
(lib.optional withMold stdenvAdapters.useMoldLinker)
|
||||
|
|
@ -23,7 +26,7 @@
|
|||
|
||||
customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
|
||||
in
|
||||
customStdenv.mkDerivation {
|
||||
customStdenv.mkDerivation {
|
||||
pname = "hyprutils" + optionalString debug "-debug";
|
||||
inherit version doCheck;
|
||||
src = ../.;
|
||||
|
|
@ -33,16 +36,21 @@ in
|
|||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
buildInputs = flatten [
|
||||
(optional doCheck gtest)
|
||||
pixman
|
||||
];
|
||||
|
||||
outputs = ["out" "dev"];
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
];
|
||||
|
||||
cmakeBuildType =
|
||||
if debug
|
||||
then "Debug"
|
||||
else "RelWithDebInfo";
|
||||
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
|
||||
|
||||
cmakeFlags = mapAttrsToList cmakeBool {
|
||||
"DISABLE_TESTING" = !doCheck;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/hyprwm/hyprutils";
|
||||
|
|
@ -50,4 +58,4 @@ in
|
|||
license = licenses.bsd3;
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue