Relative Content

Tag Archive for cmake

How to unit test spagheti code

A little background on the project: we as a company receive a spaghetti source code, and into that we add even more spaghetti code. So with that I want to say that complete restructuring the code and un-spaghettifing it is not really possible, and we also do not have any say in what the other company deliveries, we just have to deal with what we have.
It is a C/C++11 code with CMake. I chose Google test framework (but I can still change it).

How to compile the source code on GitHub into the files they release?

I’m sorry, I am a complete beginner. I made some changes to the source code of the GP2040-CE project (using ChatGPT), and now I’m trying to compile it into software for my device (a uf2 file as their releases). I’ve tried my best to search for information, but I just can’t seem to get it done. Please help me out.
Project URL:https://github.com/OpenStickCommunity/GP2040-CE

How can I get information about CMAKE project without running the compiler checks?

I am writing a script that will compile a few hundred applications using CMAKE. These applications use various compilers for embedded systems and each has it’s own build instructions. Usually we use compilers on shared network drive, but in order to speed things up I want to check which compiler should be used, cache it locally and override compiler settings via command line.

How to conditionally set compile definitions in cmake

if(“$<CONFIG:Debug>”) target_compile_definitions(Geodesic-RayTracer PRIVATE TESTING_ENABLED) endif() #target_compile_definitions(Geodesic-RayTracer PRIVATE TESTING_ENABLED) I have the above in my CMakeLists.txt for my project. If I uncomment the line below endif() my code has TESTING_ENABLED set. So I know that part is correct. However I only want to set it on Debug builds. The C++ pattern I’m trying to follow looks […]

How to find “link-name” of a library after it’s built with cmake?

I’m building a C++ project with CMakeLists.txt, that depends on some library, which is built in the build-process. I’ve used:
add_subdirectory(/path/to/some_lib)
that contains another CMakeLists.txt, that builds that library. In order to link I call:
target_link_libraries(${target} some_lib_name)
My question is:
how am I supposed to know what “some_lib_name” to use in target_link_libraries?

Test and compiler output

I would like to capture the output of CMake testing. Using Xcode, one can find a file named LastTest which includes most of what I want. But it seems to not include build/link failures. If a test fails to compile, nothing at all appears in the LastTest file.

CMake targets are not exported before add_subdirectory is called

I have an app, an interface library and plugins.
I define the targets in the main lists file.
Plugins are included using add_subdirectory(plugins).
I want plugins to be able to use find_package in the build and install tree.
I exported targets like this

Breaking long lines in CMakeLists.txt

I’ve seen a couple of posts suggesting that it’s possible to use to break long lines in CMakeLists.txt. But in my world it appears not to be true. Here’s my CMakeLists.txt: