This commit is contained in:
Tom Hicks
2025-04-09 19:42:37 -07:00
parent 07904c9336
commit f479672834
3 changed files with 41 additions and 22 deletions

View File

@@ -109,6 +109,7 @@ if(NOT TINYTEST_USE_SYSTEM_CPPUTILS)
# Disable CPPUtils tests to avoid conflicts with our targets
set(CPPUTILS_BUILD_TESTS OFF CACHE BOOL "Disable CPPUtils tests" FORCE)
set(CPPUTILS_ENABLE_TESTING OFF CACHE BOOL "Disable CPPUtils testing framework" FORCE)
set(CPPUTILS_SKIP_GOOGLETEST ON CACHE BOOL "Disable Google Test fetching in CPPUtils" FORCE)
FetchContent_Declare(
cpputils
@@ -121,10 +122,20 @@ if(NOT TINYTEST_USE_SYSTEM_CPPUTILS)
if(NOT cpputils_POPULATED)
FetchContent_Populate(cpputils)
# Try to patch the CPPUtils CMakeLists.txt to prevent Google Test fetching
if(EXISTS "${cpputils_SOURCE_DIR}/CMakeLists.txt")
file(READ "${cpputils_SOURCE_DIR}/CMakeLists.txt" CPPUTILS_CMAKE_CONTENT)
string(REPLACE "FetchContent_MakeAvailable(googletest)" "" CPPUTILS_CMAKE_CONTENT "${CPPUTILS_CMAKE_CONTENT}")
string(REPLACE "find_package(GTest REQUIRED)" "" CPPUTILS_CMAKE_CONTENT "${CPPUTILS_CMAKE_CONTENT}")
string(REPLACE "FetchContent_Declare(googletest" "# Disabled FetchContent_Declare(googletest" CPPUTILS_CMAKE_CONTENT "${CPPUTILS_CMAKE_CONTENT}")
file(WRITE "${cpputils_SOURCE_DIR}/CMakeLists.txt" "${CPPUTILS_CMAKE_CONTENT}")
endif()
# Set variables to prevent conflicts before we include the CMakeLists.txt
set(CPPUTILS_BUILD_TESTS OFF CACHE BOOL "Disable CPPUtils tests" FORCE)
set(CPPUTILS_BUILD_EXAMPLES OFF CACHE BOOL "Disable CPPUtils examples" FORCE)
set(CPPUTILS_ENABLE_TESTING OFF CACHE BOOL "Disable CPPUtils testing framework" FORCE)
set(CPPUTILS_SKIP_GOOGLETEST ON CACHE BOOL "Disable Google Test fetching in CPPUtils" FORCE)
# Store original flags
set(CMAKE_CXX_FLAGS_ORIG ${CMAKE_CXX_FLAGS})

View File

@@ -1,18 +1,22 @@
@echo off
:: Helper script to build TinyTest with CMake on Windows
setlocal enabledelayedexpansion
:: Create build directory if it doesn't exist
if not exist build mkdir build
cd build
REM Create build directory if it doesn't exist
if not exist build_ci mkdir build_ci
cd build_ci
:: Configure with CMake
echo Configuring with CMake...
cmake .. %*
REM Use the same CMake settings as in CI
cmake .. ^
-DCMAKE_BUILD_TYPE=Debug ^
-DTINYTEST_BUILD_SHARED_LIBS=OFF ^
-DBUILD_TESTING=ON
:: Build
echo Building...
cmake --build . --config Release
REM Build the project
cmake --build . --config Debug
echo Build complete!
echo To run tests: cd build ^&^& ctest -C Release
echo To install: cd build ^&^& cmake --install . --config Release
REM Run tests
ctest -C Debug --output-on-failure
echo "Build complete!"
echo "To run tests: cd build_ci && ctest -C Debug"
echo "To install: cd build_ci && cmake --install . --config Debug"

View File

@@ -5,17 +5,21 @@
set -e
# Create build directory if it doesn't exist
mkdir -p build
cd build
mkdir -p build_ci
cd build_ci
# Configure with CMake
echo "Configuring with CMake..."
cmake .. $@
# Use the same CMake settings as in CI
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DTINYTEST_BUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=ON
# Build
echo "Building..."
# Build the project
cmake --build .
# Run tests
ctest --output-on-failure
echo "Build complete!"
echo "To run tests: cd build && ctest"
echo "To install: cd build && sudo cmake --install ."
echo "To run tests: cd build_ci && ctest"
echo "To install: cd build_ci && sudo cmake --install ."