diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e83b9..04df54e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(myframe) +project(myframe VERSION 0.8.1) ### gcc version if (CMAKE_COMPILER_IS_GNUCC) @@ -77,26 +77,52 @@ install(DIRECTORY tools DESTINATION .) install(DIRECTORY conf DESTINATION .) install(DIRECTORY DESTINATION ${MYFRAME_LOG_DIR}) install(DIRECTORY DESTINATION ${MYFRAME_SERVICE_DIR}) -execute_process( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE -) -execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_ID - OUTPUT_STRIP_TRAILING_WHITESPACE -) -execute_process( - COMMAND git show -s --format=%ci HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE -) install(CODE " file( WRITE ${CMAKE_INSTALL_PREFIX}/version.txt - \"${GIT_BRANCH}\n${GIT_COMMIT_ID}\n${GIT_COMMIT_DATE}\n\") + \"${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}\" + ) ") + +### package +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}") +include(CPack) + +### export cmake file +install(EXPORT "${PROJECT_NAME}Targets" + FILE "${PROJECT_NAME}Targets.cmake" + DESTINATION lib/cmake/${PROJECT_NAME} +) + +include(CMakePackageConfigHelpers) +# generate the config file that is includes the exports +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "lib/cmake/${PROJECT_NAME}" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" + COMPATIBILITY AnyNewerVersion +) + +# install the configuration file +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION lib/cmake/${PROJECT_NAME} +) + +# generate the export targets for the build tree +# needs to be after the install(TARGETS ) command +export(EXPORT "${PROJECT_NAME}Targets" + FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" +) diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 0000000..ac260c0 --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,4 @@ + +@PACKAGE_INIT@ + +include ( "${CMAKE_CURRENT_LIST_DIR}/myframeTargets.cmake" ) diff --git a/LICENSE b/LICENSE index efd643f..d9876b9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 李柯鹏 +Copyright (c) 2019 李柯鹏 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/version_release.md b/doc/version_release.md new file mode 100644 index 0000000..2f95042 --- /dev/null +++ b/doc/version_release.md @@ -0,0 +1,6 @@ +# 版本发布 +* 修改CMakeLists.txt中版本号 +* 提交修改 +* 合入master +* 生成版本tag并发布 + * 发布tag中详细描述版本更新内容 diff --git a/myframe/CMakeLists.txt b/myframe/CMakeLists.txt index aecfc05..5bb041c 100644 --- a/myframe/CMakeLists.txt +++ b/myframe/CMakeLists.txt @@ -5,6 +5,11 @@ aux_source_directory(. __srcs) ### lib add_library(${PROJECT_NAME} SHARED ${__srcs}) +target_include_directories(${PROJECT_NAME} + INTERFACE + $ + $ +) ### install file(GLOB header_files @@ -26,7 +31,6 @@ install(FILES DESTINATION ${MYFRAME_INC_DIR}/${PROJECT_NAME} ) install(TARGETS ${PROJECT_NAME} - LIBRARY DESTINATION ${MYFRAME_LIB_DIR} - ARCHIVE DESTINATION ${MYFRAME_LIB_DIR} - RUNTIME DESTINATION ${MYFRAME_BIN_DIR} + DESTINATION lib + EXPORT "${PROJECT_NAME}Targets" )