simoninns / DomesdayDuplicator

High-speed LaserDisc RF sampler
GNU General Public License v3.0
138 stars 21 forks source link

Cmake build files #121

Closed oyvindln closed 1 year ago

oyvindln commented 1 year ago

Add cmake build files for easier setup on non-ubuntu

findlibusb borrowed from https://github.com/OpenKinect/libfreenect2 - there are other variants out there too so not sure what is most up to date, and whether that file has some specific license different from the project.

mostly generated with qmake2cmake, though tweaked the linux-apllication to use a find script rather than the existing manual library linking to increase flexibility.

Will look at ld-decode tools next, though that will be more complex as there are multiple binaries.

oyvindln commented 1 year ago

Also needs testing on windows May want to look into automatic dependency downloading/integration with vcpkg or similar down the line

atsampson commented 1 year ago

A few thoughts after testing...

It would be good to have a top-level CMakeLists.txt in the Linux-Application directory, so you can build all the tools at once - that would simplify the build instructions too. (I've added this for qmake in #118.)

libusb-1.0 has always included a pkg-config file, so there's no need for FindLibUSB.cmake - just use PKG_CHECK_MODULES directly from CMakeLists.txt.

You need include(FindPkgConfig) somewhere - at present the pkg-config code doesn't get used at all (and the fallback code fails on my Linux system because it's not looking in the system path).

Can we prefer Qt 6 over Qt 5 if available? Given that Qt 5 is no longer maintained upstream, I'd rather have people using Qt 6 when they can.

oyvindln commented 1 year ago

Yeah would have to look into how to best handle a top-level thing.

Not sure how well using pkg-config works on windows, using FIndxxx seems to be the standard way of doing this for cmake (which often uses pkg-config for hints underneath), and it makes it easy to provide the paths in e.g cmake-gui oneself if you are e.g on windows and have a manually downloaded libusb.

The FindLibUSB.cmake module is supposed to be able to use pkg-config if available. Is it findlibUSB failing for you or did you refer to something else? It might need some work/updates.

It defaulted to using Qt6 on my system, so I presume it goes with the highest found version.

EDIT: Seems the wiki page is a bit outdated though, need to read up on how it's supposed to be best handled in modern cmake.

atsampson commented 1 year ago

Here's a branch with some fixes to the above. You may or may not want to take the third change - it depends whether you want it to be one big project with subdirs, or three separate projects (I'd lean towards the former, but people who use IDEs may prefer the latter?).

At present it can only work with Qt 6 - the Qt 5 CMake stuff has some differences, e.g. no qt_add_executable.

atsampson commented 1 year ago

Pushed a couple more commits to that branch - now it works with Qt 5, and should in theory work with 5.12 on the oldest version of Ubuntu we support. It might be worth adding the GitHub CI stuff at the same time?

I note that "make clean" doesn't work properly - it doesn't delete the Qt generated files.

oyvindln commented 1 year ago

Yeah looks good. Not sure why qmake2cmake uses qt_add_executable even when specifying min version as qt 5 something so guess it's a bit buggy still.

Not sure what would cause make clean issues, maybe due to multiple targets? Should not be a big deal anyhow and can be made cleaner by suggesting out-of-tree build, e.g in a build subdirectory.

atsampson commented 1 year ago

I've added the CI file to that branch, and fixed up the Qt 5 compatibility so it works with 5.12 now. The CI passes for Qt 5.12 on Ubuntu 20.04 and Qt 6.2 on Ubuntu 22.04.