diff --git a/CMakeLists.txt b/CMakeLists.txt index 48596a9..52c15c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/build_cmake.bat b/build_cmake.bat index db4cbc9..3694ecf 100644 --- a/build_cmake.bat +++ b/build_cmake.bat @@ -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 \ No newline at end of file +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" \ No newline at end of file diff --git a/build_cmake.sh b/build_cmake.sh index 2893827..e0e26ac 100755 --- a/build_cmake.sh +++ b/build_cmake.sh @@ -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 ." \ No newline at end of file +echo "To run tests: cd build_ci && ctest" +echo "To install: cd build_ci && sudo cmake --install ." \ No newline at end of file