Revert cmake reformat

This commit is contained in:
SM9CC 2021-12-01 04:20:39 +00:00
parent db972aaca7
commit 5f84f11de8
No known key found for this signature in database
GPG Key ID: 497769F3F5AD3A35
5 changed files with 147 additions and 147 deletions

View File

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

View File

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

View File

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

View File

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

View File

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