Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch_discover_tests DISCOVERY_MODE PRE_TEST does not work with Xcode. #2746

Closed
z-ukalnins opened this issue Sep 20, 2023 · 1 comment
Closed
Labels
Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.

Comments

@z-ukalnins
Copy link

Describe the bug
Adding DISCOVERY_MODE "PRE_TEST" to catch_discover_tests causes cmake errors during project generation if Xcode generator is used.

Example error:

CMake Error in Tests/CMakeLists.txt:
  Evaluation file to be written multiple times with different content.  This
  is generally caused by the content evaluating the configuration type,
  language, or location of object files:

   <Path To Project>/Tests/test-core_include-b12d07c.cmake

Expected behavior

No errors during make project generation and test discovery mode delayed until test execution.

Reproduction steps
Project setup:

// test.cpp 
#include <catch2/catch_test_macros.hpp>

TEST_CASE("Empty", "[Empty]")
{
}

// CMakeLists.txt
cmake_minimum_required(VERSION 3.27)
project(Test LANGUAGES C CXX)
include(FetchContent)
FetchContent_Declare(
  Catch2
  GIT_REPOSITORY https://github.com/catchorg/Catch2.git
  GIT_TAG        v3.4.0
)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(Catch)
add_executable(test-core test.cpp)
target_link_libraries(test-core PRIVATE Catch2::Catch2WithMain)
catch_discover_tests(test-core WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" DISCOVERY_MODE "PRE_TEST")

Command to execute:

cmake -G Xcode

Platform information:

  • OS: macOS-13.5.2
  • Compiler+version: Xcode-15
  • Catch version: v3.4.0

Additional context
I suspect that DISCOVERY_MODE fails to account for multi config build systems.

@horenmar
Copy link
Member

I suspect that DISCOVERY_MODE fails to account for multi config build systems.

This is correct, see #2739

@horenmar horenmar added the Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration. label Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.
Projects
None yet
Development

No branches or pull requests

2 participants