From cc90da292cb8bc100c84c2da5b43d8c1a53df00d Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Fri, 25 Jan 2019 16:38:19 +0200 Subject: [PATCH] better cmake scripts --- CMakeLists.txt | 4 ++++ {src => cmake}/module-config.cmake.in | 0 {src => cmake}/module-install.cmake | 12 ++++++++++-- src/CMakeLists.txt | 7 ------- utility/module-uninstall.sh | 21 +++++++++++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) rename {src => cmake}/module-config.cmake.in (100%) rename {src => cmake}/module-install.cmake (89%) create mode 100755 utility/module-uninstall.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c63f266e..1d353014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,4 +28,8 @@ add_subdirectory(src) if(OATPP_BUILD_TESTS) enable_testing() add_subdirectory(test) +endif() + +if(OATPP_INSTALL) + include("cmake/module-install.cmake") endif() \ No newline at end of file diff --git a/src/module-config.cmake.in b/cmake/module-config.cmake.in similarity index 100% rename from src/module-config.cmake.in rename to cmake/module-config.cmake.in diff --git a/src/module-install.cmake b/cmake/module-install.cmake similarity index 89% rename from src/module-install.cmake rename to cmake/module-install.cmake index 15bf01d2..09b28ff4 100644 --- a/src/module-install.cmake +++ b/cmake/module-install.cmake @@ -44,6 +44,14 @@ set(OATPP_MODULE_LIBRARIES CACHE INTERNAL "oatpp module libraries" ) +####################################################################################### +## calc directories to install (relative to this script) +## dirs should be in ( relative ../src/) + +foreach(CURR_DIR ${OATPP_THIS_MODULE_DIRECTORIES}) + list(APPEND OATPP_DIRS_TO_INSTALL ${CMAKE_CURRENT_LIST_DIR}/../src/${CURR_DIR}) +endforeach() + ####################################################################################### include(GNUInstallDirs) @@ -56,7 +64,7 @@ install(TARGETS ${OATPP_THIS_MODULE_TARGETS} INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}" ) -install(DIRECTORY ${OATPP_THIS_MODULE_DIRECTORIES} +install(DIRECTORY ${OATPP_DIRS_TO_INSTALL} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}" FILES_MATCHING PATTERN "*.hpp" ) @@ -77,7 +85,7 @@ write_basic_package_version_file("${OATPP_MODULE_NAME}ConfigVersion.cmake" ## Take module-config.cmake.in file in this direcory as a template configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/module-config.cmake.in" + "${CMAKE_CURRENT_LIST_DIR}/module-config.cmake.in" "${OATPP_MODULE_NAME}Config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${OATPP_MODULE_NAME}-${OATPP_MODULE_VERSION}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea53b65b..11cfc8af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -218,10 +218,3 @@ target_include_directories(oatpp-test PUBLIC ) add_dependencies(oatpp-test oatpp) - -####################################################################################################### -## INSTALL TARGETS - -if(OATPP_INSTALL) - include("module-install.cmake") -endif() \ No newline at end of file diff --git a/utility/module-uninstall.sh b/utility/module-uninstall.sh new file mode 100755 index 00000000..6c2ef32c --- /dev/null +++ b/utility/module-uninstall.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +MODULE_NAME="oatpp" +MODULE_VERSION="0.19.1" + +echo "remove include folder: '/usr/local/include/oatpp-$MODULE_VERSION/$MODULE_NAME'" +rm -rf "/usr/local/include/oatpp-$MODULE_VERSION/$MODULE_NAME" + +echo "remove cmake package: '/usr/local/lib/cmake/$MODULE_NAME-$MODULE_VERSION'" +rm -rf "/usr/local/lib/cmake/$MODULE_NAME-$MODULE_VERSION" + +MODULE_LIB_PATH="/usr/local/lib/oatpp-$MODULE_VERSION" + +echo "remove '$MODULE_LIB_PATH/lib$MODULE_NAME.dylib'" +rm "$MODULE_LIB_PATH/lib$MODULE_NAME.dylib" + +echo "remove '$MODULE_LIB_PATH/lib$MODULE_NAME.so'" +rm "$MODULE_LIB_PATH/lib$MODULE_NAME.so" + +echo "remove '$MODULE_LIB_PATH/lib$MODULE_NAME.a'" +rm "$MODULE_LIB_PATH/lib$MODULE_NAME.a"