Commit e04cbd5122e710a59987cb56781dad26f5a204fd

Authored by Moritz W
1 parent 20f83ebb

Add an install for static library and a uninstall target

CMakeLists.txt
1 1 cmake_minimum_required(VERSION 2.8.3)
2 2 project(hueplusplus)
3 3  
  4 +# uninstall target
  5 +if(NOT TARGET uninstall)
  6 + configure_file(
  7 + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  8 + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  9 + IMMEDIATE @ONLY)
  10 +
  11 + add_custom_target(uninstall
  12 + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
  13 +endif()
  14 +
4 15 option(hueplusplus_TESTS "Build tests" OFF)
5 16  
6 17 if (1 AND APPLE)
... ...
cmake_uninstall.cmake.in 0 → 100644
  1 +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
  2 + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
  3 +endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
  4 +
  5 +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
  6 +string(REGEX REPLACE "\n" ";" files "${files}")
  7 +foreach(file ${files})
  8 + message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
  9 + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
  10 + exec_program(
  11 + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
  12 + OUTPUT_VARIABLE rm_out
  13 + RETURN_VALUE rm_retval
  14 + )
  15 + if(NOT "${rm_retval}" STREQUAL 0)
  16 + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
  17 + endif(NOT "${rm_retval}" STREQUAL 0)
  18 + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
  19 + message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
  20 + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
  21 +endforeach(file)
... ...
hueplusplus/CMakeLists.txt
1 1 file(GLOB hueplusplus_HEADERS *.h *.hpp)
2 2 file(GLOB hueplusplus_SOURCES *.cpp)
3 3  
4   -add_library(HuePlusPlusShared SHARED ${hueplusplus_SOURCES})
5   -set_property(TARGET HuePlusPlusShared PROPERTY CXX_STANDARD 14)
6   -set_property(TARGET HuePlusPlusShared PROPERTY CXX_EXTENSIONS OFF)
  4 +add_library(hueplusplusshared SHARED ${hueplusplus_SOURCES})
  5 +set_property(TARGET hueplusplusshared PROPERTY CXX_STANDARD 14)
  6 +set_property(TARGET hueplusplusshared PROPERTY CXX_EXTENSIONS OFF)
7 7  
8   -add_library(HuePlusPlusStatic STATIC ${hueplusplus_SOURCES})
9   -set_property(TARGET HuePlusPlusStatic PROPERTY CXX_STANDARD 14)
10   -set_property(TARGET HuePlusPlusStatic PROPERTY CXX_EXTENSIONS OFF)
  8 +add_library(hueplusplusstatic STATIC ${hueplusplus_SOURCES})
  9 +set_property(TARGET hueplusplusstatic PROPERTY CXX_STANDARD 14)
  10 +set_property(TARGET hueplusplusstatic PROPERTY CXX_EXTENSIONS OFF)
  11 +install(TARGETS hueplusplusstatic DESTINATION lib)
  12 +install(FILES ${hueplusplus_HEADERS} DESTINATION include)
... ...