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

@ -23,25 +23,25 @@ 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)
@ -77,10 +77,10 @@ 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}

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

@ -48,10 +48,10 @@ function(set_project_warnings project_name)
-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}
@ -64,13 +64,13 @@ function(set_project_warnings project_name)
-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,5 +1,5 @@
# 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
@ -12,35 +12,35 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"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()