👷 fix compilation

This commit is contained in:
Vladislav Nepogodin 2022-06-06 00:36:15 +04:00
parent 8c8dc17cb7
commit 1c923cdbc9
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
6 changed files with 40 additions and 36 deletions

View File

@ -59,14 +59,12 @@ CPMAddPackage(
GIT_TAG 2157a3126c2ef1b76f339dedd6d7585e39651512
EXCLUDE_FROM_ALL YES
)
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
CPMAddPackage(
NAME range-v3
GITHUB_REPOSITORY ericniebler/range-v3
GIT_TAG 0fa54d7de5dc00655e38a08e87cda61f7aa6d5b9
EXCLUDE_FROM_ALL YES
)
endif()
CPMAddPackage(
NAME range-v3
GITHUB_REPOSITORY ericniebler/range-v3
GIT_TAG 0fa54d7de5dc00655e38a08e87cda61f7aa6d5b9
EXCLUDE_FROM_ALL YES
)
##
## CONFIGURATION
@ -134,15 +132,10 @@ enable_sanitizers(project_options)
include_directories(${CMAKE_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options spdlog::spdlog fmt::fmt ftxui::screen ftxui::dom ftxui::component cpr::cpr)#simdjson::simdjson)
target_link_libraries(test-exec-interactive PRIVATE project_warnings project_options spdlog::spdlog fmt::fmt ftxui::component cpr::cpr)#simdjson::simdjson)
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options spdlog::spdlog fmt::fmt ftxui::screen ftxui::dom ftxui::component cpr::cpr range-v3::range-v3)#simdjson::simdjson)
target_link_libraries(test-exec-interactive PRIVATE project_warnings project_options spdlog::spdlog fmt::fmt ftxui::component cpr::cpr range-v3::range-v3)#simdjson::simdjson)
target_link_libraries(test-process-tailing PRIVATE project_warnings project_options spdlog::spdlog fmt::fmt ftxui::component cpr::cpr)#simdjson::simdjson)
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
target_link_libraries(${PROJECT_NAME} PRIVATE range-v3::range-v3)
target_link_libraries(test-exec-interactive PRIVATE range-v3::range-v3)
endif()
option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
if(ENABLE_UNITY)
# Add for any project you want to apply unity builds for

View File

@ -59,7 +59,7 @@ function(set_project_warnings project_name)
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
-Wuseless-cast # warn if you perform a cast to the same type
-Wsuggest-attribute=cold
#-Wsuggest-attribute=cold
#-Wsuggest-attribute=format
-Wsuggest-attribute=malloc
-Wsuggest-attribute=noreturn

View File

@ -14,6 +14,8 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"RelWithDebInfo")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)

View File

@ -38,6 +38,7 @@ fmt = dependency('fmt', version : ['>=8.0.0'], fallback : ['fmt', 'fmt_dep'])
ftxui = dependency('ftxui', modules : ['ftxui::screen', 'ftxui::dom', 'ftxui::component'], fallback : ['ftxui', 'ftxui_dep'])
simdjson = dependency('simdjson', version : ['>=1.0.2'], fallback : ['simdjson', 'simdjson_dep'])
cpr = dependency('cpr', version : ['>=1.7.0'], fallback : ['cpr', 'cpr_dep'])
ranges = dependency('range-v3', version : ['>=0.11.0'])
#glibmm = dependency('glibmm-2.4', version : ['>=2.56.0'])
src_files = files(
@ -84,8 +85,9 @@ if cc.get_id() == 'gcc'
'-Wduplicated-branches',
'-Wlogical-op',
'-Wuseless-cast',
'-Wno-restrict',
'-Wsuggest-attribute=cold',
#'-Wsuggest-attribute=cold',
#'-Wsuggest-attribute=format',
'-Wsuggest-attribute=malloc',
'-Wsuggest-attribute=noreturn',
@ -120,11 +122,7 @@ endif
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'cpp')
deps = [fmt, spdlog, ftxui, cpr]
if cc.get_id() == 'clang'
ranges = dependency('range-v3', version : ['>=0.11.0'])
deps += [ranges]
endif
deps = [fmt, spdlog, ftxui, cpr, ranges]
executable(
'cachyos-installer',

View File

@ -11,6 +11,7 @@
/* clang-format off */
#include <sys/mount.h> // for mount
#include <fstream> // for ofstream
#include <algorithm> // for copy
#include <filesystem> // for exists, is_directory
#include <string> // for basic_string
#include <ftxui/component/component.hpp> // for Renderer, Button
@ -24,14 +25,19 @@ namespace fs = std::filesystem;
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
#include <range/v3/algorithm/any_of.hpp>
#include <range/v3/algorithm/copy.hpp>
#include <range/v3/algorithm/search.hpp>
#if defined(__clang__)
#pragma clang diagnostic pop
#else
namespace ranges = std::ranges;
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#ifdef NDEVENV
@ -1644,7 +1650,7 @@ void make_swap() noexcept {
}
const auto& partitions = std::get<std::vector<std::string>>(config_data["PARTITIONS"]);
temp.reserve(partitions.size());
ranges::copy(partitions, std::back_inserter(temp));
std::copy(partitions.begin(), partitions.end(), std::back_inserter(temp));
auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{};
@ -1851,7 +1857,6 @@ bool zfs_create_zpool() noexcept {
if (!success) { return false; }
/* clang-format on */
}
const auto& partition = std::get<std::string>(config_data["PARTITION"]);
static constexpr auto zfs_zpool_body = "\nEnter the name for the new zpool\n";
static constexpr auto zfs_zpoolcvalidation1 = "\nzpool names must start with a letter and are limited to only alphanumeric characters and the special characters : . - _\n";
@ -1885,10 +1890,11 @@ bool zfs_create_zpool() noexcept {
}
config_data["ZFS_ZPOOL_NAME"] = zfs_zpool_name;
// Find the UUID of the partition
const auto& partuuid = utils::exec(fmt::format(FMT_COMPILE("lsblk -lno PATH,PARTUUID | grep \"^{}\" | {}"), partition, "awk '{print $2}'"), false);
#ifdef NDEVENV
// Find the UUID of the partition
const auto& partition = std::get<std::string>(config_data["PARTITION"]);
const auto& partuuid = utils::exec(fmt::format(FMT_COMPILE("lsblk -lno PATH,PARTUUID | grep \"^{}\" | {}"), partition, "awk '{print $2}'"), false);
// See if the partition has a partuuid, if not use the device name
if (!partuuid.empty()) {
utils::exec(fmt::format(FMT_COMPILE("zpool create -m none {} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_name, partuuid), true);
@ -1908,7 +1914,7 @@ bool zfs_create_zpool() noexcept {
utils::exec(fmt::format(FMT_COMPILE("zpool import -R {} {} 2>>/tmp/cachyos-install.log"), mountpoint, zfs_zpool_name), true);
#endif
return false;
return true;
}
// Automated configuration of zfs. Creates a new zpool and a default set of filesystems
@ -2248,7 +2254,7 @@ void mount_partitions() noexcept {
const auto& partitions = std::get<std::vector<std::string>>(config_data["PARTITIONS"]);
std::vector<std::string> temp{"Done -"};
temp.reserve(partitions.size());
ranges::copy(partitions, std::back_inserter(temp));
std::copy(partitions.begin(), partitions.end(), std::back_inserter(temp));
auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{};
@ -2552,7 +2558,7 @@ void prep_menu() noexcept {
"RAID (optional)",
"Logical Volume Management (optional)",
"LUKS Encryption (optional)",
"ZFS (optional)"
"ZFS (optional)",
"Mount Partitions",
"Configure Installer Mirrorlist",
"Refresh Pacman Keys",

View File

@ -26,6 +26,11 @@
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
#include <range/v3/algorithm/for_each.hpp>
#include <range/v3/algorithm/reverse.hpp>
@ -34,10 +39,10 @@
#include <range/v3/view/split.hpp>
#include <range/v3/view/transform.hpp>
#if defined(__clang__)
#pragma clang diagnostic pop
#else
#include <ranges>
namespace ranges = std::ranges;
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#ifdef NDEVENV