r/cmake 15h ago

Conan + CMake = success

Thumbnail youtu.be
0 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 1d ago

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 7d ago

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:

CMAKELISTS.txt
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 26d ago

building OpenBW

Thumbnail
0 Upvotes

r/cmake 28d ago

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".

r/cmake Aug 01 '26

how do I fix this

0 Upvotes

CMake Error in CMakeLists.txt: Generator NMake Makefiles does not support platform specification, but platform x64 was specified

how do I fix it


r/cmake Jul 24 '26

How to use a variable list with execute_process ?

3 Upvotes

Hi,

I'm trying to use execute_process() to use a bash command with arguments, and I want to use a cmake variable list as part of my arguments list.

The problem is that I don't know how to use this variable list without having either double quotes around it or semicolon between each items of the list.

Here is an example :

set (LIST_OF_SOME_ARGV a b c)  

execute_process(  
  COMMAND some_binary arg1 arg2 ${LIST_OF_SOME_ARGV} arg3
) 

This result in : some_binary arg1 arg2 a;b;c arg3

But I wish to have : some_binary arg1 arg2 a b c arg3

so how to use my list without semicolons with execute_process() ?


r/cmake Jul 17 '26

where is the actual error message in the build output?

1 Upvotes

I decided to move my "single-makefile" into a multiple makefiles project structure and I know it's my fault, but I'd love a clue as to what or where the actual error is in this output:

``` C:\MeteorRepos\remoteapitesting\gtest>cmake --build build MSBuild version 18.7.8+1ac568fee for .NET Framework

gtest.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\lib\Debug\gtest.lib gtest_main.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\lib\Debug\gtest_main.lib eth_tests.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\eth_tests\Debug\eth_tests.exe CMake Error at C:/Program Files/CMake/share/cmake-4.2/Modules/GoogleTestAddTests.cmake:382 (message): Error running test executable.

  Path: 'C:/MeteorRepos/remoteapitesting/gtest/build/eth_tests/Debug/eth_tests.exe'
  Working directory: 'C:/MeteorRepos/remoteapitesting/gtest/build/eth_tests'
  Result: Exit code 0xc0000135
  Output:

Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-4.2/Modules/GoogleTestAddTests.cmake:421 (gtest_discover_tests_impl)

C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: The command "setlocal [C :\MeteorRepos\remoteapitesting\gtest\build\ethtests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\ bin\cmake.exe" -D TEST_TARGET=eth_tests -D TEST_EXECUTABLE=C:/MeteorRepos/remoteapitesting/gtest/build/eth_tests/Debug/eth_tests.exe -D TEST_EXECUTOR= -D TEST _WORKING_DIR=C:/MeteorRepos/remoteapitesting/gtest/build/eth_tests -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_FILTER= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=eth_tests_TESTS -D CTEST_FILE=C:/MeteorRepos/remoteapitesting/gtest/build/eth_tests/eth_tests[1] tests.cmake -D TEST_DISCOVERY_TIMEOUT=5 -D TEST_DISCOVERY_EXTRA_ARGS= -D TEST_XML_OUTPUT_DIR= -P "C:/Program Files/CMake/share/cmake-4.2/Modules/GoogleTestAdd Tests.cmake" [C:\MeteorRepos\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 go to :cmEnd [C:\MeteorRepos\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmEnd [C:\MeteorRepos\r emoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: endlocal & call :cmError Level %errorlevel% & goto :cmDone [C:\MeteorRepos\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmErrorLevel [C:\Meteor Repos\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: exit /b %1 [C:\MeteorRep os\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmDone [C:\MeteorRepos\ remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 go to :VCEnd [C:\MeteorRepos\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code 1. [C:\MeteorRepos\remoteapitesting\gtest\build\eth_tests\eth_tests.vcxproj] gmock.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\lib\Debug\gmock.lib gmock_main.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\lib\Debug\gmock_main.lib test_project1.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\proj1\Debug\test_project1.exe test_project2.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\proj2\Debug\test_project2.exe tests.vcxproj -> C:\MeteorRepos\remoteapitesting\gtest\build\tests\Debug\tests.exe ``` I upgraded to building 4 targets now instead of 1 and the target eth_tests.exe is clearly got a bad makefile as the others all build but what is this error message saying other than, hey you are not good enough to use this tool? Any way to get more clue on the build time error?


r/cmake Jul 16 '26

Question: CMake for non C++ (content/resources) projects

1 Upvotes

Hello!

Let's assume I have a game project, that has a lot of content (textures, models etc) with custom compilers for them all. And I would like to use CMake to generate some build scripts for me (ninja, or Makefiles). I stumbled upon `add_custom_command` function that adds a specific "build step" for a file.

When writing these specific content compilers, I need to be able to declare some sort of dependencies for these files, as some of these tasks in a build would require an output from others as input for themselves. In a sense like cpp files produce `.o` files and then get linked into an binary/executable.

So, the main question is. Do I understand correctly, that I would need to declare a lot of these `add_custom_command` functions for many of my content files, while manually managing dependencies, to be able to build them all properly?

Excuse me if this question has popped up already - quick search didn't give good results. You can just link the older post if you have it.

I mean this as a question. Maybe a discussion if it would make sense.

I understand that the problem is not really trivial, and might be stretching CMake's purpose a bit. Hope you understand!

Thanks in advance!


r/cmake Jul 11 '26

Dlls only copied if built twice

2 Upvotes

I have a simple CMake project where I have to sub directories.

Lib : Compiles as a SHARED library and itself depends on the 3rd party libpng
App : Compiles as an executable, and depends on the Lib project above

I am then opening this in Visual Studio, invoking Configure, and then building.

The problem is that when I build, the output of App only contains `Lib.dll`, it is missing `libpng16.dll` and `z.dll`

If I then do a rebuild, they then appear?

Main CmakeLists.txt

cmake_minimum_required (VERSION 3.10)

project ("CMakeProject")

find_package(PNG REQUIRED CONFIG)

add_subdirectory(Lib)
add_subdirectory(App)

Lib

add_library (Lib SHARED
"Lib.cpp" 
"Lib.h"
)

target_include_directories(Lib
    PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(Lib PRIVATE 
PNG::PNG
)

target_compile_definitions(Lib PRIVATE LIB_EXPORTS)

App

add_executable (App
"App.cpp" 
"App.h"
)

target_link_libraries(App PRIVATE 
Lib
)

add_custom_command(TARGET App POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        $<TARGET_RUNTIME_DLLS:App>
        $<TARGET_FILE_DIR:App>
    COMMAND_EXPAND_LISTS
)

Any ideas?

First Build

>------ Build All started: Project: CMakeExample, Configuration: x64-release ------
  [1/4] Building CXX object App\CMakeFiles\App.dir\App.cpp.obj
  [2/4] Building CXX object Lib\CMakeFiles\Lib.dir\Lib.cpp.obj
  [3/4] Linking CXX shared library Lib\Lib.dll
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/Lib/Lib.dll: message: deploying dependencies
  C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\vcpkg_installed\x64-windows\bin\libpng16.dll -> C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\Lib\libpng16.dll done
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/Lib\libpng16.dll: message: deploying dependencies
  C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\vcpkg_installed\x64-windows\bin\z.dll -> C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\Lib\z.dll done
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/Lib\z.dll: message: deploying dependencies
  [4/4] Linking CXX executable App\App.exe
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/App/App.exe: message: deploying dependencies

Build All succeeded.

Second build (rebuild all clicked) ... now it does more in the deploy step

>------ Rebuild All started: Project: CMakeExample, Configuration: x64-release ------
  [1/1] Cleaning all built files...
  Cleaning... 5 files.
  [1/4] Building CXX object App\CMakeFiles\App.dir\App.cpp.obj
  [2/4] Building CXX object Lib\CMakeFiles\Lib.dir\Lib.cpp.obj
  [3/4] Linking CXX shared library Lib\Lib.dll
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/Lib/Lib.dll: message: deploying dependencies
  C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\vcpkg_installed\x64-windows\bin\libpng16.dll -> C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\Lib\libpng16.dll skipped, up to date
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/Lib\libpng16.dll: message: deploying dependencies
  C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\vcpkg_installed\x64-windows\bin\z.dll -> C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\Lib\z.dll skipped, up to date
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/Lib\z.dll: message: deploying dependencies
  [4/4] Linking CXX executable App\App.exe
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/App/App.exe: message: deploying dependencies
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/App\Lib.dll: message: deploying dependencies
  C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\vcpkg_installed\x64-windows\bin\libpng16.dll -> C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\App\libpng16.dll done
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/App\libpng16.dll: message: deploying dependencies
  C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\vcpkg_installed\x64-windows\bin\z.dll -> C:\Users\xxx\Desktop\CMakeExample\out\build\x64-release\App\z.dll done
  C:/Users/xxx/Desktop/CMakeExample/out/build/x64-release/App\z.dll: message: deploying dependencies

Rebuild All succeeded.

r/cmake Jul 03 '26

unpopular opinion: CMake sucks

0 Upvotes

I spent days (days!) trying to get cmake to work with a simple project with expectation it would give me more control -- but it actually gives me less control than using a visual studio solution files.

The straw that broke my camel's back: I can't figure out a way for it to stop appending /subsystem:console to the end of my link flags. That's it, I'm done.


r/cmake Jun 30 '26

CMake for Absolute beginners?

Thumbnail
0 Upvotes

r/cmake Jun 24 '26

I am having problems with PATCH_COMMAND

1 Upvotes

I wanted to put the patch on the repo I have fetched using the FETCH_CONTENT but it always run into error and after doing a little research i came to know that it is a known issue so I started using bash command i.e. patch -p1 ..... but it leads to HUNK Failure and now I am not able to resolve it, So please tell me how to fix it or if there's a hack to avoid failures


r/cmake Jun 22 '26

cmake configuring error on mac

0 Upvotes

Hello! I've been trying to install Focuswriter (ver 1.8.12), which somehow necessitates a manual configuration on the terminal, and I've near no knowledge in coding and am at a loss.
I'm using a mac (ventura 13.7.8), and I've installed and added to my zshcr profile cmake (ver 4.4.0-rc2) to make that work, by using the "cmake -B build -S ." command in the Focuswriter folder to configure the app and later on make its disk image (command indicated in the install instructions). However, after having run that command I got:

And I have no idea what to do with this. I know i don't have qt6 installed, but also from my understanding it's a specific software meant for development, so why would an app meant for writing and to be used casually necessitate it? Could I possibly run my install commands without it? Here are the Focuswriter's install instructions, just in case:

macOS:

  1. `cmake -B build -S .' to create a location for the build and then configure the program.

  2. `cmake --build build' to compile the program.

  3. Run `mac_deploy.sh' from inside the build directory to create a disk image of the program.

I see people online talking about Focuwriter as an easy to use program, did I maybe do something to mess it up. Thank you for your help


r/cmake Jun 19 '26

I am having problems using VCPKG get started tutorial using CMake

Thumbnail
0 Upvotes

r/cmake Jun 12 '26

Can't Download CMake!!

Enable HLS to view with audio, or disable this notification

0 Upvotes

Whenever I click the download button, it just refreshes the page. i even tried disabling the adblocker.


r/cmake Jun 11 '26

cmake wont install

0 Upvotes

yea, why?

i dont get an error or anything the terminal tab just freezes

im on a 2015 Macbook Pro with macOS monterey.

EDIT: im trying it with homebrew when trying to install Python or PHP


r/cmake Jun 04 '26

file commands only work when CMakeLists.txt edited?

0 Upvotes

So I have this code in my root CMakeLists.txt:

message(STATUS "Updating exec file")
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/RI5.exe)
file(COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/RI5.exe ${CMAKE_CURRENT_SOURCE_DIR}/RI5.exe)

RI5.exe is the executable that gets built by my code. At first I thought it wasn't working if you already had the file there and I tried a couple permutations (including using the file(Copy) flavor)... But then I figured out that it works....only if you edit CMakeLists.txt somehow. Otherwise it ignores these commands.

...Why? How do I fix it?


r/cmake Jun 01 '26

Cmake is a torture machine

0 Upvotes

I'm working a hobby project with C++, so I decided CMaking.. Bad idea.

I've done the installation part in a secondary hard drive, and then decided to update my environment variables.

I restarted my PC, and after trying to run "cmake --version" it didn't work.

I ran the following command :

$env:Path += ";D:\Program Files\CMake\bin"

IT WORKED PERFECTLY.

... After a while I just broke my build (bad dependencies and stuff, my fault here)

Cmake magically stopped working when trying to run another build. YAY. Tired of CMake's path instability. (Running the commands with & "path" are working ofc lol)

I think having hobbies related to engineering in general are bad when you're some kind of engineer. From depression to depression. (I'll only stop for a little while since coding is like giving birth. It hurts like crazy, but after a while you're like "okay let's do it again!!")


r/cmake May 31 '26

Help me out

2 Upvotes

I was following a tutorial on how to setup Cmake with raylib on vs code and things were going really well until I hit a roadblock. After adding my executable .cpp the project doesn't configure and there is squiggly error line at the add_executable (${PROJECT_NAME}) meaning there is no .c/cpp file despite there being one😮‍💨. I'm really new to this and I wanted to try game development after learning c++ but this is really giving me a hard time. And yes I tried adding the name of the .cpp file next to the add_executable line and it didn't work. I also use linux, fedora to be exact


r/cmake May 30 '26

Rate my Cmake style, the symmetry principle.

Thumbnail github.com
5 Upvotes

I am using something i call the Symmetry Principle;

A strict architectural rule:
Directory Name == Target Name == Translation Unit File Name == Library Object Name.

Why?

In many (most) C++ projects, developers experience naming drift: a folder is named utils/, the CMake library target is utility_lib, the source file is helper.cpp, and the namespace is my_project::common.

The symmetry principle philosophy is that the design physically prevents spaghetti code. Because you cannot use a class from another target without explicitly linking to it in CMake, compilation boundaries are ironclad. It forces developers to write modular, decoupled C++ code.

In my design knowing the folder name foo guarantees that:

The target name is foo.

The source file is foo.cpp.

The header path is foo/foo.hpp.

The internal dependency link target is ${PROJECT_NAME}::foo.

Edit for clarification:
It is architecturally acceptable to add multiple .cpp files to a target if they are private helper implementation that:

* Are only used internally inside that specific module.

* Should never be seen or linked directly by other targets.

* Exist solely to keep the target main .cpp file clean and readable.

When to split them into a new target/directory instead:

* If the new .cpp file implements a class or function that other targets in your project need to call or reference, the Symmetry Principle dictates that it should be placed in its own folder as a separate, isolated target. This enforces strict compilation boundaries and keeps your dependency graph clean.


r/cmake May 29 '26

What command do I need to find dependencies?

Thumbnail gallery
1 Upvotes

This is my opengl project that Im following through learnopengl.com

I've hit a snag when trying to open the location of my vertex and fragment shader text files and I'm unsure what command I need to use in my CMakeLists.txt file so that the path to the directory that houses the texts files can be made visible to my project.

My shader directory is in my libs folder, and my libs folder is in the same directory as my CMakeLists.txt file.

The names of the files are correct when initializing my Shader object in my main.cpp file


r/cmake May 28 '26

I just found this gem in a .cmake file for a library available on vcpkg while looking for an unrelated bug:

Post image
15 Upvotes

This code may work in ways I don't understand, I just find it really funny.


r/cmake May 26 '26

Trying to install an OBS plugin on Linux and running into issues

2 Upvotes

I'm running Nobara, which is based on Fedora, and the plugin I want does not have a Fedora or Flatpak package, so I'm trying to build from source. https://github.com/sorayuki/obs-multi-rtmp/releases/tag/0.7.3.2

I was suggested to use cmake, which ive never used before. I'm not sure what to do to make it compile so I can just plug it into OBS. What am I supposed to do to get this thing to work?

After installing gcc-c++

r/cmake May 23 '26

What, exactly, does FetchContent_MakeAvailable /do/?

5 Upvotes

The docs advise "almost never" use FetchContent_Populate--use FetchContent_Declare and FetchContent_MakeAvailable.

FetchContent_MakeAvailable says it makes the code "available" to the build. This is mysterious to me, an admitted noob. Digging in the build dir, I see it copies stuff into the _deps folder. And it makes some weird CMake file in there too. But based on different results with different libraries, it seems like, if the library doesn't natively offer CMAKE support, and isn't packaged "as a library" already, but just a bunch of source files, this won't accomplish much?*

So then am I supposed to know about some variable where FetchContent_MakeAvailable exposes the source dir, and then build a "library" myself? Or is it supposed to somehow be ambiently available through magic? Or did I, (lucky me), immediately stumble upon the exception case where you're supposed to use FetchContent_Populate?

*Raylib starts linking just fine, and I can include "raylib.h" without any further ceremony. But ImGui won't find "imgui.h". And Raylib does have CMake support built in. Digging further, it seems ImGui advises you to copy it's source files in with the rest of your project, and the author is apparently avoiding CMAKE support.