This commit is contained in:
SM9CC 2021-12-01 01:31:37 +00:00
parent 4d8f1a08e0
commit 98e9c570d7
No known key found for this signature in database
GPG Key ID: 497769F3F5AD3A35
6 changed files with 148 additions and 148 deletions

View File

@ -7,8 +7,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
## name and version
##
project(cachyos-installer
VERSION 0.0.1
LANGUAGES CXX)
VERSION 0.0.1
LANGUAGES CXX)
##
## INCLUDE
@ -21,27 +21,27 @@ include(ClangTidy)
include(FetchContent)
FetchContent_Declare(ftxui
GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git"
GIT_TAG "cecd54df42dd66fdf8386ed461e16b725bffc827"
)
GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git"
GIT_TAG "cecd54df42dd66fdf8386ed461e16b725bffc827"
)
FetchContent_MakeAvailable(ftxui)
FetchContent_Declare(fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG "491ba2dda5a04c2438abb6bd90219de773793ec0"
)
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG "491ba2dda5a04c2438abb6bd90219de773793ec0"
)
FetchContent_MakeAvailable(fmt)
FetchContent_Declare(nlohmann_json
GIT_REPOSITORY "https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent.git"
GIT_TAG "v3.10.4"
)
GIT_REPOSITORY "https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent.git"
GIT_TAG "v3.10.4"
)
FetchContent_MakeAvailable(nlohmann_json)
FetchContent_Declare(cpr
GIT_REPOSITORY "https://github.com/vnepogodin/cpr.git"
GIT_TAG "824358455f61629ca43422adce0243bb05e99bf8"
)
GIT_REPOSITORY "https://github.com/vnepogodin/cpr.git"
GIT_TAG "824358455f61629ca43422adce0243bb05e99bf8"
)
FetchContent_MakeAvailable(cpr)
##
@ -49,9 +49,9 @@ FetchContent_MakeAvailable(cpr)
##
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program")
endif ()
# Link this 'library' to set the c++ standard / compile-time options requested
add_library(project_options INTERFACE)
@ -61,12 +61,12 @@ target_compile_features(project_options INTERFACE cxx_std_20)
## Target
##
add_executable(${PROJECT_NAME}
src/definitions.hpp
src/config.cpp src/config.hpp
src/utils.cpp src/utils.hpp
src/tui.cpp src/tui.hpp
src/main.cpp
)
src/definitions.hpp
src/config.cpp src/config.hpp
src/utils.cpp src/utils.hpp
src/tui.cpp src/tui.hpp
src/main.cpp
)
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
@ -77,12 +77,12 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options fmt::fmt ftxui::screen ftxui::dom ftxui::component nlohmann_json::nlohmann_json cpr::cpr)
option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
if(ENABLE_UNITY)
# Add for any project you want to apply unity builds for
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
endif()
if (ENABLE_UNITY)
# Add for any project you want to apply unity builds for
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
endif ()
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@ -1,15 +1,15 @@
option(ENABLE_TIDY "Enable clang-tidy [default: OFF]" OFF)
if(ENABLE_TIDY)
find_program(CLANG_TIDY_EXE
NAMES clang-tidy-9 clang-tidy-8 clang-tidy-7 clang-tidy
DOC "Path to clang-tidy executable")
if(NOT CLANG_TIDY_EXE)
message(STATUS "[clang-tidy] Not found.")
else()
message(STATUS "[clang-tidy] found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()
else()
message(STATUS "[clang-tidy] Disabled.")
endif()
if (ENABLE_TIDY)
find_program(CLANG_TIDY_EXE
NAMES clang-tidy-9 clang-tidy-8 clang-tidy-7 clang-tidy
DOC "Path to clang-tidy executable")
if (NOT CLANG_TIDY_EXE)
message(STATUS "[clang-tidy] Not found.")
else ()
message(STATUS "[clang-tidy] found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif ()
else ()
message(STATUS "[clang-tidy] Disabled.")
endif ()

View File

@ -1,76 +1,76 @@
function(set_project_warnings project_name)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as error" ON)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as error" ON)
set(MSVC_WARNINGS
/W4 # Base
/w14242 # Conversion
/w14254 # Operator convers.
/w14263 # Func member doesn't override
/w14265 # class has vfuncs, but destructor is not
/w14287 # unsigned/negative constant mismatch
/we4289 # nonstandard extension used: loop control var
/w14296 # expression is always 'boolean_value'
/w14311 # pointer trunc from one tipe to another
/w14545 # expression before comma evaluates to a function which missign an argument list
set(MSVC_WARNINGS
/W4 # Base
/w14242 # Conversion
/w14254 # Operator convers.
/w14263 # Func member doesn't override
/w14265 # class has vfuncs, but destructor is not
/w14287 # unsigned/negative constant mismatch
/we4289 # nonstandard extension used: loop control var
/w14296 # expression is always 'boolean_value'
/w14311 # pointer trunc from one tipe to another
/w14545 # expression before comma evaluates to a function which missign an argument list
/w14546 # function call before comma missing argument list
/w14547 # operator before comma has no effect; expected operator with side-effect
/w14549 # operator before comma has no effect; did you intend operator?
/w14546 # function call before comma missing argument list
/w14547 # operator before comma has no effect; expected operator with side-effect
/w14549 # operator before comma has no effect; did you intend operator?
/w14555 # expresion has no effect; expected expression with side-effect
/w14619 # pragma warning
/w14640 # Enable warning on thread; static member
/w14555 # expresion has no effect; expected expression with side-effect
/w14619 # pragma warning
/w14640 # Enable warning on thread; static member
/w14826 # Conversion from one tipe to another is sign-extended cause unexpected runtime behavior.
/w14928 # illegal copy-initialization; more than user-defined.
/X
/constexpr
)
/w14826 # Conversion from one tipe to another is sign-extended cause unexpected runtime behavior.
/w14928 # illegal copy-initialization; more than user-defined.
/X
/constexpr
)
set(CLANG_WARNINGS
-Wall
-Wextra # standard
-Wshadow
set(CLANG_WARNINGS
-Wall
-Wextra # standard
-Wshadow
-Wnon-virtual-dtor
-Wnon-virtual-dtor
-Wold-style-cast # c-style cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wold-style-cast # c-style cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wpedantic # non-standard C++
-Wconversion # type conversion that may lose data
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion # float to double
-Wpedantic # non-standard C++
-Wconversion # type conversion that may lose data
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion # float to double
-Wformat=2
)
-Wformat=2
)
if(WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif()
if (WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif ()
set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation
set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation
-Wduplicated-cond
-Wduplicated-branches
-Wlogical-op
-Wduplicated-cond
-Wduplicated-branches
-Wlogical-op
-Wuseless-cast
)
-Wuseless-cast
)
if(MSVC)
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(PROJECT_WARNINGS ${CLANG_WARNINGS})
else()
set(PROJECT_WARNINGS ${GCC_WARNINGS})
endif()
if (MSVC)
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(PROJECT_WARNINGS ${CLANG_WARNINGS})
else ()
set(PROJECT_WARNINGS ${GCC_WARNINGS})
endif ()
target_compile_options(${project_name} INTERFACE ${PROJECT_WARNINGS})
target_compile_options(${project_name} INTERFACE ${PROJECT_WARNINGS})
endfunction()

View File

@ -2,12 +2,12 @@
#
# The ccache is auto-enabled if the tool is found.
# To disable set -DCCACHE=OFF option.
if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
find_program(CCACHE ccache DOC "ccache tool path; set to OFF to disable")
if(CCACHE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
message(STATUS "[ccache] Enabled: ${CCACHE}")
else()
message(STATUS "[ccache] Disabled.")
endif()
endif()
if (NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
find_program(CCACHE ccache DOC "ccache tool path; set to OFF to disable")
if (CCACHE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
message(STATUS "[ccache] Enabled: ${CCACHE}")
else ()
message(STATUS "[ccache] Disabled.")
endif ()
endif ()

View File

@ -1,46 +1,46 @@
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui, ccmake
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo")
endif()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui, ccmake
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo")
endif ()
# Generate compile_commands.json to make it easier to work with clang based tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(ENABLE_IPO "Enable Interprocedural Optimization, aka Link Time Optimization (LTO)" OFF)
if(ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(
RESULT
result
OUTPUT
output)
if(result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else()
message(SEND_ERROR "IPO is not supported: ${output}")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
add_compile_options(-fcolor-diagnostics)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
else()
message(STATUS "No colored compiler diagnostic set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()
if (ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(
RESULT
result
OUTPUT
output)
if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else ()
message(SEND_ERROR "IPO is not supported: ${output}")
endif ()
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
add_compile_options(-fcolor-diagnostics)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
else ()
message(STATUS "No colored compiler diagnostic set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif ()
# Enables STL container checker if not building a release.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_GLIBCXX_ASSERTIONS)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_GLIBCXX_ASSERTIONS)
endif ()

View File

@ -11,8 +11,8 @@
#include <cpr/api.h>
#include <cpr/response.h>
#include <cpr/timeout.h>
#include <cpr/status_codes.h>
#include <cpr/timeout.h>
namespace fs = std::filesystem;