# ExternalProject\_Add and CMAKE\_CONFIGURATION\_TYPES

**URL:** <https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744>\
**Category:** Code\
**Tags:** gen:vs\
**Created:** [August 15, 2023, 7:47pm UTC](https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744 "2023-08-15T19:47:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxEd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxed/32/3561_2.png) [@MaxEd](https://discourse.cmake.org/u/MaxEd)\
**Post date:** [August 15, 2023, 7:47pm UTC](https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744/1 "2023-08-15T19:47:13Z")

</div>

I added an external project to my CMake file, and I wanted it to have the same set of configurations as the parent project. However, the generated project seems to have only one configuration - the default RelWithDebInfo. Here’s the code:

```auto
include(ExternalProject)
ExternalProject_Add(allegro_monolith_ext 
    SOURCE_DIR ${ALLEGRO_DIR} 
    CMAKE_GENERATOR ${CMAKE_GENERATOR}
    CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
    CMAKE_CACHE_ARGS 
        -DWANT_MONOLITH:BOOL=ON
        -DWANT_DEMO:BOOL=OFF
        -DWANT_DOCS:BOOL=OFF
        -DWANT_VIDEO:BOOL=OFF
        -DWANT_EXAMPLES:BOOL=OFF
        -DFREETYPE_ZLIB:BOOL=ON
        -DFREETYPE_BZIP2:BOOL=OFF
        -DSHARED:BOOL=ON
        -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
        -DCMAKE_CONFIGURATION_TYPES:STRING=${CMAKE_CONFIGURATION_TYPES}
        -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_BINARY_DIR}/allegro
    LOG_CONFIGURE 1
)

```

In the generated CMakeCache:

```auto
CMAKE_CONFIGURATION_TYPES:INTERNAL=RelWithDebInfo

```

But the rest of options are set, so I’m sure that they are not entirely ignored. I assumed that external project should be built with the same set of configurations and currently selected configuration as the main project, but it’s not happening: if I change build type to Debug in Visual Studio, I get error `error MSB8013: This project doesn't contain the Configuration and Platform combination of Debug|x64.`

---

<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:** [August 15, 2023, 8:22pm UTC](https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744/2 "2023-08-15T20:22:04Z")

</div>

`CMAKE_CONFIGURATION_TYPES` is a `;`-separated list. So this ends up with cache args of (in some order):

```auto
-DCMAKE_CONFIGURATION_TYPES:STRING=RelWithDebInfo
Debug
Release
MinSizeRel

```

You need to replace the `;` and let EP know with the `LIST_SEPARATOR` argument.

---

<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:** [August 15, 2023, 8:22pm UTC](https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744/3 "2023-08-15T20:22:40Z")

</div>

Quoting may also help to some extent; I’d try that with your minimum CMake and bump if that is more palatable to you (and it works on newer CMake versions).

---

<div class="post-metadata">

**Author:** ![MaxEd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxed/32/3561_2.png) [@MaxEd](https://discourse.cmake.org/u/MaxEd)\
**Post date:** [August 15, 2023, 8:43pm UTC](https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744/4 "2023-08-15T20:43:00Z")

</div>

```auto
string(REPLACE ";" "|" CONFIGS "${CMAKE_CONFIGURATION_TYPES}")
message(STATUS "=====> ${CONFIGS}")

ExternalProject_Add(allegro_monolith_ext 
LIST_SEPARATOR "|"
    ...
CMAKE_CACHE_ARGS 
    -DCMAKE_CONFIGURATION_TYPES:STRING=${CONFIGS}

```

prints `=====> Debug|Release|MinSizeRel|RelWithDebInfo`, so CONFIGS is now a corrected value, but ExternalProject is still generated with only RelWithDebInfo. Interestingly, the list of configurations ends up with “;” in “allegro\_monolith\_ext-cache-Debug.cmake” (the file used to populate CMake cache with CMAKE\_CACHE\_ARGS). And CMakeCache.txt still ends up with a single config.

I’m not sure LIST\_SEPARATOR makes sense in context of CMAKE\_CACHE\_ARGS - it documented to work on command line arguments mostly. If I move DCMAKE\_CONFIGURATION\_TYPES to CMAKE\_ARGS, it gets passed to CMake with escaped ‘;’ between configs, but they’re still ignored silently.

---

<div class="post-metadata">

**Author:** ![MaxEd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maxed/32/3561_2.png) [@MaxEd](https://discourse.cmake.org/u/MaxEd)\
**Post date:** [August 16, 2023, 8:58am UTC](https://discourse.cmake.org/t/externalproject-add-and-cmake-configuration-types/8744/5 "2023-08-16T08:58:03Z")

</div>

OK, it seems that the external project was overwriting  
CMAKE\_CONFIGURATION\_TYPES. Who knew…
