Skip to content

Fix CMake install absolute path to support --prefix option #438

Description

@x12301450

In your CMakeLists.txt, five absolute path are used as the destination of install command, which is not recommended by CMake.

agent/CMakeLists.txt: 89 and 100

SET(SYS_CONFIG_DIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}/softwarecontainer/)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/softwarecontainer-config" DESTINATION ${SYS_CONFIG_DIR})

install(FILES softwarecontainer-agent.conf DESTINATION "/etc/dbus-1/system.d")

examples/temperature/temperature-service/CMakeLists.txt: 27

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dbus/com.pelagicore.TemperatureService.conf
            DESTINATION /etc/dbus-1/system.d/)

libsoftwarecontainer/CMakeLists.txt: 57 and 59

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/softwarecontainer.pc DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/softwarecontainer.conf DESTINATION ${SYS_CONFIG_DIR})

When attempting to use the --prefix option to relocate the installation destination, using an absolute path causes the installation to fail. This prevents the installation to custom prefixes and could lead to unintended issues.

There are numerous similar fixes, such as this example.

I think the destinatioin should be set to a relative path, excluding ${CMAKE_INSTALL_PREFIX}. For example, using CMAKE_INSTALL_SYSCONFDIR rather than full_dir would be a better practice.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions