Skip to content

Commit

Permalink
Added uninstall target and fixed make/ninja install on linux with cor…
Browse files Browse the repository at this point in the history
…rect ldconfig settings
  • Loading branch information
swallat committed Aug 5, 2019
1 parent 329a5c5 commit 2ab94d2
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 6 deletions.
27 changes: 25 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ set(GRAPH_ALGORITHM_LIB graph_algorithm)
set(QUINE_MCCLUSKY_LIB quine_mccluskey)

option(BUILD_ALL_PLUGINS "BUILD_ALL_PLUGINS" OFF)
option(BUILD_TESTS "BUILD_TESTS" ON)
option(BUILD_TESTS "BUILD_TESTS" OFF)
option(BUILD_COVERAGE "BUILD_COVERAGE" OFF)

if(${BUILD_TESTS} AND ${BUILD_COVERAGE})
Expand Down Expand Up @@ -374,7 +374,11 @@ install(FILES ${CMAKE_BINARY_DIR}/hal.pc DESTINATION "${PKGCONFIG_INSTALL_DIRECT
message(STATUS "PKGCONFIG_INSTALL_DIRECTORY ${PKGCONFIG_INSTALL_DIRECTORY}")

if(LINUX)
install(FILES "installer/deb/hal.conf" DESTINATION "${SHARE_INSTALL_DIRECTORY}/ld_conf/")
configure_file(
"installer/deb/hal.conf.in"
"${CMAKE_BINARY_DIR}/hal.conf"
@ONLY)
install(FILES "${CMAKE_BINARY_DIR}/hal.conf" DESTINATION "${SHARE_INSTALL_DIRECTORY}/ld_conf/")
endif()

if(UPLOAD_PPA)
Expand Down Expand Up @@ -478,3 +482,22 @@ if(BUILD_DOCUMENTATION)

endif()

# on make/ninja install run configure and run ldconfig
option(ENABLE_INSTALL_LDCONFIG "ENABLE_INSTALL_LDCONFIG" ON)

if(ENABLE_INSTALL_LDCONFIG)
if(LINUX)
configure_file(
"cmake/post_install.cmake.in"
"${CMAKE_BINARY_DIR}/post_install.cmake"
@ONLY)
install(SCRIPT "${CMAKE_BINARY_DIR}/post_install.cmake")
endif(LINUX)
endif(ENABLE_INSTALL_LDCONFIG)

# add uninstall target
configure_file(
"cmake/uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/uninstall.cmake"
@ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/uninstall.cmake")
2 changes: 1 addition & 1 deletion cmake/UploadPPA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ foreach(DISTRI ${PROJECT_PPA_DISTRIB_TARGET})
"\tdh $@ --buildsystem=cmake --parallel\n"
"\noverride_dh_auto_configure:\n"
"\tls -lah\n"
"\tDESTDIR=\"$(CURDIR)/debian/${CPACK_DEBIAN_PACKAGE_NAME}\" dh_auto_configure -- -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_ALL_PLUGINS=OFF -DBUILD_TESTS=OFF -DWITH_GUI=ON -DUSE_VERSION_FROM_OPTION=ON -DDHAL_VERSION_RETURN=\"${DHAL_VERSION_RETURN}\" -DHAL_VERSION_MAJOR=\"${HAL_VERSION_MAJOR}\" -DHAL_VERSION_MINOR=\"${HAL_VERSION_MINOR}\" -DHAL_VERSION_PATCH=\"${HAL_VERSION_PATCH}\" -DHAL_VERSION_TWEAK=\"${HAL_VERSION_TWEAK}\" -DHAL_VERSION_ADDITIONAL_COMMITS=\"${HAL_VERSION_ADDITIONAL_COMMITS}\" -DHAL_VERSION_HASH=\"${HAL_VERSION_HASH}\" -DHAL_VERSION_DIRTY=\"${HAL_VERSION_DIRTY}\" -DHAL_VERSION_BROKEN=\"${HAL_VERSION_BROKEN}\"\n"
"\tDESTDIR=\"$(CURDIR)/debian/${CPACK_DEBIAN_PACKAGE_NAME}\" dh_auto_configure -- -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_INSTALL_LDCONFIG=OFF -DBUILD_ALL_PLUGINS=OFF -DBUILD_TESTS=OFF -DWITH_GUI=ON -DUSE_VERSION_FROM_OPTION=ON -DDHAL_VERSION_RETURN=\"${DHAL_VERSION_RETURN}\" -DHAL_VERSION_MAJOR=\"${HAL_VERSION_MAJOR}\" -DHAL_VERSION_MINOR=\"${HAL_VERSION_MINOR}\" -DHAL_VERSION_PATCH=\"${HAL_VERSION_PATCH}\" -DHAL_VERSION_TWEAK=\"${HAL_VERSION_TWEAK}\" -DHAL_VERSION_ADDITIONAL_COMMITS=\"${HAL_VERSION_ADDITIONAL_COMMITS}\" -DHAL_VERSION_HASH=\"${HAL_VERSION_HASH}\" -DHAL_VERSION_DIRTY=\"${HAL_VERSION_DIRTY}\" -DHAL_VERSION_BROKEN=\"${HAL_VERSION_BROKEN}\"\n"
"\n\noverride_dh_auto_install:\n"
"\tdh_auto_install --destdir=\"$(CURDIR)/debian/${CPACK_DEBIAN_PACKAGE_NAME}\" --buildsystem=cmake"
"\n\noverride_dh_strip:\n"
Expand Down
13 changes: 13 additions & 0 deletions cmake/post_install.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(LINUX @LINUX@)
set(SHARE_INSTALL_DIRECTORY_FULL @SHARE_INSTALL_DIRECTORY_FULL@)
if(LINUX)
message(STATUS "Copy file ${SHARE_INSTALL_DIRECTORY_FULL}/ld_conf/hal.conf to /etc/ld.so.conf.d/")

execute_process(COMMAND ${CMAKE_COMMAND} -E copy hal.conf /etc/ld.so.conf.d/)

message(STATUS "Running: ldconfig")
execute_process(COMMAND "ldconfig" RESULT_VARIABLE ldconfig_result)
if (NOT ldconfig_result EQUAL 0)
message(WARNING "ldconfig failed")
endif()
endif(LINUX)
40 changes: 40 additions & 0 deletions cmake/uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
set(LINUX @LINUX@)
set(ENABLE_INSTALL_LDCONFIG @ENABLE_INSTALL_LDCONFIG@)
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")

if(NOT EXISTS ${MANIFEST})
message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'")
endif()

file(STRINGS ${MANIFEST} files)
foreach(file ${files})
if(EXISTS ${file})
message(STATUS "Removing file: '${file}'")

exec_program(
${CMAKE_COMMAND} ARGS "-E remove ${file}"
OUTPUT_VARIABLE stdout
RETURN_VALUE result
)

if(NOT "${result}" STREQUAL 0)
message(FATAL_ERROR "Failed to remove file: '${file}'.")
endif()
else()
message(STATUS "File '${file}' does not exist.")
endif()
endforeach(file)

if(ENABLE_INSTALL_LDCONFIG)
if(LINUX)
message(STATUS "Remove file ${SHARE_INSTALL_DIRECTORY}/ld_conf/hal.conf to /etc/ld.so.conf.d/hal.conf")

execute_process(COMMAND ${CMAKE_COMMAND} -E remove /etc/ld.so.conf.d/hal.conf)

message(STATUS "Running: ldconfig")
execute_process(COMMAND "ldconfig" RESULT_VARIABLE ldconfig_result)
if(NOT ldconfig_result EQUAL 0)
message(WARNING "ldconfig failed")
endif()
endif(LINUX)
endif(ENABLE_INSTALL_LDCONFIG)
2 changes: 0 additions & 2 deletions installer/deb/hal.conf

This file was deleted.

3 changes: 3 additions & 0 deletions installer/deb/hal.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Install to /etc/ld.so.conf.d
@LIBRARY_INSTALL_DIRECTORY_FULL@
@LIBRARY_INSTALL_DIRECTORY_FULL@/hal_plugins
2 changes: 1 addition & 1 deletion tests/googletest-CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ ExternalProject_Add(googletest
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
INSTALL_COMMAND cmake -E echo "Skipping install step."
TEST_COMMAND ""
)

0 comments on commit 2ab94d2

Please sign in to comment.