-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fresh CMakeLists.txt #2912
base: master
Are you sure you want to change the base?
Fresh CMakeLists.txt #2912
Conversation
…f there is a more modern way of doing this.
- fix some weird thing in pybind11 CMakeLists.txt file - update setup.py script
- fixing actions
2 problems:
|
So added the missing BLAS files in external/blas. I didn't know there was a difference between cblas and blas. I have no idea how this was working before. We would have got errors like: "undefined reference to dgemm_" in file cblas_dgemm.c Otherwise, I think the FindBLAS module in cmake is broken. Shame. It doesn't always detect perfectly valid BLAS libraries. So I'll quickly write a custom one tomorrow (steal quite a bit from dlib's old file) Otherwise, the Python tests are failing in test_global_optimization.py |
The problem with test_global_optimization.py is So I'm not sure how:
in test_global_optimization.py is supposed to work with I've replaced a couple |
…time you hit this, the program will abort
… an issue on windows build - only enable BLAS if either a valid BLAS library is found or fortran is enabled - correctly set DLIB_DISABLE_ASSERTS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a bit confusing. It used to, though. The dependency was removed in #2273.
I've looked at some online tutorials on how to write cmake Config files for installable targets. It's crazy how complicated it is. It's laughable. There should be a better tool. I'm surprised there isn't a repo with some cmake helper scripts out there that figure out how to package a target. |
What's currently there doesn't work? I mean it works on master. But you are finding that something about the new cmake setup breaks it I guess? The current thing is fairly simple 🤷♂️ |
Yeah if you look at the GitHub Action Runners, you'll see I've added one which demonstrates what I see. It builds and installs dlib then builds one of the examples using the installed version of dlib, i.e using find_package(dlib) |
It's because we are using imported targets now, not XXX_LINK_LIBRARIES and XXX_INCLUDE_DIRECTORIES |
pkg-config is broken too since it uses the old |
Right, made some progress, while reading https://cmake.org/cmake/help/latest/command/install.html#export, I found the
to the generated So I think any custom cmake modules, like Also i need to add Again, this isn't a problem on master, since it doesn't use imported targets, just plain old compile options and linker flags. Unless someone can come up with a better option. I don't really like how we now have to maintain two lists of dependencies, one using Is Cmake really this bad? |
https://buildmedia.readthedocs.org/media/pdf/bcm/stable/bcm.pdf |
I have a working solution but now |
I've added a test to CI/CD which attempts to build an example using pkg-config. So this needs fixing.
My opinion now is cmake is a pile of ***t EDIT: |
Well, every year "modern cmake" is different. Which is fine. The only big change to cmake that I really think of as "the modern one" was when you started to be able to do I mean there are other things too. But the other big one is different platforms and their related tools keep changing so older versions of cmake accumulate a bunch of magic in user cmake scripts to deal with that stuff. And those things eventually get folded into cmake proper and everyone goes "see, new cmake is simple, you don't need that stuff!". But that is a never ending battle since other people keep screwing up/changing/over-complicating/whatevering their systems and tools in new and never ending ways. Anyway, do you mean that stuff like |
# =================================================================================== | ||
# The dlib CMake configuration file | ||
# | ||
# ** File generated automatically, do not modify ** | ||
# | ||
# Usage from an external project: | ||
# In your CMakeLists.txt, add these lines: | ||
# | ||
# find_package(dlib REQUIRED) | ||
# target_link_libraries(MY_TARGET_NAME dlib::dlib) | ||
# | ||
# =================================================================================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally keep the instructions. People see this stuff and then go "oh right, I'll do that" rather than do a bunch of confusing hacks.
|
||
include(CMakeFindDependencyMacro) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's screwy that these deps are repeated but it's simple so it's not the end of the world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just so dissatisfied with this. You would think cmake understands enough about a target that by the time you've built it it understands how to install it with one line of code.
Libraries like https://github.com/boost-cmake/bcm.git and https://github.com/robotology/ycm sort of provide this if you use their custom functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is annoying. It's also a bit of a regression compared to how it was before. But it's not a big deal at the end of the day, especially compared to how much other stuff is simpler so ¯_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though it doesn't fix dlib.pc
for pkg-config. That needs specific compile and linker options. It there was a magic cmake macro/function which took all your imported targets, generator expressions, and resolved everything down to concrete compile and linker options, then everything would be good. It must do this anyway since it has to generate make/ninja files. If there was a way to reuse those functions then it would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah you haven't figured out how to make it generate a dlib.pc
file yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sorry. I mean it generates it fine but it references libraries like blah::blah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll have to use something like file(GENERATE) as a hack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work.
Shame this can't make it into the release but until |
Yeah that's annoying. Thanks for trying it though. At some point cmake will presumably make this possible. I'm also not super sure how popular pkg-config is. I don't use it, but I get asked about it often enough and before this stuff was in dlib there were complaints about it. So maybe popular? It's hard to tell the difference between a loud tiny minority and a bigger thing sometimes. Maybe not enough people care about pkg-config anymore for cmake to support this in a reasonable way? |
What's nice about pkg-config is that it's portable. Multiple IDEs can us it (Eclipse, Netbeans), other c++ builders like Meson support it. But yeah, cmake is making it hard. |
Heh, yeah, that face detector example is unreasonably popular 😅 |
I don't think it's unreasonable. Here we're complaining about how hard it is to make foolproof C++ builds, but it's still better than all the Honestly. I am always surprised about how many people have problems building dlib. I guess that a lot of the issues are caused by |
I don't know why people use |
Yeah, same here, I hate |
Yeah my experience with |
Pinching the code from https://bcm.readthedocs.io/en/latest/ might be the best bet. It looks really cool. |
Yeah but then that's one more dependency that gets out of date and needs
updating. Might as well just keep what dlib has then.
…On Wed, Mar 13, 2024 at 6:42 PM pfeatherstone ***@***.***> wrote:
Pinching the code from https://bcm.readthedocs.io/en/latest/ might be the
best bet. It looks really cool.
—
Reply to this email directly, view it on GitHub
<#2912 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPYFRZDYFB5PJCWRGJCQODYYDI4NAVCNFSM6AAAAABC4W44TWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWGAYTGNZZG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Like if we aren't putting the responsibility on the cmake team to handle
this stuff but just having cmake scripts in dlib's repo, what's the point?
Since that's already the state of how things are now.
…On Thu, Mar 14, 2024 at 8:12 AM Davis King ***@***.***> wrote:
Yeah but then that's one more dependency that gets out of date and needs
updating. Might as well just keep what dlib has then.
On Wed, Mar 13, 2024 at 6:42 PM pfeatherstone ***@***.***>
wrote:
> Pinching the code from https://bcm.readthedocs.io/en/latest/ might be
> the best bet. It looks really cool.
>
> —
> Reply to this email directly, view it on GitHub
> <#2912 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABPYFRZDYFB5PJCWRGJCQODYYDI4NAVCNFSM6AAAAABC4W44TWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWGAYTGNZZG4>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Cmake and pkg-config issue tracker |
It is sad to see this work not merged in. Dlib is a pain to package properly due to homegrown find modules that do not work for non standard configurations. |
Unfortunately if we want to maintain support for pkgconfig then we have to keep the current CMakeList.txt. |
This is an attempt at refactoring dlib's CMakeLists.txt files.
The objectives are:
target_
functionsfind_package()
FindCUDAToolkit
and others.