gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

Visual Studio plugin does not support C++ Unit Test #1011

Open lacasseio opened 5 years ago

lacasseio commented 5 years ago

Expected Behavior

cpp-unit-test should participate to Visual Studio project creation.

Current Behavior

C++ component added by cpp-unit-test aren't available in Visual Studio.

Context

Steps to Reproduce (for bugs)

Your Environment

pedrolamarao commented 5 years ago

I am very interested in this. Currently, this is how I keep both main and test Visual C++ projects in a single source directory. I generate a foo.vcxproj and foo-test.vcxproj side by side. I adjust the "Intermediate Directory" to obj\main\$(Platform)\$(Configuration) and obj\test\$(Platform)\$(Configuration) accordingly. In foo.vcxproj, I "Exclude From Project" the entire src/test directory. In foo-test.vcxproj, "Exclude From Project" the src/main/main.cpp file or some similar conflict. This way, foo-test statically imports foo sources, which, if I understand correctly, is how cpp-unit-test works. I have also experimented with foo-test dynamically linking with foo, successfully. With this approach, cpp-unit-test works out of the box with my Visual C++ projects. Edit: my foo-test projects are always googletest console projects; Visual Studio Unit Test discovery works.