diff --git a/CMakeLists.txt b/CMakeLists.txt index 881653ff8a7..fdcc7025950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) @@ -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) @@ -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") \ No newline at end of file diff --git a/cmake/UploadPPA.cmake b/cmake/UploadPPA.cmake index d98f734fdfe..87fdd6d0371 100644 --- a/cmake/UploadPPA.cmake +++ b/cmake/UploadPPA.cmake @@ -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" diff --git a/cmake/post_install.cmake.in b/cmake/post_install.cmake.in new file mode 100644 index 00000000000..ed7cb08382b --- /dev/null +++ b/cmake/post_install.cmake.in @@ -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) diff --git a/cmake/uninstall.cmake.in b/cmake/uninstall.cmake.in new file mode 100644 index 00000000000..65100a1fe04 --- /dev/null +++ b/cmake/uninstall.cmake.in @@ -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) \ No newline at end of file diff --git a/installer/deb/hal.conf b/installer/deb/hal.conf deleted file mode 100644 index 4a2acdda443..00000000000 --- a/installer/deb/hal.conf +++ /dev/null @@ -1,2 +0,0 @@ -# Install to /etc/ld.so.conf.d -/usr/lib/x86_64-linux-gnu/hal_plugins \ No newline at end of file diff --git a/installer/deb/hal.conf.in b/installer/deb/hal.conf.in new file mode 100644 index 00000000000..eb4caf905ad --- /dev/null +++ b/installer/deb/hal.conf.in @@ -0,0 +1,3 @@ +# Install to /etc/ld.so.conf.d +@LIBRARY_INSTALL_DIRECTORY_FULL@ +@LIBRARY_INSTALL_DIRECTORY_FULL@/hal_plugins \ No newline at end of file diff --git a/tests/googletest-CMakeLists.txt.in b/tests/googletest-CMakeLists.txt.in index 749bfae4f7a..8ccc81843b9 100644 --- a/tests/googletest-CMakeLists.txt.in +++ b/tests/googletest-CMakeLists.txt.in @@ -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 "" ) \ No newline at end of file