# Skipping an useless argument when invoking a command

**URL:** <https://discourse.cmake.org/t/skipping-an-useless-argument-when-invoking-a-command/8258>\
**Category:** Code\
**Created:** [June 5, 2023, 9:53am UTC](https://discourse.cmake.org/t/skipping-an-useless-argument-when-invoking-a-command/8258 "2023-06-05T09:53:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cher-nov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/cher-nov/32/3433_2.png) [@cher-nov](https://discourse.cmake.org/u/cher-nov)\
**Post date:** [June 5, 2023, 9:53am UTC](https://discourse.cmake.org/t/skipping-an-useless-argument-when-invoking-a-command/8258/1 "2023-06-05T09:53:04Z")

</div>

I want to call `string(REGEX MATCH` without the `<output_variable>` argument, because I don’t need it in this particular case since I want to use `CMAKE_MATCH_<n>` variables instead. So my invocation line looks something like this:

```cmake
string(REGEX MATCH "^#define LIBRARY_VERSION .*\\(([0-9]+),([0-9]+),([0-9]+)\\)" _z "${version_file_raw}")

```

The problem is that I don’t want to clutter namespace with obscure dummy variables that use some unclear notation to mark them as unused (in this example it’s `_z` - a leading underscore and a meaningless name).

Is there any default notation and/or good practice way for that?

I have tried to replace `_z` with the following options:

1. `""` - doesn’t work, fails with a random error citing the contents of the match, as in `CMAKE_MATCH_0`:

```plaintext
-- Detecting C compiler ABI info
CMake Error: Parse error in command line argument: #define LIBRARY_VERSION \
(0,1,0)
 Should be: VAR:type=value

CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile):
  Failed to configure test project build system.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:8 (project)

-- Configuring incomplete, errors occurred!

```

1. `0` - doesn’t work, fails with another random error:

```plaintext
-- Detecting CXX compile features - failed
CMake Error at sources/plainmtp.cmake:19 (target_compile_features):
  target_compile_features no known features for C compiler

  "MSVC"

  version 19.29.30147.0.
Call Stack (most recent call first):
  CMakeLists.txt:9 (include)

-- Configuring incomplete, errors occurred!

```

1. `" "` - seems to work.
2. `_` / `,` / `;` / `:` / `$` / invalid identifiers like `123test` - also seem to work.

If there is no default way, then which of the mentioned ones is better?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 7, 2023, 11:59am UTC](https://discourse.cmake.org/t/skipping-an-useless-argument-when-invoking-a-command/8258/2 "2023-06-07T11:59:36Z")

</div>

Just use `unset(_z)` after the call.

---

<div class="post-metadata">

**Author:** ![cher-nov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/cher-nov/32/3433_2.png) [@cher-nov](https://discourse.cmake.org/u/cher-nov)\
**Post date:** [June 7, 2023, 2:33pm UTC](https://discourse.cmake.org/t/skipping-an-useless-argument-when-invoking-a-command/8258/3 "2023-06-07T14:33:56Z")

</div>

This is also an option, but I’m wondering how it can be done without being too verbose.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 7, 2023, 2:47pm UTC](https://discourse.cmake.org/t/skipping-an-useless-argument-when-invoking-a-command/8258/4 "2023-06-07T14:47:34Z")

</div>

There’s no “bit bucket” variable available in CMake.
