# How to parse the values passed to findXXX.cmake file?

**URL:** https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098
**Category:** Code
**Created:** [December 20, 2022, 11:51am UTC](https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098 "2022-12-20T11:51:13Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![msilvestre](https://discourse.cmake.org/user_avatar/discourse.cmake.org/msilvestre/32/2666_2.png) [@msilvestre](https://discourse.cmake.org/u/msilvestre)
#### Post date: [December 20, 2022, 11:51am UTC](https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098/1 "2022-12-20T11:51:13Z")

</div>

Hi all,

I need to parse the stuff passed to findXXX.cmake file. How can it be done?

I’ve tried the `cmake_parse_arguments` but ARGV and ARGN are empty.

Usage example:

CMakeLists.txt file:

```auto
find_package(foo REQUIRED
    COMPONENTS
         bar
         baz
) 

```

findfoo.cmake file:

```auto
# find what components do we need and if it is required
# Parsing code here
if(MY_CONDITION)
 do_something()
else ()
  do_another_thing(foo_COMPONENTS)
endif()

```

Thanks.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [December 20, 2022, 12:41pm UTC](https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098/2 "2022-12-20T12:41:41Z")

</div>

You cannot do that. Arguments passed to `find_package` are already parsed when `FindXXX.cmake` is called. Various [variables](https://cmake.org/cmake/help/latest/command/find_package.html#package-file-interface-variables) are defined to describe the arguments passed to `find_package`.

The constraint to this approach is that it is not possible to pass unknown (i.e. custom) arguments to `find_package`.

---

<div class="post-metadata">

### Author: ![msilvestre](https://discourse.cmake.org/user_avatar/discourse.cmake.org/msilvestre/32/2666_2.png) [@msilvestre](https://discourse.cmake.org/u/msilvestre)
#### Post date: [December 20, 2022, 3:09pm UTC](https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098/3 "2022-12-20T15:09:24Z")

</div>

That will do. Many thanks
