r/cmake

▲ 9 r/cmake+1 crossposts

C++ is an old language, and so is its business model. And if the language needs some updates from time to time, its business model might need them too. But hold on, what is C++'s business model? C++ is the specification of a programming language, so what are you talking about?

u/_a4z — 4 hours ago
▲ 0 r/cmake+2 crossposts

who else uses AI to write CMakeLists.txt

im a lazy programmer, I absolutely hate cmake files, they take away from the C experience. Just wondering who else uses AI to write cmake files. (I love cmake, its real easy to use. Just not the cmakelists.txt files)

reddit.com
u/Clear_Safe_5408 — 11 days ago
▲ 22 r/cmake+1 crossposts

A small CMake helper for C++20 modules (including C++23 import std)

I’ve been experimenting with C++ modules across different compilers and build systems, and ended up writing a small CMake helper script that makes the whole thing much less painful.

It doesn’t try to reinvent module support — it relies on CMake’s native named-module features and only adds a thin layer of convenience (shorter target definitions, optional header-unit helpers, and clean presets for Clang/GCC/MSVC).

If you’re playing with modules or want a minimal, practical setup without extra tooling, you might find it useful:

👉 https://github.com/basvas-jkj/cpp_modules

It includes example programs, compiler compatibility notes, and a summary of what actually works in practice on Windows/Linux.

If you want to see larger example, you can check my older project, fully rewritten to use C++ modules:

👉 https://github.com/basvas-jkj/oul

u/basvas_jkj — 13 days ago
▲ 0 r/cmake

Why is CONFIGURE_DEPENDS not working properly with UNIX Makefiles?

I was using a remote development environment using Clion which ssh onto a raspberry pi 5: Debian GNU/Linux 13 (trixie) aarch64 RPIOS Lite from a windows computer

the ssh works, Directory structure:

https://preview.redd.it/a2fdamk3f50h1.png?width=336&format=png&auto=webp&s=c5e0cf2be775a5c7f57e1978a6889ee35b7f4c86

the problem comes when I use GLOB

cmake_minimum_required(VERSION 3.31.4)

project(custom_stack)

set(HEADER_DIR include)
file(GLOB headers "${HEADER_DIR}/*.h")
file(GLOB sources "src/*.c")

add_library(custom STATIC ${sources} ${headers})

target_compile_options(custom PRIVATE -Wall -Wextra)

target_include_directories(custom PUBLIC "${HEADER_DIR}")

add_executable(${CMAKE_PROJECT_NAME} main.c)

target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)

target_link_libraries(${CMAKE_PROJECT_NAME} custom)

Not the best practice, I know! but this works with success

but when I add:

cmake_minimum_required(VERSION 3.31.4)

project(custom_stack)

set(HEADER_DIR include)
file(GLOB CONFIGURE_DEPENDS headers "${HEADER_DIR}/*.h")
file(GLOB CONFIGURE_DEPENDS sources "src/*.c")

add_library(custom STATIC ${sources} ${headers})

target_compile_options(custom PRIVATE -Wall -Wextra)

target_include_directories(custom PUBLIC "${HEADER_DIR}")

add_executable(${CMAKE_PROJECT_NAME} main.c)

target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)

target_link_libraries(${CMAKE_PROJECT_NAME} custom)

it fails by not finding any source files? why?

https://preview.redd.it/mawrpabaf50h1.png?width=1332&format=png&auto=webp&s=882ee4448bd4b3c6077c047d60a440738039aaf2

reddit.com
u/No-Worldliness-5106 — 14 days ago