Giter Site home page Giter Site logo

Comments (14)

nunotexbsd avatar nunotexbsd commented on July 21, 2024 1

+if(LINUX OR BSD)

Works perfectly.

Understand it about TREESHEETS_RELOCATABLE_INSTALLATION.

Related to:

-install(DIRECTORY TS/examples DESTINATION ${TREESHEETS_DOCDIR})
+install(DIRECTORY TS/examples DESTINATION ${CMAKE_INSTALL_DATADIR}/examples/ {CMAKE_PROJECT_NAME})

It has to do with our hier and ports framework:

DATADIR gets expanded to PREFIX/share/PORTNAME.
DOCSDIR gets expanded to PREFIX/share/doc/PORTNAME.
EXAMPLESDIR gets expanded to PREFIX/share/examples/PORTNAME.

cmake apears to not have a variable for examples like it do for doc, so I've patched it.

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024 1

Ok :-) Thanks for your feedback! Is it okay for you to keep the patch at your (port) side?

But if you keep it that way, does not TreeSheet complain about the missing example file? If you run treesheets on the commandline there should be a warning?

from treesheets.

nunotexbsd avatar nunotexbsd commented on July 21, 2024 1

Sure, not problem.

Thanks for help solving this issue.

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

Thanks for posting this issue.

Does BSD implement the Hierarchical File System from Linux? If yes, then it can be fixed by adding BSD to the condition check.

from treesheets.

nunotexbsd avatar nunotexbsd commented on July 21, 2024

I don't think so from what I'm reading on https://wiki.freebsd.org/HFS

At version 7861249636 I didn't change values from CMakeLists.txt appart from sending examples to other dir, so it is a good start the check what changed.

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

Sorry I meant Filesystem Hierarchy Standard.

from treesheets.

nunotexbsd avatar nunotexbsd commented on July 21, 2024

FreeBSD Unix don't conform with FHS and it is the first time that I'm seing it being configured in cmake:

https://man.freebsd.org/cgi/man.cgi?hier(7)

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

First approach: Follow the Filesystem Hierarchy Standard also on BSD.

You may seem to use it anyway in your patch, because when you include(GNUInstallDirs), you follow the Filesystem Hierarchy Standard, meaning that you put the documentation into $CMAKE_INSTALL_PREFIX/share/doc/ ... during installation (e.g. when you use make install or cmake --install <builddir>).

In this case: Does it help to only replace LINUX with BSD in CMakeLists.txt, not keeping the original patch? You may need to clean up the CMake cache, too. (That means removing CMakeCache.txt and then re-generate the Makefiles with CMake).

Second approach: Keep everything relative to the TreeSheets binary (this is just the case on every operating system apart from Linux where TREESHEETS_RELOCATABLE_INSTALLATION is not set, thus following the Filesystem Hierarchy Standard). In this case, you should leave the CMakeLists.txt as is from upstream without patching it and configure CMAKE_INSTALL_PREFIX to a suitable location where it does not interfere with the root filesystem hierarchy. You need to check then that examples and images directories are installed relative to/along with the TreeSheets binary.

When you change between the two approaches, please remind to also clean the CMake Cache because otherwise the variables TREESHEETS_DOCDIR etc. will be left over (the variables indicate absolute paths in the case of the Filesystem Hierarchy Standard used). These are used by the preprocessor to determine whether it should consider these paths, too or only the paths relative to the binary.

from treesheets.

nunotexbsd avatar nunotexbsd commented on July 21, 2024

@t2b3

It worked fine! I've run so many tests and even so I did missed something.

My test patch is:

--- CMakeLists.txt.orig 2024-03-28 08:00:11 UTC
+++ CMakeLists.txt
@@ -99,7 +99,7 @@ endif()
     OPTION(TREESHEETS_RELOCATABLE_INSTALLATION "Install data relative to the treesheets binary, instead of respecting the Filesystem Hierarchy Standard" OFF)
 endif()

-if(LINUX AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
+if(NOT LINUX AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
     include(GNUInstallDirs)

     set(TREESHEETS_BINDIR ${CMAKE_INSTALL_BINDIR})
@@ -125,7 +125,7 @@ install(FILES TS/readme.html DESTINATION ${TREESHEETS_
 install(TARGETS treesheets DESTINATION ${TREESHEETS_BINDIR})
 install(DIRECTORY TS/docs DESTINATION ${TREESHEETS_DOCDIR})
 install(FILES TS/readme.html DESTINATION ${TREESHEETS_DOCDIR})
-install(DIRECTORY TS/examples DESTINATION ${TREESHEETS_DOCDIR})
+install(DIRECTORY TS/examples DESTINATION ${CMAKE_INSTALL_DATADIR}/examples/${CMAKE_PROJECT_NAME})

 install(DIRECTORY TS/images DESTINATION ${TREESHEETS_PKGDATADIR})
 install(DIRECTORY TS/scripts DESTINATION ${TREESHEETS_PKGDATADIR})

So, for my understanding FreeBSD could be added to this block.

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

Thanks for your reply! Happy to hear that it works.
One more question: Is it sufficient to patch the CMakeLists.txt with the patch below to make it work on FreeBSD?
I am curious whether and why it is needed to patch the install destination for TS/examples because in the branch now used TREESHEETS_DOCDIR is now set and thus that path is considered by the compiler preprocessor and thus hardcoded as candidate into the candidate path array for the TreeSheets example files, like tutorial, into the binary.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 576cf3f..84d0f57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,11 +95,11 @@ target_link_libraries(
 
 ########## TREESHEETS INSTALLATION SETTINGS ###############
 
-if(LINUX)
+if(LINUX OR FREEBSD)
     OPTION(TREESHEETS_RELOCATABLE_INSTALLATION "Install data relative to the treesheets binary, instead of respecting the Filesystem Hierarchy Standard" OFF)
 endif()
 
-if(LINUX AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
+if((LINUX OR FREEBSD) AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
     include(GNUInstallDirs)
 
     set(TREESHEETS_BINDIR ${CMAKE_INSTALL_BINDIR})

from treesheets.

nunotexbsd avatar nunotexbsd commented on July 21, 2024

+if(LINUX OR FREEBSD)

Adding FREEBSD like this doesn't work (all files get installed into cmake install prefix).

CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" seems the right setting, don't know if a generic one exists for *bsd.

Don't know if TREESHEETS_RELOCATABLE_INSTALLATION will have any use on FreeBSD...

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

Ok, what about BSD then directly? Sorry, you are completely right!
https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 576cf3f..0ed952d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,11 +95,11 @@ target_link_libraries(
 
 ########## TREESHEETS INSTALLATION SETTINGS ###############
 
-if(LINUX)
+if(LINUX OR BSD)
     OPTION(TREESHEETS_RELOCATABLE_INSTALLATION "Install data relative to the treesheets binary, instead of respecting the Filesystem Hierarchy Standard" OFF)
 endif()
 
-if(LINUX AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
+if((LINUX OR BSD) AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
     include(GNUInstallDirs)
 
     set(TREESHEETS_BINDIR ${CMAKE_INSTALL_BINDIR})

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

+if(LINUX OR FREEBSD)

Adding FREEBSD like this doesn't work (all files get installed into cmake install prefix).

CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" seems the right setting, don't know if a generic one exists for *bsd.

Don't know if TREESHEETS_RELOCATABLE_INSTALLATION will have any use on FreeBSD...

Yes, I think it has its use case if you do not want to install it directly to the /usr/ hierarchy, but e.g. only to install it somewhere in your home directory (adjust CMAKE_INSTALL_PREFIX for it) and/or if you want to keep everything (binary, translation, documentation, tutorial) in one folder and move it around. Then relocatable install is needed. But normally packages distributed by the distribution should integrate directly with the Filesystem Hierarchy Standard structure, so and that case it is not needed.

from treesheets.

tobiolo avatar tobiolo commented on July 21, 2024

Sure, not problem.

Thanks for help solving this issue.

You are welcome.

from treesheets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.