catchorg / catchorg/Catch2

Catch2 ParseAndAddCatchTests with CMake generator expressions not working

Open
#2,228 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

The `ParseAndAddCatchTests` CMake macro warns when generator expression is used. I have two scenarios that I'm trying to figure out if there's a solution to:

```cmake
add_executable(tests
test.cpp
$<$:test_feature_x.cpp>
$<$:
test_feature_y_1.cpp
test_feature_y_2.cpp>)
```

The `FEATURE_X` scenario simply presents the warning:

```
CMake Warning at cmake/Modules/ParseAndAddCatchTests.cmake:101 (message):
Cannot find source file:
C:/src/binpkg/test/$<$:test_feature_x.cpp>
Call Stack (most recent call first):
cmake/Modules/ParseAndAddCatchTests.cmake:248 (ParseAndAddCatchTests_ParseFile)
test/CMakeLists.txt:25 (ParseAndAddCatchTests)
```

The `FEATURE_Y` scenario does the same, but also continues to include the `test_feature_y_1.cpp` and `test_feature_y_2.cpp` files, which is not good for what I am trying to do.

**Expected behavior**
I'm not sure if this is mainly a CMake macro issue, but I'd expect the files to not be passed to `ParseAndAddCatchTests`.

**Reproduction steps**
See [my example](https://github.com/erichschroeter/binpkg/commit/0f8649377862e77a0464935eb17fa7bd61c73bc7).

**Platform information:**
- OS: **Windows 10**
- Compiler+version: **Microsoft (R) Build Engine version 16.3.2+e481bbf88 for .NET Framework**
- Catch version: **v3.0.0-preview3**

**Additional context**
Is there a way to use CMake generator expressions with the Catch2 macros/functions?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.