2024-06-15 21:53:45 +08:00
|
|
|
cmake_minimum_required(VERSION 3.23)
|
2024-06-03 14:24:05 +08:00
|
|
|
project(YYCC
|
|
|
|
VERSION 1.0.0
|
|
|
|
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-06-20 15:47:15 +08:00
|
|
|
# Detect MSVC IDE environment.
|
|
|
|
# If we in it, we should add configuration and build type in install path.
|
|
|
|
if (CMAKE_GENERATOR MATCHES "Visual Studio")
|
|
|
|
# Do Visual Studio specific
|
|
|
|
set(YYCC_INSTALL_PATH_LIB lib/${CMAKE_VS_PLATFORM_NAME}/$<CONFIG>)
|
|
|
|
set(YYCC_INSTALL_PATH_BIN bin/${CMAKE_VS_PLATFORM_NAME})
|
|
|
|
else()
|
|
|
|
# Other stuff
|
|
|
|
set(YYCC_INSTALL_PATH_LIB lib)
|
|
|
|
set(YYCC_INSTALL_PATH_BIN bin)
|
|
|
|
endif()
|
|
|
|
|
2024-06-03 14:24:05 +08:00
|
|
|
# Import 2 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-06-03 14:24:05 +08:00
|
|
|
# Install project package infos
|
|
|
|
# Package target
|
|
|
|
install(EXPORT YYCCommonplaceTargets
|
|
|
|
FILE YYCCommonplaceTargets.cmake
|
|
|
|
NAMESPACE YYCC::
|
|
|
|
DESTINATION lib/cmake/YYCCommonplace
|
|
|
|
)
|
|
|
|
# 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"
|
|
|
|
INSTALL_DESTINATION lib/cmake/YYCCommonplace
|
|
|
|
)
|
|
|
|
# Copy to install destination
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfig.cmake"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/YYCCommonplaceConfigVersion.cmake"
|
|
|
|
DESTINATION
|
|
|
|
lib/cmake/YYCCommonplace
|
|
|
|
)
|
|
|
|
|