Skip to content

Commit 922c29d

Browse files
committed
fix doctest path resolve if system package used
1 parent cf98625 commit 922c29d

File tree

6 files changed

+46
-29
lines changed

6 files changed

+46
-29
lines changed

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ list(
1414
${CMAKE_CURRENT_LIST_DIR}/cmake/pkg
1515
${CMAKE_CURRENT_LIST_DIR}/cmake/utils)
1616

17-
# Android: only extend CMAKE_FIND_ROOT_PATH if cross-compiling
1817
if(CMAKE_CROSSCOMPILING)
1918
list(
2019
APPEND
@@ -32,11 +31,11 @@ option(ENABLE_DEV_TOOLS "Enable dev tools like clang-format, clang-tidy, etc."
3231
OFF)
3332

3433
if(ENABLE_DEV_TOOLS)
35-
find_package(clang_format CONFIG QUIET)
36-
find_package(clang_tidy CONFIG QUIET)
37-
find_package(clang_doc CONFIG QUIET)
38-
find_package(cpplint CONFIG QUIET)
39-
find_package(doxygen CONFIG QUIET)
34+
find_package(clang_format CONFIG REQUIRED)
35+
find_package(clang_tidy CONFIG REQUIRED)
36+
find_package(clang_doc CONFIG REQUIRED)
37+
find_package(cpplint CONFIG REQUIRED)
38+
find_package(doxygen CONFIG REQUIRED)
4039

4140
# Optional: fail if critical tools missing in dev mode?
4241
# mark_as_advanced(...) # hide from GUI if desired

cmake/cpm-config.cmake

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@
33
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
44

55
set(CPM_DOWNLOAD_VERSION 0.42.0)
6-
set(CPM_HASH_SUM "2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a")
6+
set(CPM_HASH_SUM
7+
"2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a")
78

89
if(CPM_SOURCE_CACHE)
9-
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
10+
set(CPM_DOWNLOAD_LOCATION
11+
"${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
1012
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
11-
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
13+
set(CPM_DOWNLOAD_LOCATION
14+
"$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
1215
else()
13-
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
16+
set(CPM_DOWNLOAD_LOCATION
17+
"${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
1418
endif()
1519

1620
# Expand relative path. This is important if the provided path contains a tilde (~)
1721
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
1822

19-
file(DOWNLOAD
20-
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
21-
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
22-
)
23+
file(
24+
DOWNLOAD
25+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
26+
${CPM_DOWNLOAD_LOCATION}
27+
EXPECTED_HASH SHA256=${CPM_HASH_SUM})
2328

2429
include(${CPM_DOWNLOAD_LOCATION})
2530

cmake/cpm/doctest-config.cmake

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.28)
1+
cmake_minimum_required(VERSION 3.30)
22

33
cpmaddpackage(
44
NAME
@@ -8,13 +8,22 @@ cpmaddpackage(
88
VERSION
99
2.4.12
1010
SYSTEM
11-
YES
11+
ON
1212
GIT_SHALLOW
13-
TRUE
13+
ON
1414
OPTIONS
1515
"DOCTEST_WITH_TESTS OFF"
1616
"DOCTEST_WITH_MAIN_IN_STATIC_LIB OFF"
1717
"DOCTEST_NO_INSTALL ON"
1818
"DOCTEST_USE_STD_HEADERS ON")
1919

20-
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
20+
if(doctest_ADDED)
21+
set(doctest_cmake_path "${doctest_SOURCE_DIR}/scripts/cmake")
22+
set(doctest_source "downloaded")
23+
else()
24+
set(doctest_cmake_path "${doctest_DIR}")
25+
set(doctest_source "system")
26+
endif()
27+
28+
list(APPEND CMAKE_MODULE_PATH "${doctest_cmake_path}")
29+
message(STATUS "doctest (${doctest_source}) -> '${doctest_cmake_path}'")

cmake/cpm/sdl3-config.cmake

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@ cpmaddpackage(
88
GIT_TAG
99
a96677bdf6b4acb84af4ec294e5f60a4e8cbbe03
1010
SYSTEM
11-
YES
11+
ON
1212
GIT_SHALLOW
13-
TRUE
13+
ON
1414
OPTIONS
15+
# Core library config - fast shared build
1516
"SDL_STATIC
1617
OFF"
1718
"SDL_SHARED
1819
ON"
20+
# Performance optimizations
1921
"SDL_CCACHE
2022
ON"
23+
"CMAKE_BUILD_TYPE RelWithDebInfo"
24+
# Disable unnecessary features for speed
25+
"SDL_TEST_LIBRARY OFF"
26+
"SDL_TESTS OFF"
27+
"SDL_EXAMPLES OFF"
28+
"SDL_INSTALL_TESTS OFF"
29+
"SDL_DISABLE_INSTALL_DOCS ON"
30+
# Platform optimizations (Linux/Wayland focused)
2131
"SDL_X11
2232
OFF"
2333
"SDL_WAYLAND
@@ -27,9 +37,4 @@ cpmaddpackage(
2737
"SDL_RENDER_VULKAN
2838
OFF"
2939
"SDL_ASSEMBLY
30-
OFF"
31-
"SDL_TEST_LIBRARY
32-
OFF"
33-
"SDL_TESTS
34-
OFF
35-
")
40+
OFF")

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.28)
1+
cmake_minimum_required(VERSION 3.30)
22

33
add_executable(cli_app main.cpp)
44
target_link_libraries(cli_app PRIVATE warnings)

tests/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ target_compile_definitions(
4040
)
4141

4242
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Windows|Darwin")
43-
# TODO: make it explicit, without in cpm auto call
44-
# include(doctest)
43+
include(doctest)
4544
doctest_discover_tests(tests)
4645
endif()

0 commit comments

Comments
 (0)