2024-06-15 21:53:45 +08:00
|
|
|
cmake_minimum_required(VERSION 3.23)
|
2024-06-03 14:24:05 +08:00
|
|
|
project(YYCC
|
2024-07-06 15:28:30 +08:00
|
|
|
VERSION 1.1.0
|
2024-06-03 14:24:05 +08:00
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
2024-05-29 23:11:52 +08:00
|
|
|
|
2024-06-06 13:16:55 +08:00
|
|
|
# Provide options
|
|
|
|
option(YYCC_BUILD_TESTBENCH "Build testbench of YYCCommonplace." OFF)
|
2024-06-12 15:48:20 +08:00
|
|
|
option(YYCC_BUILD_DOC "Build document of YYCCommonplace." OFF)
|
2024-06-06 13:16:55 +08:00
|
|
|
|
2024-07-22 13:56:00 +08:00
|
|
|
# Setup install path from CMake provided install path for convenient use.
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
set(YYCC_INSTALL_INCLUDE_PATH ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH
|
|
|
|
"Public header install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
|
|
|
set(YYCC_INSTALL_LIB_PATH ${CMAKE_INSTALL_LIBDIR} CACHE PATH
|
|
|
|
"Library install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
|
|
|
set(YYCC_INSTALL_BIN_PATH ${CMAKE_INSTALL_BINDIR} CACHE PATH
|
|
|
|
"Binary install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
|
|
|
set(YYCC_INSTALL_DOC_PATH ${CMAKE_INSTALL_DOCDIR} CACHE PATH
|
|
|
|
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
2024-06-20 15:47:15 +08:00
|
|
|
|
2024-07-22 13:56:00 +08:00
|
|
|
# Import 3 build targets
|
2024-05-29 23:11:52 +08:00
|
|
|
add_subdirectory(src)
|
2024-06-06 13:16:55 +08:00
|
|
|
if (YYCC_BUILD_TESTBENCH)
|
|
|
|
add_subdirectory(testbench)
|
|
|
|
endif ()
|
2024-06-12 15:48:20 +08:00
|
|
|
if (YYCC_BUILD_DOC)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif ()
|
2024-05-29 23:11:52 +08:00
|
|
|
|
2024-07-22 13:56:00 +08:00
|
|
|
# Install target and package
|
|
|
|
# Install target
|
2024-06-03 14:24:05 +08:00
|
|
|
install(EXPORT YYCCommonplaceTargets
|
|
|
|
FILE YYCCommonplaceTargets.cmake
|
|
|
|
NAMESPACE YYCC::
|
2024-07-22 13:56:00 +08:00
|
|
|
DESTINATION ${YYCC_INSTALL_LIB_PATH}/cmake/YYCCommonplace
|
2024-06-03 14:24:05 +08:00
|
|
|
)
|
|
|
|
# Package configuration file
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
write_basic_package_version_file(
|
|
|
|
YYCCommonplaceConfigVersion.cmake
|
|
|
|
VERSION ${PACKAGE_VERSION}
|
|
|
|
COMPATIBILITY SameMinorVersion
|
|
|
|
)
|
|
|
|
configure_package_config_file(
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/cmake/YYCCommonplaceConfig.cmake.in
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfig.cmake"
|
2024-07-22 13:56:00 +08:00
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/YYCCommonplace
|
2024-06-03 14:24:05 +08:00
|
|
|
)
|
2024-07-22 13:56:00 +08:00
|
|
|
# Copy package files to install destination
|
2024-06-03 14:24:05 +08:00
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfig.cmake"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfigVersion.cmake"
|
|
|
|
DESTINATION
|
2024-07-22 13:56:00 +08:00
|
|
|
${CMAKE_INSTALL_LIBDIR}/cmake/YYCCommonplace
|
2024-06-03 14:24:05 +08:00
|
|
|
)
|
|
|
|
|