Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Adds uninstall target to CMake projects.

Signed-off-by: Oleh Kravchenko <[email protected]>
  • Loading branch information
Oleh-Kravchenko committed Jan 1, 2019
0 parents commit f119927
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.*~
*.bak
*.kdev4
build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "3rdparty/cmake-version4git"]
path = 3rdparty/cmake-version4git
url = https://github.com/Oleh-Kravchenko/cmake-version4git.git
1 change: 1 addition & 0 deletions 3rdparty/cmake-version4git
Submodule cmake-version4git added at 58e12a
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(cmake-uninstall NONE)

INCLUDE(CMakePackageConfigHelpers)
INCLUDE(GNUInstallDirs)

FIND_PACKAGE(cmake-version4git 0.0 QUIET)
IF(NOT cmake-version4git_FOUND)
INCLUDE(3rdparty/cmake-version4git/cmake/cmake-version4git.cmake)
ENDIF()
PROJECT_VERSION_FROM_GIT()

SET(PROJECT_CONFIG_PREFIX
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config")
SET(PROJECT_CMAKE_INSTALL_LIBDIR
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}")

WRITE_BASIC_PACKAGE_VERSION_FILE("${PROJECT_CONFIG_PREFIX}-version.cmake"
VERSION
${PROJECT_VERSION}
COMPATIBILITY
SameMajorVersion)

CONFIGURE_PACKAGE_CONFIG_FILE("cmake/${PROJECT_NAME}-config.cmake.in"
"${PROJECT_CONFIG_PREFIX}.cmake"
INSTALL_DESTINATION
"${PROJECT_CMAKE_INSTALL_LIBDIR}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

INSTALL(FILES
"${PROJECT_CONFIG_PREFIX}-version.cmake"
"${PROJECT_CONFIG_PREFIX}.cmake"
cmake/cmake_uninstall.cmake.in
DESTINATION
"${PROJECT_CMAKE_INSTALL_LIBDIR}"
COMPONENT
Devel)

CONFIGURE_FILE(cmake/cmake_uninstall.cmake.in
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" @ONLY)

ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
COMMENT
"Uninstall the project...")
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019, Oleh Kravchenko
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Overview

Adds uninstall target to CMake projects.

# Example

CMakeLists.txt

FIND_PACKAGE(cmake-uninstall REQUIRED)

Command interpreter

make uninstall

# Installation

## Gentoo Linux

$ layman -S
$ layman -a kaa
$ emerge dev-util/cmake-uninstall -a

## Yocto

Please use recipe contrib/yocto/cmake-uninstall_git.bb
12 changes: 12 additions & 0 deletions cmake/cmake-uninstall-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@PACKAGE_INIT@

MESSAGE(STATUS "Found @PROJECT_NAME@: ${CMAKE_CURRENT_LIST_DIR}"
" (found version \"${@PROJECT_NAME@_VERSION}\")")

CONFIGURE_FILE("${CMAKE_CURRENT_LIST_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" @ONLY)

ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
COMMENT
"Uninstall the project...")
22 changes: 22 additions & 0 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
IF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest:"
" \"@CMAKE_BINARY_DIR@/install_manifest.txt\"")
ENDIF()

FILE(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" FILES)
STRING(REGEX REPLACE "\n" ";" FILES "${FILES}")

FOREACH(FILE ${FILES})
IF(EXISTS "$ENV{DESTDIR}${FILE}")
MESSAGE(STATUS "Uninstalling: $ENV{DESTDIR}${FILE}")

EXECUTE_PROCESS(COMMAND
@CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${FILE}"
RESULT_VARIABLE
RESULT)

IF(RESULT)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${FILE}\"")
ENDIF()
ENDIF()
ENDFOREACH()
23 changes: 23 additions & 0 deletions contrib/yocto/cmake-uninstall_git.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SUMMARY = "Adds uninstall target to CMake projects"
SECTION = "devel"
HOMEPAGE = "https://github.com/Oleh-Kravchenko/cmake-uninstall"
BUGTRACKER = "https://github.com/Oleh-Kravchenko/cmake-uninstall/issues"

LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=f967ca707a6df9d1e6b584c85f4d8779"

PV = "git${SRCPV}"
SRCREV = "${AUTOREV}"
SRC_URI = "gitsm://github.com/Oleh-Kravchenko/cmake-uninstall.git;protocol=https"
S = "${WORKDIR}/git"

inherit allarch cmake

DEPENDS += "git-native"
PACKAGES = "${PN}-dev"
RDEPENDS_${PN}-dev = "${PN}-dev"

FILES_${PN}-dev += "${libdir}/cmake"

# by default git-native is provided by host system, please see bitbake.conf
EXTRA_OECMAKE += "${@bb.utils.contains('ASSUME_PROVIDED', 'git-native', '-DGIT_EXECUTABLE=/usr/bin/git', '', d)}"

0 comments on commit f119927

Please sign in to comment.