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HARED_MODULE_PREFIX)
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
find_package(Boost REQUIRED)
find_package(date REQUIRED)
add_subdirectory(src)
set(Nix_VERSION ${Nix_nix-main_VERSION})
string(REPLACE "." ";" VERSION_LIST ${Nix_VERSION})
list(GET VERSION_LIST 0 Nix_MAJOR_VERSION)
list(GET VERSION_LIST 1 Nix_MINOR_VERSION)
list(GET VERSION_LIST 2 Nix_PATCH_VERSION)
target_compile_definitions(PkgConfig::Nix
INTERFACE
"NIX_MAJOR_VERSION=(${Nix_MAJOR_VERSION})"
"NIX_MINOR_VERSION=(${Nix_MINOR_VERSION})"
"NIX_PATCH_VERSION=(${Nix_PATCH_VERSION})"
add_subdirectory(autotests)
"NIX_VERSION=(((0x${Nix_MAJOR_VERSION})<<16) | ((0x${Nix_MINOR_VERSION})<<8) | (0x${Nix_PATCH_VERSION}))"
SYSTEM="")
target_link_libraries(PkgConfig::Nix
INTERFACE
Boost::headers
date::date
nlohmann_json)
add_compile_options(-Wall -Werror)
pkg_check_modules(Nix REQUIRED IMPORTED_TARGET nix-main nix-store)
find_library(nixfetchers_LIBRARY nixfetchers REQUIRED)
target_link_libraries(PkgConfig::Nix INTERFACE ${nixfetchers_LIBRARY})
find_package(nlohmann_json REQUIRED)
include(CTest)
file(STRINGS VERSION _version)
project(nix-plugin-pijul VERSION ${_version})
add_library(pijul MODULE)
install(TARGETS pijul DESTINATION ${CMAKE_INSTALL_LIBDIR}/nix/plugins)
target_sources(pijul PRIVATE ${SRC})
target_sources(PijulTesting PRIVATE ${SRC})
target_include_directories(PijulTesting PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_compile_options(PijulTesting PUBLIC -O1 -ggdb)
target_link_libraries(PijulTesting PRIVATE date::date)
target_link_libraries(pijul
PUBLIC
PkgConfig::Nix)
fetcher.cpp
repo.cpp
repo.h)
set(SRC
compat.cpp
compat.h
add_library(PijulTesting STATIC)
lib_src = files(
'compat.cpp',
'fetcher.cpp',
'repo.cpp',
)
lib_inc = include_directories('.')
# Nix uses these macros that are only defined in its own build
lib_extra_cppflags = ['-DSYSTEM=""']
if nix_main_dep.version().version_compare('<=2.22')
lib_extra_cppflags += ['-DHAVE_STRUCT_DIRENT_D_TYPE']
endif
lib = shared_module(
'pijul',
lib_src,
dependencies: [
nix_main_dep,
nix_store_dep,
],
cpp_args: [
f'-DNIX_MAJOR_VERSION=(@nix_major_version@)',
f'-DNIX_MINOR_VERSION=(@nix_minor_version@)',
f'-DNIX_PATCH_VERSION=(@nix_patch_version@)',
f'-DNIX_VERSION=(((0x@nix_major_version@)<<16) | ((0x@nix_minor_version@)<<8) | (0x@nix_patch_version@))',
] + lib_extra_cppflags,
include_directories: lib_inc,
install: true,
install_dir: get_option('libdir') / 'nix/plugins',
name_prefix: '',
)
test_lib = static_library(
'testsupport',
lib_src,
include_directories: lib_inc,
)
project(
'nix-plugin-pijul',
'cpp',
license: 'LGPL-3.0',
license_files: ['LICENSE'],
version: configure_file(input: 'VERSION', output: 'VERSION', copy: true),
default_options: {
'cpp_std': 'c++20',
'werror': true,
}
)
nix_main_dep = dependency('nix-main', required: true)
nix_store_dep = dependency('nix-store', required: true)
nix_version_components = nix_main_dep.version().split('.')
nix_major_version = nix_version_components[0]
nix_minor_version = nix_version_components[1]
nix_patch_version = nix_version_components[2]
if nix_patch_version.contains('_')
nix_patch_version = '99'
endif
subdir('src')
subdir('autotests')
add_compile_options(-O1 -ggdb)
add_executable(DateTest datetest.cpp)
target_link_libraries(DateTest PUBLIC PijulTesting)
add_test(NAME DateTest COMMAND DateTest)
add_executable(RepoTest repotest.cpp)
target_link_libraries(RepoTest PUBLIC PijulTesting)
add_test(NAME RepoTest COMMAND RepoTest)
datetest_exe = executable(
'datetest',
['datetest.cpp'],
link_with: [test_lib],
include_directories: [lib_inc],
)
test('date', datetest_exe)
repotest_exe = executable(
'repotest',
['repotest.cpp'],
link_with: [test_lib],
include_directories: [lib_inc],
)
test('repo', repotest_exe)