[waffle] [PATCH 3/4] cmake: Add the installed package files to the registry on windows

Dylan Baker baker.dylan.c at gmail.com
Mon Dec 29 09:39:49 PST 2014


On Monday, December 29, 2014 05:33:43 PM Jose Fonseca wrote:
> On 29/12/14 17:07, Dylan Baker wrote:
> > On Monday, December 29, 2014 11:35:20 AM Jose Fonseca wrote:
> >> On 22/12/14 22:36, Dylan Baker wrote:
> >>> This adds the locations of the package files to the registry on windows,
> >>> which should allow them to be auto detected by cmake on windows when
> >>> linking against waffle in other projects.
> >>>
> >>> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> >>> ---
> >>>
> >>> This patch is completely untested (I don't have access to a windows
> >>> development machine, nor do I want to maintain one), I've sent this as a
> >>> courtesy to windows users, and hopefully it can point an interested part
> >>> in the correct direction.
> >>>
> >>> Note that this installs into the local machine registry, and there is
> >>> also the option of using local user registry instead, and that can be
> >>> done by changing waffle to use export(), though I'm not exactly sure how
> >>> that works either
> >>>
> >>>    CMakeLists.txt | 10 ++++++++++
> >>>    1 file changed, 10 insertions(+)
> >>>
> >>> diff --git a/CMakeLists.txt b/CMakeLists.txt
> >>> index 729ebc1..0ac2d4b 100644
> >>> --- a/CMakeLists.txt
> >>> +++ b/CMakeLists.txt
> >>> @@ -182,6 +182,16 @@ install(
> >>>        COMPONENT Devel
> >>>    )
> >>>
> >>> +# If running on windows add waffle to the registry so it can be auto detected
> >>> +# by consuming projects
> >>> +if (WIN32)
> >>
> >> This will break cross-compiling from Linux to Windows (via MinGW),
> >> because "WIN32" is true.
> >>
> >> Replacing it with
> >>
> >>     if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
> >>
> >> should do the trick.
> >>
> >>
> >>> +    execute_process(
> >>> +        COMMAND "REG ADD HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\Waffle /v Waffle-1 /t REG_SZ /d ${ConfigPackageLocation} /f"
> >>
> >> I suspect this will fail when there are spaces in the path (e.g., when
> >> waffle is in "C:\Program Files\..."
> >>
> >>
> >>> +        ERROR_QUIET
> >>> +        OUTPUT_QUIET
> >>> +    )
> >>> +endif ()
> >>
> >> Also I believe execute_process() will execute the command when
> >> configuring -- not when building --, or even better, not when installing.
> >>
> >>
> >>
> >>
> >> I'm not sure this is a great idea overall.  Are any other packages doing
> >> anything like this?  It all seems very non-standard, so I wonder if this
> >> will really simplify things or be too surprising.
> >
> > I can't say whether it is a good idea or not, it's suggested by the
> > cmake documentation as the "right" way to do things on windows. I don't
> > have a strong opinion either way, and, like you, I doubt this works
> > correctly in it's current form. I provided mostly as a way to say "hey,
> > you can do this if you want", but I no problem dropping it.
> 
> Thanks.  I actually forgot to say in my reply that I appreciate you 
> taking the time and energy to looking into this.
> 
> If CMake documentation recommends, then it might be possible to find a 
> more comprehensive example in some open source project that does this, 
> that we can use as reference.  I confess I never came across one, but my 
> sampling universe is limited.
> 
> http://www.cmake.org/Wiki/CMake/Tutorials/Package_Registry explains some 
> of this, but doesn't actually explain how to set.  My guess is that the 
> registry key is typically set by full-blown Windows pakcages installers 
> like Windows Installer or NSIS, but we don't use them here.
> 
> We could though, as cpack supports NSIS -- 
> http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#NSIS --, so we 
> could produce a NSIS installer for waffle, which would set the registry 
> key enabling waffle consumers to automatically pick up the right locations.
> 
> In short, I think there might be some merit in this idea, but there a 
> few open issues.  In the meanwhile we should hold on.
> 
> Jose

That sounds reasonable, I've spun a v3 that doesn't include this patch,
it will be here if we want to clean it up later.

Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/waffle/attachments/20141229/56422634/attachment-0001.sig>


More information about the waffle mailing list