From 7c03ae56c901a83c8b83a769d4782dc552eb96a6 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sat, 14 Mar 2020 09:51:32 +0100 Subject: [PATCH 1/5] Add the uninstall target using uninstall-manifest --- cmake/MakeUninstall.cmake.in | 21 +++++++++++++++++++++ cmake/SfizzConfig.cmake | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 cmake/MakeUninstall.cmake.in diff --git a/cmake/MakeUninstall.cmake.in b/cmake/MakeUninstall.cmake.in new file mode 100644 index 00000000..c2d34d47 --- /dev/null +++ b/cmake/MakeUninstall.cmake.in @@ -0,0 +1,21 @@ +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}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif() + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach() diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index 81184a87..6ad1aae4 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -94,4 +94,15 @@ Compiler CXX min size flags: ${CMAKE_CXX_FLAGS_MINSIZEREL} endif() endfunction() +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MakeUninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake) +endif() + + find_package (Threads REQUIRED) From 65b2baf344ba56d1d8bd4e79839adb94a1b59470 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sat, 14 Mar 2020 09:52:41 +0100 Subject: [PATCH 2/5] No additional public header with the shared lib The public header is always installed with the static lib. --- src/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 14d469f6..f840899d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,8 +81,7 @@ if (SFIZZ_SHARED) install (TARGETS sfizz_shared RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if (UNIX AND NOT APPLE) From 35b7564c1cd0e288438e157566763cc1966e098d Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sat, 14 Mar 2020 09:53:15 +0100 Subject: [PATCH 3/5] Move pkgconfig installation with its configuration --- src/CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f840899d..38e2d67f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,8 @@ if (NOT MSVC) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) configure_file (${PROJECT_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) + install (FILES ${CMAKE_BINARY_DIR}/src/sfizz.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() if(WIN32) include(VSTConfig) @@ -90,8 +92,3 @@ if (SFIZZ_SHARED) endif() endif() endif() - -if (NOT MSVC) - install (FILES ${CMAKE_BINARY_DIR}/src/sfizz.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif() From 643acbc644c875296988e5cf227f0cb3da328c12 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sat, 14 Mar 2020 10:36:42 +0100 Subject: [PATCH 4/5] Remove the public header from the shared lib It's installed with the static one --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 38e2d67f..0247e1aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,7 +75,6 @@ if (SFIZZ_SHARED) target_compile_definitions (sfizz_shared PRIVATE _USE_MATH_DEFINES) endif() target_compile_definitions(sfizz_shared PRIVATE SFIZZ_EXPORT_SYMBOLS) - set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER "sfizz.h;sfizz.hpp") set_property (TARGET sfizz_shared PROPERTY SOVERSION ${PROJECT_VERSION_MAJOR}) sfizz_enable_lto_if_needed(sfizz_shared) From 8b639845a9f53ae48f7c755ffb925c76b17bc407 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sat, 14 Mar 2020 10:37:35 +0100 Subject: [PATCH 5/5] Move the uninstall definition at the end of the root CMakeLists and add custom commands to remove the lv2/vst directories --- CMakeLists.txt | 5 +++++ cmake/SfizzConfig.cmake | 11 ----------- cmake/SfizzUninstall.cmake | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 cmake/SfizzUninstall.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 670fd81d..55a80114 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,4 +64,9 @@ if (SFIZZ_TESTS) add_subdirectory (tests) endif() +# Put it at the end so that the vst/lv2 directories are registered +if (NOT MSVC) + include(SfizzUninstall) +endif() + show_build_info_if_needed() diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index 6ad1aae4..81184a87 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -94,15 +94,4 @@ Compiler CXX min size flags: ${CMAKE_CXX_FLAGS_MINSIZEREL} endif() endfunction() -if(NOT TARGET uninstall) - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MakeUninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake" - IMMEDIATE @ONLY) - - add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake) -endif() - - find_package (Threads REQUIRED) diff --git a/cmake/SfizzUninstall.cmake b/cmake/SfizzUninstall.cmake new file mode 100644 index 00000000..6c1d7f12 --- /dev/null +++ b/cmake/SfizzUninstall.cmake @@ -0,0 +1,19 @@ +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MakeUninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake) + + if (SFIZZ_LV2 AND LV2PLUGIN_INSTALL_DIR) + add_custom_command(TARGET uninstall + COMMAND rm -rv "${LV2PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2") + endif() + + if (SFIZZ_VST AND VSTPLUGIN_INSTALL_DIR) + add_custom_command(TARGET uninstall + COMMAND rm -rv "${VSTPLUGIN_INSTALL_DIR}/${PROJECT_NAME}.vst3") + endif() +endif()