View Issue Details

IDProjectCategoryView StatusLast Update
0004352FreeCADBugpublic2021-03-21 11:17
Reporterhobbes1069 Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformALL 
Target Version0.20 
Summary0004352: CMake Install process needs revamping
DescriptionI've posted about this some time ago (i.e. 2011) either to the bug tracker or the forums but that's irrelevant now. It looks like there have been some changes in 0.19 prerelease that seem to move in the right direction but the work is incomplete. My current spec file for Fedora no longer installs files to the correct location and my old method of dumping almost everything into /usr/lib{,64}/freecad no long functions.

Having a fully compliant FHS install is long overdue and while I can't find the specific messages anymore, it was promised some time ago.

I am submitting this to the issue tracker in hopes of getting the attention it deserves, and part of that is offering my time to help fix it ONLY if there is sufficient interest from the developers. To be honest, I don't have time for this. I'm working on cutting back on my Fedora packaging duties due to $LIFE and $DAYJOB, but I really don't like the way things are right now and am willing to make the short term sacrifice, but again, only if it is taken seriously.

1. For the love of god, please use CMake's GNUInstallDirs module. This will take care of all *Nix systems and maybe others.

2. Unless the libraries produced by FreeCAD are intended for TRULY shared (ie.e. public) consumption, they belong in a private subdir, i.e., /usr/lib{,64}/freecad on RPM (FHS compliant systems), but really all you have to do is append /freecad to CMAKE_INSTALL_LIBDIR if you use GNUInstallDirs, it takes care of the odd Debian tuple location for libraries.

Certainly the libraries not prefixed with "lib" can't go into /usr/lib{,64}.

There are 93 instances of CMAKE_INSTALL_LIBDIR being used directly based on current master:

$ grep -ro CMAKE_INSTALL_LIBDIR | wc -l
93

My recommendation would be instead of sed'ing these all to "CMAKE_INSTALL_LINDIR/freecad" is to replace them with "FREECAD_INSTALL_LIBDIR" and default them to the correct location in one of the helper macros.

3. If you do this, CMake is smart enough to know if the RPATH needs to be set or not, negating the need for all the manual RPAH handling.

4. All no-arch data does belong in /usr/share, but it ALSO needs to be in a "freecad" subdirectory. Currently if I don't override it a lot of stuff is dumped directly into /usr/share, like some of the Mod python files.

It can be handled similarly to 0000002. Also, I haven't dug into it enough to know it's not being done correctly but stuff in /usr/share REALLY needs to be noarch. Meaning it's EXACTLY the same if its i686, x86_64, ppc64le, s390x, arm, etc.

Now that I actually cut out the install portion of the build log and sorted it. It's not quite as bad as I thought, but my premis still stands. I'll attach the install portion so you can see where things are being installed when no override is being specified on the command line.
Additional InformationSide topic:
Maybe it matters for other platforms but I don't understand the overriding the output location of binaries and libraries in cMake/FreeCadMacros.cmake. By default they are created in the same directory they are configured in and CMake can track this just fine.
Tagscmake
FreeCAD InformationMaster as of 2020-05-28

Activities

hobbes1069

2020-05-29 02:31

reporter  

freecad-install.txt (Attachment missing)

hobbes1069

2020-05-29 13:44

reporter   ~0014437

Ok, after several build attempts yesterday trying to beat the package back into submission I got more than a little frustrated. With fresh eyes I found GNUInstallDirs buried in "cMake/FreeCAD_Helpers/ConfigureCMakeVariables.cmake".

It's also in "src/XDGData/CMakeLists.txt" which I would say would be inappropriate to include two different places but my guess this is an attempt to override the PREFIX in the former location:

        set(CMAKE_INSTALL_PREFIX "/usr/lib${LIB_SUFFIX}/freecad" CACHE PATH "Installation root directory")

I believe this is only necessary because all of the Mod/ installs use the relative install path "Mod/<module>" which will only be installed relative to the PREFIX.

Also, I misspoke in the original post, noarch data if it's executable code still belongs in /usr/lib, not /usr/share, which IS for noarch data, just not noarch code such as pure python.

Evaluating the install location portion of


macro(ConfigureCMakeVariables)
    # ================================================================================
    # Output directories for install target

    if(WIN32)
        set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation root directory")
        set(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for executables")
        set(CMAKE_INSTALL_DATADIR data CACHE PATH "Output directory for data and resource files")
        set(CMAKE_INSTALL_INCLUDEDIR include CACHE PATH "Output directory for header files")
        set(CMAKE_INSTALL_DOCDIR doc CACHE PATH "Output directory for documentation and license files")
        # Don't set it without manual adoption of LibDir variable in src/App/FreeCADInit.py
        set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
    else()
        set(CMAKE_INSTALL_PREFIX "/usr/lib${LIB_SUFFIX}/freecad" CACHE PATH "Installation root directory")
        include(GNUInstallDirs)
    endif()

1. In this case creating all the cache variables for WIN32 is superfluous as GNUInstallDirs would set cache variables to the exact same values in all cases except the _PREFIX which could be easily modified.

2. Referenced above, the old issue of dumping everything into /usr/lib{,64}. Please correct me if I'm wrong, but again, the only reason I can find for this is all the stuff in src/Mod not using a proper install location ${CMAKE_INSTALL_LIBDIR}.

By default GNUInstallDirs marks all the variables as advanced but it's trivial to expose the locations that FreeCAD actually uses.

hobbes1069

2020-05-29 22:31

reporter   ~0014440

Ok, so even though I wasn't going to do it I did anyway. I have a patch ready for master but I still have a few things to tweak. I've got everything installing correctly except:


   Installed (but unpackaged) file(s) found:
   /usr/Ext/PySide/QtCore.py
   /usr/Ext/PySide/QtGui.py
   /usr/Ext/PySide/QtSvg.py
   /usr/Ext/PySide/QtUiTools.py
   /usr/Ext/PySide/__init__.py
   /usr/Ext/freecad/gui/RemoteDebugger.py
   /usr/Ext/freecad/gui/RemoteDebugger.ui
   /usr/Ext/lazy_loader/__init__.py
   /usr/Ext/lazy_loader/lazy_loader.py
   /usr/share/doc/FreeCAD/ThirdPartyLibraries.html
   /usr/share/doc/FreeCAD/freecad.qch
   /usr/share/doc/FreeCAD/freecad.qhc
   /usr/share/icons/hicolor/16x16/apps/freecad.png
   /usr/share/icons/hicolor/32x32/apps/freecad.png
   /usr/share/icons/hicolor/48x48/apps/freecad.png
   /usr/share/icons/hicolor/64x64/apps/freecad.png
   /usr/share/icons/hicolor/scalable/mimetypes/application-x-extension-fcstd.svg
   /usr/share/pixmaps/freecad.xpm

I fixed the icon stuff so it's really just the top stuff.

1. Why are the translations (I assume that's what the qch and qhc files are) installing to /usr/doc? That doesn't make any sense.

2. The Ext stuff is still not installing to a freecad subdir even though the helper macro that adds it is added before src/Ext is executed in the main CMakeLists.txt.

in src/Ext/freecad/CMakeLists.txt, FREECAD_LIBRARY_INSTALL_DIR is set to CMAKE_INSTALL_LIBDIR, which should already be /usr/lib{,64}/freecad but it's not working...

if (WIN32)
        set(FREECAD_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
else()
        set(FREECAD_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
endif()

Almost there!

hobbes1069

2020-05-30 13:33

reporter   ~0014443

Well I mentioned this bug in the pull request but it doesn't look like it's been picked up yet...

https://github.com/FreeCAD/FreeCAD/pull/3525

There's still some non-script stuff being installed to /usr/lib{,64}/freecad/Mod I'll work on that when I have a little more time.

vocx

2020-06-02 16:21

reporter   ~0014456

Why are the translations (I assume that's what the qch and qhc files are) installing to /usr/doc? That doesn't make any sense.

hobbes1069

These files are not translation files, they are compiled HTML files. They comprise the offline documentation that can be opened with FreeCAD, and need Qt assistant to be installed, I think.

hobbes1069

2020-06-02 16:25

reporter   ~0014457

Last edited: 2020-06-03 17:26

I figured that out later, I still question if they should get installed into /usr/doc, which is typically for plain text, markdown, rtf, files. Since they are compiled I would consider them to be a Qt resource file and should go somewhere in /usr/share/freecad.

PrzemoF

2020-07-01 09:18

reporter   ~0014607

Default file locations on fedora linux.
FreeCAD_installation_locations.txt (Attachment missing)

PrzemoF

2020-07-01 09:18

reporter   ~0014608

Forum thread: https://forum.freecadweb.org/viewtopic.php?f=10&t=47159

Issue History

Date Modified Username Field Change
2020-05-29 02:31 hobbes1069 New Issue
2020-05-29 02:31 hobbes1069 File Added: freecad-install.txt
2020-05-29 13:44 hobbes1069 Note Added: 0014437
2020-05-29 22:31 hobbes1069 Note Added: 0014440
2020-05-30 13:33 hobbes1069 Note Added: 0014443
2020-06-02 16:21 vocx Note Added: 0014456
2020-06-02 16:25 hobbes1069 Note Added: 0014457
2020-06-03 17:26 hobbes1069 Note Edited: 0014457
2020-07-01 09:18 PrzemoF Note Added: 0014607
2020-07-01 09:18 PrzemoF File Added: FreeCAD_installation_locations.txt
2020-07-01 09:18 PrzemoF Note Added: 0014608
2021-02-06 06:49 abdullah Target Version => 0.20
2021-03-21 11:17 Kunda1 Tag Attached: cmake