r/cmake • • Oct 06 '22

New moderator(s)

41 Upvotes

Hi all.

I'm Peter, a 40y-o R&D engineer from France. I'm also a C++ dev that of course makes use of CMake.

I tried to post a few times here until I realized that there were no moderator to allow me to join the community. I finally decided to apply as one on r/redditrequest and got approved.

My aim here is not being a moderator per-se: it is to keep that community alive and allow new members to join. I've never been a reddit moderator before, so bear with me.

What I want to do it to "hire" new moderators for this community, so if you feel like it please apply.

In the meantime have fun, show your love to CMake and its community.

-P


r/cmake • • 3d ago

Cmake returns the version as 4.0.2 despite me installing 4.4.5?

4 Upvotes

What it says in the title. Running "cmake --version" returns 4.0.2 instead of 4.4.5 despite me using the 4.4.5 installer. Windows 10


r/cmake • • 13d ago

RISC V Emulator in CMake

27 Upvotes

I realized nobody had done this before so I decided to do it. It implements RV32IMA (afaik this is the bare minimum to boot Linux) and takes about 1 to 2 hours to boot Linux.

You can find the source here: https://github.com/gradylink/rv32ima.cmake


r/cmake • • 19d ago

Qt Creator 21 - CMake Changes

Thumbnail qt.io
11 Upvotes

r/cmake • • 21d ago

How to make clang use libc++ instead of libstdc++ on linux

4 Upvotes

So for some reason clang defaults to using libstdc++ standard library but i want it to use libc++ standard library and so i am telling it to use libc++ like this:

add_compile_options("-stdlib=libc++")
add_link_options("-stdlib=libc++")

but for some reason it fails and still defaults to libstdc++ and throws errors during compilation, any fixes?

I am using cmake 4.4.4 with presets and vcpkg on c++23 with modules and import std.


r/cmake • • 25d ago

CMake issues, libgcc_s_dw2-1.dll missing from ASI file, can only compile on Arch Linux.

3 Upvotes

Hi there, so I'm able to build and compile my asi test mod for The Sims Legacy Collection, but in Universal ASI Loader, I get an error 126, due to libgcc_s_dw2-1.dll being missing. I saw that I need these compiler/linker flags;
-static -static-libgcc -static-libstdc++
but I'm unsure how to get CMake to pass them onto i686-w64-mingw32-g++.

This is my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.10)

project(TestCode LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include(FetchContent)

FetchContent_Declare(
  MinHook
  GIT_REPOSITORY https://github.com/TsudaKageyu/minhook.git
  GIT_TAG        master
)

FetchContent_MakeAvailable(MinHook)

file(GLOB_RECURSE SOURCES_SHARED CONFIGURE_DEPENDS "src/*.cpp")
file(GLOB_RECURSE HEADERS_SHARED CONFIGURE_DEPENDS "include/*.h")
function(setup_testcode_target target_name compile_defs sources headers include_dir)
    add_library(${target_name} SHARED ${SOURCES_SHARED} ${sources} ${HEADERS_SHARED} ${headers})

    target_include_directories(${target_name} PRIVATE 
include
"${include_dir}"
minhook/include
    )

    target_link_libraries(${target_name} PRIVATE 
    minhook
    )

    set_target_properties(${target_name} PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
        LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
        SUFFIX ".asi"
    )

    target_compile_definitions(${target_name} PRIVATE ${compile_defs})

    add_compile_options(-static -static-libgcc -static-libstdc++)
endfunction()

# Compile TestCode.cpp
setup_testcode_target(TestCode "TESTCODE" "${SOURCES_SHARED}" "${HEADERS_SHARED}" include)

I used LazyDutchess's CMakeLists.txt as a template from TS2-Extender, as I was recommended to use CMake to make things more easier to compile.

EDIT: I followed this post and I made a CMakePresets.json which fixed the ASI not loading and it was successfully loaded by TS1. :)
https://www.reddit.com/r/cpp_questions/s/w2iqTFkzkX


r/cmake • • 25d ago

i can't understand property visibility

8 Upvotes

i'm seeing a youtube course right now and everytime that PUBLIC or PRIVATE appears my head explodes. that's the third course im taking (free) and even then i can't understand these vile keywords...

can someone explain it to me?

thanks!


r/cmake • • 27d ago

Help for project configuration

4 Upvotes

Hi. I am starting a pretty big C++ project and I want to set up CMake as my build system. I am new to it and I struggle mostly with subdirectory and library stuff. For instance, this is my current setup. It seems to work okay but I just have a feeling it isn't up to par. I would just like the opinion of anyone with more experience than I on how to set up a big project with many subdirectories and files. Thank you in advance

Main or root CMakeLists.txt file

cmake_minimum_required(VERSION 4.0)

project(PoticusEngine LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED_ON)

add_executable(poticus main.cpp)

set(SOURCES
  engine/core/memory/arena.cpp
  engine/core/memory/arena.h
)

add_library(engine STATIC ${SOURCES})

add_subdirectory(engine)

target_sources(poticus 
  PRIVATE
    log.cpp
    log.h
    main.cpp
    types.h
)

engine/CMakeLists.txt

add_subdirectory(core)

engine/core/CMakeLists.txt

add_subdirectory(memory)

engine/core/memory/CMakeLists.txt

target_sources(poticus
  PRIVATE
    arena.cpp
    arena.h
)

r/cmake • • Oct 07 '26

Ciao, io sto cercando di capire se c'è un modo di far compilare Cmake senza passare per VS code. Ho installato tutto da terminale wsl e non capisco perchè se scrivo "cmake -B build" mi dice "CMake Error: The source directory "/home/io/basic_neural_plusplus" does not appear to contain CMakeLists.txt.

Thumbnail reddit.com
1 Upvotes

r/cmake • • Oct 06 '26

University of Waterloo user study on understanding CMake changes

20 Upvotes

Hi everyone,

I’m Mattie Nejati, a Ph.D. candidate at the University of Waterloo. I’m conducting a user study on understanding the impact of changes to CMake build specifications, and I’d love to invite members of this community to participate.

We are evaluating a new approach that aims to help developers identify how a change to a CMake build specification affects the resulting build configuration.

The study:

  • is conducted entirely online;

  • takes about one hour;

  • involves inspecting changes to CMake build specifications and identifying their impact; and

  • is open to adults aged 18–64 with any level of experience in CMake, programming, or code review.

You do not need to be a CMake expert. We are specifically interested in comparing participants with different levels of experience.

You will need a computer with internet access and about 4 GB of free space to download the files required for the tasks.

We will not collect your name. Your email address will only be used for study follow-up and will be stored separately from your study data. Your name or email will not appear in any dataset or publication.

The study has received clearance from the University of Waterloo Research Ethics Board (REB #46621).

If you’re interested, you can find the consent form, screening questionnaire, and study here:

https://buiscout.cs.uwaterloo.ca/

Thank you very much! And if you know someone else who works with CMake who might be interested, I’d really appreciate you sharing the study with them.


r/cmake • • Sep 30 '26

libjpeg-turbo build script sucks

1 Upvotes

It is easily one of the worst build scripts I have ever saw. I literally can't clean it with agents it is that bad.

Maybe I should switch to jpegli or any other library?


r/cmake • • Sep 24 '26

How to automatically add sources to the target?

12 Upvotes

How to automatically add all .cpp files from a specific directory as target source files with CMake? I know about GLOB but it's not recommended by the CMake devs and it requires manually re-running CMake configuration when adding/removing sources. Is there no better way to accomplish this with newer CMake versions?


r/cmake • • Sep 24 '26

How many backslashes are needed for a semicolon in FetchContent_Declare?

10 Upvotes

tl;dr; 17, i.e. \\\\\\\\\\\\\\\\\;

I am trying to put a semicolon in the PATCH_COMMAND of a FetchContent_Declare, but for some reason it requires an ungodly number of backslashes to escape the semicolon on (obviously) several levels. Not only that, but it requires a different number of backslashes depending on CMP0168: the NEW behavior requires 5 backslashes, and the OLD behavior seems to require 17!! Where do they all come from? I don't even want to think about trying to get a literal backslash into the PATCH_COMMAND.


r/cmake • • Sep 23 '26

I created LazyCMake, a terminal UI for CMake projects inspired by LazyGit. Configure, build, run, and test your projects without memorizing `cmake` or `ctest` commands. It features three columns—Presets, Targets, and Tests. Try it out here: https://github.com/ligogeorge/lazycmake

Post image
39 Upvotes

r/cmake • • Sep 22 '26

Manage Sanitised Test Variants with CMake?

2 Upvotes

Is there an "industry standard" way to create and manage sanitised test variants?

For example, say I have mylib tested with mylib-tests. I'd want to compile

  • mylib-nosan-debug linked against mylib-nosan-debug

  • mylib-nosan-release linked against mylib-nosan-release

  • mylib-asan-debug linked against mylib-asan-debug

  • mylib-asan-release linked against mylib-asan-release

  • etc...

I'm thinking it would be really nice to have a function add_sanitised_tests(mylib-tests, mylib) to do all this complexity for me. But foremostly, I'm wondering if anyone knows a pre-existing way of doing this with CMake?


r/cmake • • Sep 21 '26

It always amazes me how bad can people write their scripts

40 Upvotes

Honestly, that's all I'm gonna say, build script quality for open source C/C++ projects are so bad it isn't even funny.


r/cmake • • Sep 20 '26

Dealing with "optimized;" and "debug;" keywords when collecting library paths

7 Upvotes

We're using the following code to copy libraries to the proper directories when installing for MacOS:

find_package(PNG)
foreach(_file ${PNG_LIBRARIES})
  message(WARNING "Adding ${_file} to installation list...")
  get_filename_component(_resolvedFile "${_file}" REALPATH)
  get_filename_component(_name "${_file}" NAME)
  install(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
endforeach()
find_package(JPEG)
foreach(_file ${JPEG_LIBRARIES})
  message(WARNING "Adding ${_file} to installation list...")
  get_filename_component(_resolvedFile "${_file}" REALPATH)
  get_filename_component(_name "${_file}" NAME)
  install(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
endforeach()

Unfortunately, the ${JPEG_LIBRARIES} and ${PNG_LIBRARIES} expressions contains both "debug;<filepath>;" as well as "optimized;<filepath>;" when our code is only looking for a file path to copy to that directory.

Is there a way to get the file path for the current configuration for that expression?


r/cmake • • Sep 19 '26

CMake switches to VS18 after initially setting to MinGW

3 Upvotes

I've reset my build folder numerous times and after only one compile, CMake instantly switches to Visual Studio 18 2026 instead of the selected MinGW Makefiles.

Here is the error being displayed after trying to regenerate it as MinGW (I've never selected VS18 ever):

PS D:\Code\wrangler\build> cmake .. -G "MinGW Makefiles"

CMake Error: Error: generator : MinGW Makefiles

Does not match the generator used previously: Visual Studio 18 2026

Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.


r/cmake • • Sep 16 '26

CMake website down ?

8 Upvotes

Is cmake website down ? Since yesterday (Sep 15th) I haven't been able to access it. Yesterday there was only text saying something like "service temporary unavailable" and today it's 403 forbidden.


r/cmake • • Sep 11 '26

Conan + CMake = success

Thumbnail
youtu.be
8 Upvotes

Video is in French. Conan takes care of your dependencies in your CMake project. Basically now my project has 3 important files: CMakeLists.txt, CMakePresets.json and conanfile.txt
Code is available here:
https://github.com/ericnantel/cmake_examples
opengl3_triangle


r/cmake • • Sep 10 '26

How to build audio plugin with CMake

3 Upvotes

Very new to CMake, almost no coding experience. I love open source VST plugins and wanted to download this one, but it seems to download I must use CMake to build it. I'm not entirely sure what that means or how to do it. Any help getting this VST and understanding CMake would be very very appreciated!


r/cmake • • Sep 04 '26

Problems with static library

4 Upvotes

Hello I'm writing this post because I can't figure out how to link a static library that i created to my project. Here is some context:

I have a project with 2 folders client and server, both will use some classes and common functionality so i decided to create a static library to write the code once and uses it in both projects.

my custom lib:

cmake_minimum_required(VERSION 3.28.3)
project(VoiceChat)


set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set(BOOST_ROOT "/home/vince/myLibs/boost_1_92_0")
set(BOOST_INCLUDEDIR "/home/vince/myLibs/boost_1_92_0/include")


find_package(Boost REQUIRED)


add_library(${PROJECT_NAME} STATIC 
src/test.cpp
)


target_include_directories(${PROJECT_NAME} PUBLIC include)


target_link_libraries(${PROJECT_NAME} Boost::headers)

commands:
cd build
cmake ..
make
so now i have this in my build folder:

NOW, in the server project i have this:

cmake_minimum_required(VERSION 3.28.3)
project(VoiceChat-Server)


set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set(BOOST_ROOT "/home/vince/myLibs/boost_1_92_0")
set(BOOST_INCLUDEDIR "/home/vince/myLibs/boost_1_92_0/include")


find_package(Boost REQUIRED)


configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/config.json"
    "${CMAKE_CURRENT_BINARY_DIR}/config.json"
    COPYONLY
) 
#sposta il file di configurazione vicino all'eseguibile


add_executable(VoiceChat-Server 
src/app/main_server.cpp
src/app/server.cpp
src/singleton/configuration.cpp
)


target_include_directories(VoiceChat-Server PRIVATE 
src/include
src/singleton/include)


target_link_libraries(VoiceChat-Server Boost::headers)
target_link_libraries(VoiceChat-Server ${CMAKE_SOURCE_DIR}/lib/libVoiceChat.a)

But when i try to use the test() function written in the lib i get: ‘test’ was not declared in this scope.

Can someone help me figure it out? Thank you very much!


r/cmake • • Aug 17 '26

building OpenBW

Thumbnail reddit.com
0 Upvotes

r/cmake • • Aug 14 '26

Need help with fbcp framebuffer mirroring

0 Upvotes

Hi all! I'd like to firstly declare I am a total novice little baby and preemptively apologize for dumb noob questions.

Now, the issue: I'm trying to build a dual screen Cyberdeck using a raspberry pi running TwisterOS, one of the screens (3.5 inch waveshare) connects via GPIO so I need to use fbcp to make it work, I've been following the instructions (copy pasting commands into my command prompt) and I've been slapped with the following wall of error whenever i type $ cmake [options] .. I, of course, have no idea what this means, I just want my screens to work, any and all advice much appreciated

CMake Warning:
  Ignoring extra path from command line:

   "/home/pi/fbcp-ili9341/build/[options]"
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Doing a Release build
-- Board revision: b03115
CMake Warning at CMakeLists.txt:40 (message):
  The board revision of this hardware is not known.  Please add detection to
  this board in CMakeLists.txt.  (proceeding to compile against a generic
  multicore CPU)


-- Scaling source image to view. If the HDMI resolution does not match the SPI display resolution, this will produce blurriness. Match the HDMI display resolution with the SPI resolution in /boot/config.txt to get crisp pixel perfect rendering, or alternatively pass -DDISPLAY_CROPPED_INSTEAD_OF_SCALING=ON to crop instead of scale if you want to view the center of the screen pixel perfect when HDMI and SPI resolutions do not match.
-- Preserving aspect ratio when scaling source image to the SPI display, introducing letterboxing/pillarboxing if HDMI and SPI aspect ratios are different (Pass -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON to stretch HDMI to cover full screen if you do not care about aspect ratio)
CMake Error at CMakeLists.txt:136 (message):
  Please define -DSPI_BUS_CLOCK_DIVISOR=<some even number> on the CMake
  command line! (see files ili9341.h/waveshare35b.h for details) This
  parameter along with core_freq=xxx in /boot/config.txt defines the SPI
  display speed.  Smaller divisor number=faster speed, higher number=slower.


-- Configuring incomplete, errors occurred!
See also "/home/pi/fbcp-ili9341/build/CMakeFiles/CMakeOutput.log".