2024-11-03 18:52:02 +08:00
|
|
|
# Configure version file
|
|
|
|
configure_file(
|
2025-06-20 23:38:34 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/yycc/version.hpp.in
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/yycc/version.hpp
|
2024-11-03 18:52:02 +08:00
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
2024-05-29 23:11:52 +08:00
|
|
|
# Create static library
|
2024-06-03 14:24:05 +08:00
|
|
|
add_library(YYCCommonplace STATIC "")
|
|
|
|
# Setup static library sources
|
|
|
|
target_sources(YYCCommonplace
|
|
|
|
PRIVATE
|
2024-06-15 21:53:45 +08:00
|
|
|
# Sources
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/string/reinterpret.cpp
|
|
|
|
yycc/string/op.cpp
|
2025-06-23 16:22:55 +08:00
|
|
|
yycc/rust/panic.cpp
|
2025-07-01 11:00:09 +08:00
|
|
|
yycc/patch/path.cpp
|
2025-07-23 16:05:53 +08:00
|
|
|
yycc/encoding/stlcvt.cpp
|
2025-07-02 10:36:33 +08:00
|
|
|
yycc/encoding/windows.cpp
|
|
|
|
yycc/encoding/iconv.cpp
|
2025-07-15 16:17:59 +08:00
|
|
|
yycc/encoding/pycodec.cpp
|
2025-06-20 23:38:34 +08:00
|
|
|
# YYCC/COMHelper.cpp
|
|
|
|
# YYCC/ArgParser.cpp
|
|
|
|
# YYCC/ConfigManager.cpp
|
|
|
|
# YYCC/ConsoleHelper.cpp
|
|
|
|
# YYCC/DialogHelper.cpp
|
|
|
|
# YYCC/EncodingHelper.cpp
|
|
|
|
# YYCC/ExceptionHelper.cpp
|
|
|
|
# YYCC/StdPatch.cpp
|
|
|
|
# YYCC/IOHelper.cpp
|
|
|
|
# YYCC/StringHelper.cpp
|
|
|
|
# YYCC/WinFctHelper.cpp
|
|
|
|
# # Natvis (only for MSVC)
|
|
|
|
# $<$<CXX_COMPILER_ID:MSVC>:YYCC.natvis>
|
2024-06-15 21:53:45 +08:00
|
|
|
)
|
|
|
|
target_sources(YYCCommonplace
|
|
|
|
PUBLIC
|
|
|
|
FILE_SET HEADERS
|
|
|
|
FILES
|
2024-06-03 14:24:05 +08:00
|
|
|
# Headers
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc.hpp
|
|
|
|
yycc/version.hpp
|
|
|
|
yycc/prelude/core.hpp
|
|
|
|
yycc/prelude/rust.hpp
|
|
|
|
yycc/macro/version_cmp.hpp
|
2025-06-22 19:53:49 +08:00
|
|
|
yycc/macro/feature_probe.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/macro/os_detector.hpp
|
2025-07-23 10:18:01 +08:00
|
|
|
yycc/macro/endian_detector.hpp
|
|
|
|
yycc/macro/compiler_detector.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/macro/class_copy_move.hpp
|
|
|
|
yycc/string.hpp
|
|
|
|
yycc/string/reinterpret.hpp
|
|
|
|
yycc/string/op.hpp
|
2025-06-30 08:45:18 +08:00
|
|
|
yycc/num/parse.hpp
|
|
|
|
yycc/num/stringify.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/rust/primitive.hpp
|
2025-06-23 16:22:55 +08:00
|
|
|
yycc/rust/panic.hpp
|
|
|
|
yycc/rust/option.hpp
|
|
|
|
yycc/rust/result.hpp
|
2025-06-30 08:45:18 +08:00
|
|
|
yycc/rust/num/parse.hpp
|
|
|
|
yycc/rust/num/stringify.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/windows/unsafe_suppressor.hpp
|
|
|
|
yycc/windows/import_guard_head.hpp
|
|
|
|
yycc/windows/import_guard_tail.hpp
|
|
|
|
yycc/constraint.hpp
|
|
|
|
yycc/constraint/builder.hpp
|
2025-07-01 11:00:09 +08:00
|
|
|
yycc/patch/path.hpp
|
|
|
|
yycc/patch/contains.hpp
|
|
|
|
yycc/patch/starts_ends_with.hpp
|
2025-07-14 15:06:33 +08:00
|
|
|
yycc/patch/expected.hpp
|
2025-07-23 16:05:53 +08:00
|
|
|
yycc/encoding/stlcvt.hpp
|
2025-07-02 10:36:33 +08:00
|
|
|
yycc/encoding/windows.hpp
|
|
|
|
yycc/encoding/iconv.hpp
|
2025-07-15 16:17:59 +08:00
|
|
|
yycc/encoding/pycodec.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
|
|
|
|
# # Headers
|
|
|
|
# # Common headers
|
|
|
|
# YYCC/Constraints.hpp
|
|
|
|
# YYCC/COMHelper.hpp
|
|
|
|
# YYCC/ArgParser.hpp
|
|
|
|
# YYCC/ConfigManager.hpp
|
|
|
|
# YYCC/ConsoleHelper.hpp
|
|
|
|
# YYCC/DialogHelper.hpp
|
|
|
|
# YYCC/EncodingHelper.hpp
|
|
|
|
# YYCC/EnumHelper.hpp
|
|
|
|
# YYCC/ExceptionHelper.hpp
|
|
|
|
# YYCC/StdPatch.hpp
|
|
|
|
# YYCC/IOHelper.hpp
|
|
|
|
# YYCC/ParserHelper.hpp
|
|
|
|
# YYCC/StringHelper.hpp
|
|
|
|
# YYCC/WinFctHelper.hpp
|
|
|
|
# # Windows including guard pair
|
|
|
|
# YYCC/WinImportPrefix.hpp
|
|
|
|
# YYCC/WinImportSuffix.hpp
|
|
|
|
# # Internal
|
|
|
|
# YYCC/YYCCVersion.hpp
|
|
|
|
# YYCC/YYCCInternal.hpp
|
|
|
|
# # Exposed
|
|
|
|
# YYCCommonplace.hpp
|
2024-05-29 23:11:52 +08:00
|
|
|
)
|
|
|
|
# Setup header infomations
|
|
|
|
target_include_directories(YYCCommonplace
|
|
|
|
PUBLIC
|
2024-06-03 14:24:05 +08:00
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
|
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
2024-05-29 23:11:52 +08:00
|
|
|
)
|
2025-07-15 16:17:59 +08:00
|
|
|
# Link Iconv if we have import it
|
|
|
|
if (Iconv_FOUND)
|
|
|
|
target_link_libraries(YYCCommonplace
|
|
|
|
PRIVATE
|
|
|
|
Iconv::Iconv
|
|
|
|
)
|
|
|
|
endif ()
|
2024-06-17 15:10:45 +08:00
|
|
|
# Link with DbgHelp.lib on Windows
|
|
|
|
target_link_libraries(YYCCommonplace
|
|
|
|
PRIVATE
|
|
|
|
$<$<BOOL:${WIN32}>:DbgHelp.lib>
|
|
|
|
)
|
2024-05-29 23:11:52 +08:00
|
|
|
# Setup C++ standard
|
2024-08-26 11:58:20 +08:00
|
|
|
target_compile_features(YYCCommonplace PUBLIC cxx_std_17)
|
|
|
|
set_target_properties(YYCCommonplace PROPERTIES CXX_EXTENSION OFF)
|
|
|
|
# Setup macros
|
2024-05-29 23:11:52 +08:00
|
|
|
target_compile_definitions(YYCCommonplace
|
2024-07-31 20:32:11 +08:00
|
|
|
PUBLIC
|
2025-07-15 16:17:59 +08:00
|
|
|
# Debug macro. And it should populate to child projects
|
2024-07-31 20:32:11 +08:00
|
|
|
$<$<BOOL:${YYCC_DEBUG_UE_FILTER}>:YYCC_DEBUG_UE_FILTER>
|
2025-07-15 16:17:59 +08:00
|
|
|
# Iconv environment macro
|
|
|
|
$<$<BOOL:${YYCC_ENFORCE_ICONV}>:YYCC_FEAT_ICONV>
|
2025-07-23 10:18:01 +08:00
|
|
|
# OS macro
|
|
|
|
$<$<BOOL:${WIN32}>:YYCC_OS_WINDOWS>
|
|
|
|
$<$<PLATFORM_ID:Linux>:YYCC_OS_LINUX>
|
|
|
|
# Compiler macro
|
|
|
|
$<$<CXX_COMPILER_ID:GNU>:YYCC_CC_GCC>
|
|
|
|
$<$<CXX_COMPILER_ID:Clang>:YYCC_CC_CLANG>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:YYCC_CC_MSVC>
|
|
|
|
# Endian macro
|
|
|
|
$<$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},LITTLE_ENDIAN>:YYCC_ENDIAN_LITTLE>
|
|
|
|
$<$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>:YYCC_ENDIAN_BIG>
|
2024-06-09 21:34:28 +08:00
|
|
|
PRIVATE
|
2025-07-15 16:17:59 +08:00
|
|
|
# Unicode charset for private using
|
2024-06-09 21:34:28 +08:00
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:UNICODE>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
2024-05-29 23:11:52 +08:00
|
|
|
)
|
|
|
|
target_compile_options(YYCCommonplace
|
2024-08-13 09:38:12 +08:00
|
|
|
# Order build as UTF-8 in MSVC
|
2024-05-29 23:11:52 +08:00
|
|
|
PRIVATE
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
|
|
|
)
|
2024-06-03 14:24:05 +08:00
|
|
|
|
2025-07-23 10:18:01 +08:00
|
|
|
# TODO: Fix GCC stacktrace link issue
|
|
|
|
|
2024-06-20 15:47:15 +08:00
|
|
|
# Install binary and headers
|
2024-06-03 14:24:05 +08:00
|
|
|
install(TARGETS YYCCommonplace
|
|
|
|
EXPORT YYCCommonplaceTargets
|
2024-07-22 13:56:00 +08:00
|
|
|
LIBRARY DESTINATION ${YYCC_INSTALL_LIB_PATH}
|
|
|
|
ARCHIVE DESTINATION ${YYCC_INSTALL_LIB_PATH}
|
|
|
|
INCLUDES DESTINATION ${YYCC_INSTALL_INCLUDE_PATH}
|
|
|
|
FILE_SET HEADERS DESTINATION ${YYCC_INSTALL_INCLUDE_PATH}
|
2024-06-03 14:24:05 +08:00
|
|
|
)
|