Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Bigger cmake builds are doing dependency resolution,

find_package(foo)

#...

target_link_libraries(myapp foo::Static)

> configuration tests,

I don't know what you mean by configuration tests. I don't think I ever added any test resembling that description other than sanity checks in cmake find modules and sanity checks on projects just for convenience.

> and configuration for development or release builds

Those are not handled by cmake other than setting a flag that's used in the code.

> /installs.

You don't need to do anything other than setting the install target.

https://cmake.org/cmake/help/latest/command/install.html

I think you're either wildly exaggerating or you've been creating your own problems.



Ok. How does find_package work? Hint: you need to understand how cmake module paths are discovered and their precedence, and you'll probably see a cmake folder in a build with the actual logic behind it as a .cmake file for each dependency. Depending on what package manager you're using you may not need this, or if you support many you'll need to own it.

> I don't know what you mean by configuration tests.

When you run cmake -S <my project> -B build folder you'll see a bunch of output. What this output corresponds to may include a number of tests that either succeed or fail to indicate whether the project will build. For example, the aforementioned find_package logic, finding the compiler tool chain (especially if cross compiling), testing for random shit like endianness, etc.

> Those are not handled by cmake other than setting a flag that's used in the code.

    if(STREQ ${CMAKE_BUILD_TYPE} Release)
        ....
    endif()
Is ridiculously common with the "..." filled in by various things like setting optimization flags, paths within the build directory, etc

> You don't need to do anything other than setting the install target.

No but you should probably understand what RPATH is and why it's set in release builds but not installed artifacts or why doing something that seems obvious like checking the checksum of your built object is the same as the installed one might fail.

The point is that cmake does a lot of work and it's not just declaring targets. Builds are hard.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: