5 ms·
> But every time I have to set up a new project it feels like death by a thousand cuts Which part of the following example is hard: program(mynewproject LANGU
by simplotek 4y ago
> But every time I have to set up a new project it feels like death by a thousand cuts
Which part of the following example is hard:
program(mynewproject LANGUAGES CXX)
add_library(libfoo STATIC
foo.cpp
)
add_executable(bar
bar.cpp
main.cpp
)
target_link_libraries(bar
libfoo
)
Edit: and this message was downvoted? Seriously?
- lifthrasiir 4y agoYou completely ignored dependencies, which in my experience everyone seems to handle differently (and definitely not in a declarative way). Differently put: a phrase "metabuild system" has both a lexical sense and an idealized sense. The lexical sense would be something that generates an input to build systems. The idealized sense would be something that does everything else not possible or difficult in build systems. CMake was definitely far from that ideal [1]; it was often simpler to make a configure script in your favorite language (and, for god's sake, not in M4) than using CMake. [1] Was using a present tense but edited after realizing that I don't know much about recent changes to CMake. Still enough to justify my (and others') criticism.
- simplotek 4y ago> You completely ignored dependencies Not really. When people talk about setting up a new project, they talk about starting a hello world project and build up from there. Anyway, I'll bite. What would it take to add a dependency? If it exports a cmake config file which exports targets, all it takes is this: find_package(MyDependency), target_link_libraries(bar MyDependency::targetA MyDependency::targetB ... MyDependency::targetZ ) If it doesn't and it is instead a system library then you can even pass the library instead. add_library(bar systemlibrary ) If the library exports no cmake config and you have anything exotic you can put together your own cmake find modules, and proceed to follow step A. Alternatively, you can even bolt on something like Conan and just follow step A all the time. > Differently put: a phrase "metabuild system" has (...) Sorry, but do you actually have any concrete example of any difficulty setting up a C++ project?
- lifthrasiir 4y ago> When people talk about setting up a new project, they talk about starting a hello world project and build up from there. The original reply said one dabbled C++ via "creative coding, graphics programming, etc.", which definitely needs dependencies from the beginning. Can you draw a nicely shaded triangle only with the C++ standard library? > If the library exports no cmake config and you have anything exotic you can put together your own cmake find modules, and proceed to follow step A. They are not exotic, libraries without cmake config are common. So, as I've said before, people had to come up with their own find modules and this requires lots of trial and error to get it right. Guaranteed, it might have been possible to collect those into some sort of registry (a la DefinitelyTyped for TypeScript .d.ts files), and probably something like Conan can provide that, but ideally that should have been built into CMake. And keep in mind that Cargo---something we were comparing against back in time---does all of them declaratively. (Arguably, from users' perspective, it can handle C/C++ dependencies better than CMake!)
- simplotek 4y ago> The original reply said one dabbled C++ via "creative coding, graphics programming, etc.", which definitely needs dependencies from the beginning. Can you draw a nicely shaded triangle only with the C++ standard library? Taken straight from Qt's page on OpenGL support: find_package(Qt6 REQUIRED COMPONENTS OpenGL) target_link_libraries(mytarget PRIVATE Qt6::OpenGL) https://doc.qt.io/qt-6/qtopengl-index.html https://doc.qt.io/qt-6/qtopengl-index.html Do you feel this is too hard to setup?
- lifthrasiir 4y agoThat's because Qt 6 wholeheartedly converted to CMake for you. (At least it is better than qmake.) In order to support this Qt has this large battery of CMake files [1]. Qt is of course a clear outlier, but you can't expect the same level of support from every other library you want. My points about "anything exotic" still stand. [1] https://github.com/qt/qtbase/tree/dev/cmake https://github.com/qt/qtbase/tree/dev/cmake