better cmake scripts

This commit is contained in:
lganzzzo 2019-01-25 16:38:19 +02:00
parent 6d6af2c0c3
commit cc90da292c
5 changed files with 35 additions and 9 deletions

View File

@ -29,3 +29,7 @@ if(OATPP_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if(OATPP_INSTALL)
include("cmake/module-install.cmake")
endif()

View File

@ -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/<dirs>)
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}"

View File

@ -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()

21
utility/module-uninstall.sh Executable file
View File

@ -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"