Skip to content

Commit

Permalink
Move cmake config file into subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Apr 16, 2021
1 parent fdc0d94 commit 70654e3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
38 changes: 19 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ endif()

enable_testing()

project(libcopp C CXX ASM)

set(LIBCOPP_VERSION_MAJOR "1")
set(LIBCOPP_VERSION_MINOR "3")
set(LIBCOPP_VERSION_PATCH "5")
set(LIBCOPP_VERSION "${LIBCOPP_VERSION_MAJOR}.${LIBCOPP_VERSION_MINOR}.${LIBCOPP_VERSION_PATCH}")
project(
libcopp
VERSION "1.3.5"
DESCRIPTION "Cross-platform coroutine library in C++ ."
HOMEPAGE_URL "https://libcopp.atframe.work"
LANGUAGES C CXX ASM)

# ##########################################################################################################################################
# CMake 模块 (递归包含模块, 带颜色输出模块, 平台检测模块)
Expand Down Expand Up @@ -228,7 +228,7 @@ endif()

# Install configuration
set(CMAKE_INSTALL_CMAKEDIR
"${CMAKE_INSTALL_LIBDIR}/cmake"
"${CMAKE_INSTALL_LIBDIR}/cmake/libcopp"
CACHE STRING "Directory relative to CMAKE_INSTALL to install the cmake configuration files")

configure_file("${CMAKE_CURRENT_LIST_DIR}/docs/libcopp.doxyfile.in" "${CMAKE_CURRENT_LIST_DIR}/docs/libcopp.doxyfile" @ONLY
Expand All @@ -237,27 +237,27 @@ configure_file("${CMAKE_CURRENT_LIST_DIR}/docs/libcopp.doxyfile.in" "${CMAKE_CUR
include(CMakePackageConfigHelpers)
set(INCLUDE_INSTALL_DIR include)

file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake")
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp")

configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/libcopp-config.cmake.in" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
PATH_VARS LIBCOPP_VERSION INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR PROJECT_SOURCE_DIR
"${CMAKE_CURRENT_LIST_DIR}/libcopp-config.cmake.in" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp/libcopp-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
PATH_VARS PROJECT_VERSION INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR PROJECT_SOURCE_DIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

write_basic_package_version_file(
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp-config-version.cmake"
VERSION ${LIBCOPP_VERSION}
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp/libcopp-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp-config.cmake"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp-config-version.cmake" DESTINATION ${CMAKE_INSTALL_CMAKEDIR})
install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp/libcopp-config.cmake"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/libcopp/libcopp-config-version.cmake" DESTINATION ${CMAKE_INSTALL_CMAKEDIR})

set(CPACK_PACKAGE_VENDOR "libcopp")
set(CPACK_PACKAGE_VERSION_MAJOR "${LIBCOPP_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LIBCOPP_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LIBCOPP_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "libcopp ${LIBCOPP_VERSION_MAJOR}.${LIBCOPP_VERSION_MINOR}.${LIBCOPP_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "libcopp ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION}")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://libcopp.atframe.work/")
Expand Down
8 changes: 4 additions & 4 deletions include/libcopp/utils/config/libcopp_build_features.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
#include "compile_optimize.h"
#include "compiler_features.h"

#cmakedefine LIBCOPP_VERSION_MAJOR @LIBCOPP_VERSION_MAJOR@
#cmakedefine LIBCOPP_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#ifndef LIBCOPP_VERSION_MAJOR
#define LIBCOPP_VERSION_MAJOR 0
#endif
#cmakedefine LIBCOPP_VERSION_MINOR @LIBCOPP_VERSION_MINOR@
#cmakedefine LIBCOPP_VERSION_MINOR @PROJECT_VERSION_MINOR@
#ifndef LIBCOPP_VERSION_MINOR
#define LIBCOPP_VERSION_MINOR 0
#endif
#cmakedefine LIBCOPP_VERSION_PATCH @LIBCOPP_VERSION_PATCH@
#cmakedefine LIBCOPP_VERSION_PATCH @PROJECT_VERSION_PATCH@
#ifndef LIBCOPP_VERSION_PATCH
#define LIBCOPP_VERSION_PATCH 0
#endif
#cmakedefine LIBCOPP_VERSION "@LIBCOPP_VERSION@"
#cmakedefine LIBCOPP_VERSION "@PROJECT_VERSION@"

#if defined(LIBCOPP_API_COPP_NATIVE) && LIBCOPP_API_COPP_NATIVE
#if defined(LIBCOPP_API_DLL) && LIBCOPP_API_DLL
Expand Down
2 changes: 1 addition & 1 deletion libcopp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# =============================================================================
# (To distribute this file outside of CMake, substitute the full License text for the above reference.)

set(Libcopp_VERSION "@LIBCOPP_VERSION@")
set(Libcopp_VERSION "@PROJECT_VERSION@")

@PACKAGE_INIT@

Expand Down
6 changes: 3 additions & 3 deletions src/libcopp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ if(BUILD_SHARED_LIBS OR LIBCOPP_USE_DYNAMIC_LIBRARY)
${PROJECT_LIBCOPP_LIB_LINK}
PROPERTIES C_VISIBILITY_PRESET "hidden"
CXX_VISIBILITY_PRESET "hidden"
VERSION ${LIBCOPP_VERSION}
SOVERSION ${LIBCOPP_VERSION}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION}
INTERFACE_COMPILE_DEFINITIONS LIBCOPP_API_DLL=1)
target_compile_definitions(${PROJECT_LIBCOPP_LIB_LINK} PRIVATE LIBCOPP_API_COPP_NATIVE=1 LIBCOPP_API_DLL=1)
else()
Expand All @@ -24,7 +24,7 @@ else()
${PROJECT_LIBCOPP_LIB_LINK}
PROPERTIES C_VISIBILITY_PRESET "hidden"
CXX_VISIBILITY_PRESET "hidden"
VERSION ${LIBCOPP_VERSION})
VERSION ${PROJECT_VERSION})
target_compile_definitions(${PROJECT_LIBCOPP_LIB_LINK} PRIVATE LIBCOPP_API_COPP_NATIVE=1)
endif()

Expand Down
6 changes: 3 additions & 3 deletions src/libcotask/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ if(BUILD_SHARED_LIBS OR LIBCOPP_USE_DYNAMIC_LIBRARY)
${PROJECT_LIBCOTASK_LIB_LINK}
PROPERTIES C_VISIBILITY_PRESET "hidden"
CXX_VISIBILITY_PRESET "hidden"
VERSION ${LIBCOPP_VERSION}
SOVERSION ${LIBCOPP_VERSION})
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION})
target_compile_definitions(${PROJECT_LIBCOTASK_LIB_LINK} PRIVATE LIBCOPP_API_COTASK_NATIVE=1 LIBCOPP_API_DLL=1)
set_target_properties(${PROJECT_LIBCOTASK_LIB_LINK} PROPERTIES INTERFACE_COMPILE_DEFINITIONS LIBCOPP_API_DLL=1)
else()
Expand All @@ -31,7 +31,7 @@ else()
${PROJECT_LIBCOTASK_LIB_LINK}
PROPERTIES C_VISIBILITY_PRESET "hidden"
CXX_VISIBILITY_PRESET "hidden"
VERSION ${LIBCOPP_VERSION})
VERSION ${PROJECT_VERSION})
target_compile_definitions(${PROJECT_LIBCOTASK_LIB_LINK} PRIVATE LIBCOPP_API_COTASK_NATIVE=1)
endif()

Expand Down

0 comments on commit 70654e3

Please sign in to comment.