# configure\_package\_config\_file throws error of unknown keyword ${PROJECT\_NAME}-config.cmake

**URL:** https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998
**Category:** Usage
**Created:** [June 12, 2024, 8:41am UTC](https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998 "2024-06-12T08:41:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![maichmueller](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maichmueller/32/4660_2.png) [@maichmueller](https://discourse.cmake.org/u/maichmueller)
#### Post date: [June 12, 2024, 8:41am UTC](https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998/1 "2024-06-12T08:41:45Z")

</div>

Hi all,

I am trying to pull in the [Arcade-Learning-Environment](https://github.com/Farama-Foundation/Arcade-Learning-Environment) project via CPM in my project via

```
CPMAddPackage(
        NAME ale  
        GIT_TAG v0.9.0
        # Configuration options passed to the dependency (optional)
        SYSTEM TRUE
        BUILD_CPP_LIB=ON
        BUILD_PYTHON_LIB=OFF
        DOWNLOAD_ONLY FALSE      
        GITHUB_REPOSITORY Farama-Foundation/Arcade-Learning-Environment
)

```

but run into an error with `configure_package_config_file` which is used in the project like so:

root CMakeLists.txt:

```auto
...

# Set cmake module path
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
...
project(ale 
           VERSION ${ALE_DEFAULT_VERSION}
            DESCRIPTION "The Arcade Learning Environment (ALE) - a platform for AI research."
            HOMEPAGE_URL "http://www.arcadelearningenvironment.org"
            LANGUAGES CXX)

# Main ALE src directory
add_subdirectory(src)
...

```

src/CMakeLists.txt:

```auto
...
  # Configure installable cmake config
  configure_package_config_file(
    ${CMAKE_MODULE_PATH}/${PROJECT_NAME}-config.cmake.in
    ${PROJECT_NAME}-config.cmake
    INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
...

```

the ale-config.cmake.in file resides in their root-level folder `cmake` which seems to be found.  
Letting CPM populate this repo now brings up this error though:

> CMake Error at /u/michael.aichmueller/cmake-3.26.5-linux-x86\_64/share/cmake-3.26/Modules/CMakePackageConfigHelpers.cmake:250 (message):  
> Unknown keywords given to CONFIGURE\_PACKAGE\_CONFIG\_FILE():  
> “ale-config.cmake”  
> Call Stack (most recent call first):  
> cmake-build-debug-clang-lactose/\_deps/ale-src/src/CMakeLists.txt:105 (configure\_package\_config\_file)

I have been trying to fix this in my fork by prepending e.g. ${CMAKE\_CURRENT\_BINARY\_DIR} to the output path of `configure_package_config_file` and/or adding quotes, but all lead to errors.

In fact, the documentation and [example on the cmake github repo](https://github.com/Kitware/CMake/blob/3f7493de72251f3dac721f960456ea474f15a330/Modules/CMakePackageConfigHelpers.cmake#L354) lead me to believe that the usage in ALE is correct.

This was run with cmake 26.5 on an x86-64 ubuntu 22.04 system.

Any tips on why this would not work?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [June 12, 2024, 10:04pm UTC](https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998/2 "2024-06-12T22:04:57Z")

</div>

The problem is the use of `${CMAKE_MODULE_PATH}` in the first argument. That’s not valid, the `CMAKE_MODULE_PATH` variable can (and indeed in this case does) contain a list. That will result in the first argument being parsed as multiple arguments. I’m not sure what they were intending, but this is definitely a bug in their project.

---

<div class="post-metadata">

### Author: ![maichmueller](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maichmueller/32/4660_2.png) [@maichmueller](https://discourse.cmake.org/u/maichmueller)
#### Post date: [June 13, 2024, 8:50am UTC](https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998/3 "2024-06-13T08:50:51Z")

</div>

Hi @craig.scott , thanks for the answer!

I see that the first input takes up the 1st and 2nd argument (input and output) upon expansion of configure\_package\_config\_file which forces the ale-config.cmake file to be parsed as keyword.

Once I replaced CMAKE\_MODULE\_PATH with CMAKE\_CURRENT\_SOURCE\_DIR/…/cmake for the 1st arg in the function call within my fork, I could configure the project correctly.

Thanks for your help. I will suggest the fix to the project maintainers.
