Configure CMake Projects to pass current file as an argument for debugging and launch

slymz 6 Reputation points
2020-12-07T14:42:32.183+00:00

I have a CMake project that happens to have a few Google Test executable targets. For debugging and building it would be a wonderful feat to be able to pass the current file name as an argument, like so:

{
        "name": "CurrentFile",
        "args": [
            "--gtest_filter=${fileBaseName}.*"   // <-- I made the variable name up
        ],
        "project": "CMakeLists.txt",
        "projectTarget": "cxx.exe",
        "type": "default",
    }

Is there such a variable? (side-note, I set test suite name as the file name to simply this automation)

Are there other documented (or yet to be documented) ways to accomplish this?

Thanks

PS: The question exemplifies Google Test. But of course, passing an argument derived from context is the most important question here. It would be useful for other non-google-test targets.

Community Center | Not monitored
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.