Skip to content

Commit

Permalink
Merge branch 'feat/fix-cmake-lint' into 'devel'
Browse files Browse the repository at this point in the history
[CI] Focus CMake lint away from build

See merge request tuda-sc/projects/metacg!170
  • Loading branch information
pearzt committed Nov 4, 2024
2 parents 6b18ac9 + 90b9122 commit b041e4e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mcg-cmake-lint:
stage: lint
needs: ["mcg-download"]
script:
- for f in $(find . -name "CMakeLists.txt"); do cmake-format --check $f || exit 1; done
- for f in $(find {cgcollector,graph,pgis} -name "CMakeLists.txt"); do cmake-format --check $f || exit 1; done ; cmake-format --check CMakeLists.txt
- for f in $(find ./cmake -type f); do cmake-format --check $f || exit 1; done


Expand Down
19 changes: 9 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# This ships with Ubuntu 20.04 and supports C++20
cmake_minimum_required(VERSION 3.16)

# Choose modern CMake behavior when extracting archives
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
list(
APPEND
CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
)

include(Policies)

set_policies()

# Require out-of-source builds (taken from
# https://hsf-training.github.io/hsf-training-cmake-webpage/07-commonproblems/index.html)
Expand Down Expand Up @@ -38,12 +43,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

list(
APPEND
CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
)

set(METACG_Directory ${CMAKE_CURRENT_SOURCE_DIR})

# Whether the GoogleTest-based unit tests should be built and GoogleTest is downloaded as dependency This needs to be
Expand Down
12 changes: 8 additions & 4 deletions cmake/GoogleTest.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
FetchContent_MakeAvailable(googletest)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(gtest_force_shared_crt
ON
CACHE BOOL
""
FORCE
)

function(add_googletest_libraries target)
target_link_libraries(${target} PUBLIC GTest::gtest_main)
target_link_libraries(${target} PUBLIC GTest::gtest_main)
endfunction()
10 changes: 10 additions & 0 deletions cmake/Policies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function(set_policies)
# Choose modern CMake behavior when extracting archives
if(POLICY CMP0135)
cmake_policy(
SET
CMP0135
NEW
)
endif()
endfunction()
2 changes: 1 addition & 1 deletion cmake/ToolchainOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ function(target_project_compile_definitions target)
if(ARG_PUBLIC_DEFS)
target_compile_definitions(${target} PUBLIC "${ARG_PUBLIC_DEFS}")
endif()
endfunction()
endfunction()
10 changes: 3 additions & 7 deletions cmake/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ include(FetchContent)
# We require spdlog to be built as a static library
set(SPDLOG_BUILD_SHARED
OFF
CACHE BOOL
"MetaCG requires statically built spdlog to avoid lifetime issues"
CACHE BOOL "MetaCG requires statically built spdlog to avoid lifetime issues"
)

# Use the spdlog install option to install when MetaCG is installed
Expand All @@ -16,13 +15,10 @@ set(SPDLOG_INSTALL
FetchContent_Declare(spdlog URL https://github.com/gabime/spdlog/archive/refs/tags/v1.8.2.tar.gz)
FetchContent_MakeAvailable(spdlog)

if (DEFINED spdlog_SOURCE_DIR)
set_target_properties(spdlog PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
if(DEFINED spdlog_SOURCE_DIR)
set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()


function(add_spdlog_libraries target)
target_link_libraries(${target} PRIVATE spdlog::spdlog)
endfunction()

0 comments on commit b041e4e

Please sign in to comment.