# On nonstandard extensions and subdirectories

**URL:** https://discourse.cmake.org/t/on-nonstandard-extensions-and-subdirectories/11115
**Category:** Usage
**Tags:** os:linux
**Created:** [June 27, 2024, 10:31am UTC](https://discourse.cmake.org/t/on-nonstandard-extensions-and-subdirectories/11115 "2024-06-27T10:31:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![owlingbishop](https://discourse.cmake.org/user_avatar/discourse.cmake.org/owlingbishop/32/4703_2.png) [@owlingbishop](https://discourse.cmake.org/u/owlingbishop)
#### Post date: [June 27, 2024, 10:31am UTC](https://discourse.cmake.org/t/on-nonstandard-extensions-and-subdirectories/11115/1 "2024-06-27T10:31:11Z")

</div>

Hello there !!

I have a project that compiles correctly with the following CMakeLists.txt

/CMakeLists.txt

```auto
# Set the project name and language
project(myProject LANGUAGES CXX)

# Set the C++20 standard globally
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)

list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS "impl;IMPL")
set_source_files_properties(GLOB_RECURSE **/*.impl LANGUAGE CXX COMPILE_FLAGS "-x c++")
set_source_files_properties(GLOB_RECURSE **/*.IMPL LANGUAGE CXX COMPILE_FLAGS "-x c++")

# Add source files
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.impl)
cmake_print_variables(SOURCES)

set_source_files_properties(${SOURCES} LANGUAGE CXX COMPILE_FLAGS "-x c++")
message(STATUS "CMAKE_CXX_SOURCE_FILE_EXTENSIONS: ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS}")

# Add executable target
add_executable(myProject-cli ${SOURCES})

```

→ \*.impl are correctly found/listed in GLOB and correctly added to build instructions as C++ files

But when I try to put the `GLOB` and `add_executable(myProject-cli ${SOURCES})` in a subfolder \*.impl are correctly found/listed in GLOB but _ **NOT** _ added to build instructions as C++ files, despite `CMAKE_CXX_SOURCE_FILE_EXTENSIONS` still being valid (including \*.impl) …

Would that be a known bug in cmake or an undocumented feature ? Or am-I doing somethig wrong ?

Thanks for any insight 🙂

Lo.

/CMakeLists.txt

```auto
# Set the project name and language
project(myProject LANGUAGES CXX)

# Set the C++20 standard globally
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)

list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS "impl;IMPL")
set_source_files_properties(GLOB_RECURSE **/*.impl LANGUAGE CXX COMPILE_FLAGS "-x c++")

add_subdirectory(_Core)

```

/\_Core/CMakeLists.txt

```auto
project(myProject-core LANGUAGES CXX)

# Set C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# # Add source files
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.impl)
cmake_print_variables(SOURCES)

set_source_files_properties(${SOURCES} LANGUAGE CXX COMPILE_FLAGS "-x c++")

# Add static library target
add_library(myProject-core.stat STATIC ${SOURCES})
set_property(TARGET myProject-core-stat PROPERTY LANGUAGE CXX POSITION_INDEPENDENT_CODE 1)
set_target_properties(myProject-core.stat PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(myProject-core.stat PUBLIC ${CMAKE_SOURCE_DIR}/_Core/include)
export(TARGETS myProject-core.stat FILE myProject-core.stat.cmake)

```

---

<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: [July 17, 2025, 4:13pm UTC](https://discourse.cmake.org/t/on-nonstandard-extensions-and-subdirectories/11115/2 "2025-07-17T16:13:11Z")

</div>

> [@owlingbishop](#):
>
> `set_source_files_properties(GLOB_RECURSE`

This is not a thing. `GLOB_RECURSE` is treated as just another filename here. I would glob the files then pass them to `set_source_files_properties` (as you do in `_Core`).
