roehling / postsrsd

Postfix Sender Rewriting Scheme daemon
319 stars 38 forks source link

build: improve default systemd unitdir #132

Closed jengelh closed 1 year ago

jengelh commented 1 year ago

Some distributions have /usr/lib64 and accordingly pass -DCMAKE_INSTALL_LIBDIR:PATH=lib64 to cmake, but still, systemd is (always) fixed at /usr/lib/systemd.

function(find_systemd_unit_destination var)
    if(CMAKE_INSTALL_PREFIX MATCHES "^/usr/?$")
        if(EXISTS "/etc/debian_version")
            set(${var}
                "/lib/systemd/system"
                PARENT_SCOPE
            )
        else()
            set(${var}
                "${CMAKE_INSTALL_LIBDIR}/systemd/system"
                PARENT_SCOPE
            )
        endif()
    else()
        set(${var}
            "/etc/systemd/system"
            PARENT_SCOPE
        )
    endif()
endfunction()

The adequate way is to query pkgconfig: pkg-config systemd --variable=pkg-config systemd --variable=systemdsystemunitdir. That would also make the Debian check redundant.

roehling commented 1 year ago

Oh, thanks, I did not know that!