Skip to content

Commit

Permalink
fix cmake formatting through fix-format target
Browse files Browse the repository at this point in the history
  • Loading branch information
amolgawai committed Apr 23, 2022
1 parent ffc802a commit 8a6c7f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 48 deletions.
21 changes: 6 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ project(
# ---- Include guards ----

if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Use a build directory."
)
message(FATAL_ERROR "In-source builds not allowed. Use a build directory.")
endif()


if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

# Optionally set things like CMAKE_CXX_STANDARD, CMAKE_POSITION_INDEPENDENT_CODE here
Expand All @@ -30,13 +26,10 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Let's nicely support folders in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Testing only available if this is the main app
# Note this needs to be done in the main CMakeLists
# since it calls enable_testing, which must be in the
# main CMakeLists.
# Testing only available if this is the main app Note this needs to be done in the main CMakeLists
# since it calls enable_testing, which must be in the main CMakeLists.
include(CTest)
# include(CMakePrintHelpers)
# Docs only available if this is the main app
# include(CMakePrintHelpers) Docs only available if this is the main app
find_package(Doxygen)
if(Doxygen_FOUND)
add_subdirectory(docs)
Expand All @@ -56,7 +49,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(cmake/CPM.cmake)
include(cmake/tools.cmake)


CPMAddPackage(
NAME fmt
GIT_TAG 7.1.3
Expand All @@ -78,9 +70,8 @@ add_subdirectory(apps)
CPMAddPackage("gh:TheLartians/[email protected]")

# ---- Create an installable target ----
# this allows users to install and find the library via `find_package()`.
# the location where the project's version header will be placed should match the project's regular
# header paths
# this allows users to install and find the library via `find_package()`. the location where the
# project's version header will be placed should match the project's regular header paths
string(TOLOWER greeter/version.h VERSION_HEADER_LOCATION)
packageProject(
NAME greeter
Expand Down
7 changes: 3 additions & 4 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()

Expand Down
46 changes: 20 additions & 26 deletions cmake/tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,44 @@ include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address,
# Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
if(USE_SANITIZER OR USE_STATIC_ANALYZER)
cpmaddpackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354")
CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354")

if(USE_SANITIZER)
include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
endif()

if(USE_STATIC_ANALYZER)
if("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
set(
CLANG_TIDY
ON
CACHE INTERNAL ""
set(CLANG_TIDY
ON
CACHE INTERNAL ""
)
else()
set(
CLANG_TIDY
OFF
CACHE INTERNAL ""
set(CLANG_TIDY
OFF
CACHE INTERNAL ""
)
endif()
if("iwyu" IN_LIST USE_STATIC_ANALYZER)
set(
IWYU
ON
CACHE INTERNAL ""
set(IWYU
ON
CACHE INTERNAL ""
)
else()
set(
IWYU
OFF
CACHE INTERNAL ""
set(IWYU
OFF
CACHE INTERNAL ""
)
endif()
if("cppcheck" IN_LIST USE_STATIC_ANALYZER)
set(
CPPCHECK
ON
CACHE INTERNAL ""
set(CPPCHECK
ON
CACHE INTERNAL ""
)
else()
set(
CPPCHECK
OFF
CACHE INTERNAL ""
set(CPPCHECK
OFF
CACHE INTERNAL ""
)
endif()

Expand All @@ -68,5 +62,5 @@ endif()

# enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent
if(USE_CCACHE)
cpmaddpackage("gh:TheLartians/[email protected]")
CPMAddPackage("gh:TheLartians/[email protected]")
endif()
2 changes: 1 addition & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.23 FATAL_ERROR)

include(../cmake/CPM.cmake)

cpmaddpackage("gh:mosra/m.css#42d4a9a48f31f5df6e246c948403b54b50574a2a")
CPMAddPackage("gh:mosra/m.css#42d4a9a48f31f5df6e246c948403b54b50574a2a")
# CPMAddPackage(NAME greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)

# ---- Doxygen variables ----
Expand Down
3 changes: 1 addition & 2 deletions libs/greeter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)


# ---- Add source files ----

# Note: globbing sources is considered bad practice as CMake's generators may not detect new files
Expand All @@ -25,7 +24,7 @@ target_link_libraries(greeter PRIVATE fmt::fmt)

target_include_directories(
greeter PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
Expand Down

0 comments on commit 8a6c7f4

Please sign in to comment.