Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  06 Jan 2025, Alexandr Kozlinskiy, Suggestion, improved find_package behaviour for Midas 
    Reply  09 Jan 2025, Stefan Ritt, Suggestion, improved find_package behaviour for Midas 
       Reply  20 Mar 2025, Konstantin Olchanski, Suggestion, improved find_package behaviour for Midas 
    Reply  20 Mar 2025, Konstantin Olchanski, Suggestion, improved find_package behaviour for Midas 
       Reply  21 Mar 2025, Alex Kozlinski, Suggestion, improved find_package behaviour for Midas 
          Reply  21 Mar 2025, Konstantin Olchanski, Suggestion, improved find_package behaviour for Midas 
             Reply  23 Mar 2025, Alexandr Kozlinskiy, Suggestion, improved find_package behaviour for Midas 
                Reply  25 Mar 2025, Konstantin Olchanski, Suggestion, improved find_package behaviour for Midas 
                   Reply  28 Mar 2025, Konstantin Olchanski, Suggestion, improved find_package behaviour for Midas 
Message ID: 2993     Entry time: 21 Mar 2025     In reply to: 2987     Reply to this: 2995
Author: Konstantin Olchanski 
Topic: Suggestion 
Subject: improved find_package behaviour for Midas 
> > > currently to link Midas to project one has to do several steps ...
> > this information is incorrect. please read https://daq00.triumf.ca/elog-midas/Midas/2258
> 
> I admit that i did not see your post about targets import
> via `include($ENV{MIDASSYS}/lib/midas-targets.cmake)`
> before implementing changes to cmake scripts.
>
> But in this respect the way you propose to do it via `include` should still work.
>

I proposed nothing, you did the proposing. I spent many hours trying to understand cmake (mission 
impossible!) and many more hours to implement the previously existing package scheme based
on the cmake "EXPORT" function.

> Note however that `include(...)` way is very unusual as one have to know exactly
> where `...-targets.cmake` is located and standard way in cmake is via `find_package`
> (similar to how e.g. ROOT, Geant4, etc. are found and linked).

Very difficult to cut-and-paste "include($ENV{MIDASSYS}/lib/midas-targets.cmake)".

You cannot simplify-out $ENV{MIDASSYS} because computer cannot read your mind, which of the 10 copies
of midas you want to use from which user account on which day.

Argument about "very unusual" I would buy, I am not a cmake expert and I do not know which package
finding method is in favour today.

>
> Though i again admit that maybe the namespace change was a bit too much as it may
> have broken previous users of `include($ENV{MIDASSYS}/lib/midas-targets.cmake)`
> 

I believe it did break at least one experiment, after updating MIDAS to latest version,
the analyzer would not build.

Speaking of which, did you implement your new scheme for the manalyzer so that it works
in standalone mode (without MIDAS)?

If you did not, now we have two schemes, your new scheme just for MIDAS and my old scheme
for manalyzer *and* MIDAS. xkcd 927.

> 
> - shortcomings of what was before is usage of non-standard `include(...)`
>

You should have started by posting a message spelling it out: Konstantin implemented
a scheme that uses the cmake "export" function to find midas, mfe and manalyzer,
it is very nice and works ok, but it is non-standard/obsoleted/obscure/frowned-upon/
unpopular/I-do-not-like-it/I-did-not-invent-it, and I propose implementing a new scheme
based on find_package().

>
> - one shortcoming i see for new implementation is usage `midas::` namespace
>   (mentioned above) that may have broken some setups
> 

If you think that your changes will break other people code, you should explicitely
say this in a message to this forum and hopefully provide instruction on fixing it,
i.e. in your makefile, please replace "midas" with "midas::midas".

> 
> - `find_package` is standard and recommended way of finding packages
>

Do you have a reference for this? When I look at cmake documentation, I do not see
any specific recommendation on creating packages and finding them. I do see
other people's code for finding packages and often spend hours fighting
them because said methods are designed to work only on the developer's laptop.

P.S. Did anybody ask Ben to update the MidasWiki documentation with the new find_package() information?

K.O.
ELOG V3.1.4-2e1708b5