diff --git a/CMakeLists.txt b/CMakeLists.txt index 5587d12..7c0cfb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 9076c63..0bf53f9 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -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 diff --git a/cmake/StandardProjectSettings.cmake b/cmake/StandardProjectSettings.cmake index 61d2962..243b526 100644 --- a/cmake/StandardProjectSettings.cmake +++ b/cmake/StandardProjectSettings.cmake @@ -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) diff --git a/meson.build b/meson.build index dc7fe12..13e3a2f 100644 --- a/meson.build +++ b/meson.build @@ -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', diff --git a/src/tui.cpp b/src/tui.cpp index 6da82fb..8994edc 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -11,6 +11,7 @@ /* clang-format off */ #include // for mount #include // for ofstream +#include // for copy #include // for exists, is_directory #include // for basic_string #include // 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 -#include #include +#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>(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(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(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>(config_data["PARTITIONS"]); std::vector 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", diff --git a/src/utils.cpp b/src/utils.cpp index d3c336e..615b792 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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 #include @@ -34,10 +39,10 @@ #include #include +#if defined(__clang__) #pragma clang diagnostic pop -#else -#include -namespace ranges = std::ranges; +#elif defined(__GNUC__) +#pragma GCC diagnostic pop #endif #ifdef NDEVENV