-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[install] CMakeLists.txt hardcodes /etc/... paths #557
Comments
This is only available in CMake 3.0 or higher, currently we support 2.6 and up. This will break compatability. |
You may propose a PR/patch and try to not break compat with 2.6-3.0. Thanks! |
See also #899. |
We should be able to deal with this now, as the minimum version requirement for cmake has been raised to 3.4.2, so one does no longer need to worry about any broken compatibilities. |
@bjornfor: I have added the GNUInstallDirs.cmake module locally, but are not quite sure yet how to properly integrate it into the build configuration we currently have. I'll open a new branch for this, so you or anyone else can have a look at it. I am sure there are people who know more about cmake than I currently do... |
This is only the plain module as requested in #557. It still requires proper integration into the existing configuration.
@Nightwalker-87 : GNUInstallDirs.cmake is distributed with cmake, you don't need to add it yourself to the codebase. To use it just
|
I understand, but is this really all that has do be done unrelated to any custom configuration? |
I think so. Heres an (untested) diff of how I'd replace two hardcoded /etc instances in stlink: diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90378f9..e81f621 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 2.8.7)
set(CMAKE_USER_MAKE_RULES_OVERRIDE cmake/c_flag_overrides.cmake)
project(stlink C)
set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics Stlink Tools")
-set(STLINK_UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "Udev rules directory")
-set(STLINK_MODPROBED_DIR "/etc/modprobe.d" CACHE PATH "modprobe.d directory")
+include(GNUInstallDirs)
+set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/udev/rules.d" CACHE PATH "Udev rules directory")
+set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory")
set(STLINK_STATIC_LIB ON CACHE BOOL "Install static lib")
if( IS_DIRECTORY ${LIB_INSTALL_DIR})
|
Ah, the remaining "/etc/" instances are in comments or documentation, so I think that patch above is all that's needed. (The patching in nixpkgs was done with sed and no GNUInstallDirs so it's not directly applicable.) |
@bjornfor: Can you test it? |
It does work, I played around with this script:
I also edited CMakeLists.txt to print out interesting variables. I guess the default CMAKE_INSTALL_FULL_SYSCONFDIR might not be what everyone expects (not that I know what that is though), so perhaps it's a good idea to update documentation to suggest building with |
Let me take a closer look at this and related documentation on the web. |
I think However I'm not sure yet, whether we
|
@bjornfor: What's your opinion on this? |
To have the least support issues, I think I would preset -DCMAKE_INSTALL_SYSCONFDIR=/etc and leave -DCMAKE_INSTALL_PREFIX= unset. But I'm really unsure of presetting /etc (vs just documenting the option). I mean the option does have a default value already, so with /etc as overridden default it would no longer behave as documented in GNUInstallDirs. |
Ok, thanks for your feedback. I'll add this to our documentation then and we can ensure the defaults as documented in GNUInstallDirs, which also appears to be in the sense of the opening post. |
I think we should take a closer look at the previous configuration now, after including |
@bjornfor: As proposed, I've added a note on cmake build options related to |
- Removed requirement for 7zip on Windows - Added note on GNUInstallDir presets (#557)
Thanks! |
Please use GNUInstallDirs[1] so that sysconfdir can be passed to cmake in a standard way.
(In Nixpkgs we now have to patch CMakeLists.txt, and that's pointless extra work for downstreams.)
[1] https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html
The text was updated successfully, but these errors were encountered: