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-08-05 10:54:15 +08:00
|
|
|
yycc/patch/fopen.cpp
|
2025-06-23 16:22:55 +08:00
|
|
|
yycc/rust/panic.cpp
|
2025-08-14 20:17:02 +08:00
|
|
|
yycc/rust/env.cpp
|
2025-08-13 15:29:47 +08:00
|
|
|
yycc/windows/com.cpp
|
|
|
|
#yycc/windows/dialog.cpp
|
|
|
|
yycc/windows/winfct.cpp
|
2025-08-12 09:45:44 +08:00
|
|
|
yycc/encoding/stl.cpp
|
2025-07-02 10:36:33 +08:00
|
|
|
yycc/encoding/windows.cpp
|
|
|
|
yycc/encoding/iconv.cpp
|
2025-08-12 16:32:59 +08:00
|
|
|
|
|
|
|
yycc/carton/pycodec.cpp
|
2025-08-19 13:50:51 +08:00
|
|
|
yycc/carton/termcolor.cpp
|
2025-08-15 16:42:28 +08:00
|
|
|
yycc/carton/wcwidth.cpp
|
2025-08-19 20:53:51 +08:00
|
|
|
yycc/carton/tabulate.cpp
|
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/macro/version_cmp.hpp
|
|
|
|
yycc/macro/os_detector.hpp
|
2025-07-31 22:25:14 +08:00
|
|
|
yycc/macro/stl_detector.hpp
|
2025-07-23 10:18:01 +08:00
|
|
|
yycc/macro/endian_detector.hpp
|
|
|
|
yycc/macro/compiler_detector.hpp
|
2025-08-05 10:54:15 +08:00
|
|
|
yycc/macro/ptr_size_detector.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/macro/class_copy_move.hpp
|
2025-08-04 22:31:37 +08:00
|
|
|
yycc/flag_enum.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/string/reinterpret.hpp
|
|
|
|
yycc/string/op.hpp
|
2025-08-05 10:54:15 +08:00
|
|
|
yycc/patch/ptr_pad.hpp
|
|
|
|
yycc/patch/fopen.hpp
|
2025-06-30 08:45:18 +08:00
|
|
|
yycc/num/parse.hpp
|
|
|
|
yycc/num/stringify.hpp
|
2025-08-05 13:53:59 +08:00
|
|
|
yycc/num/safe_cast.hpp
|
|
|
|
yycc/num/safe_op.hpp
|
|
|
|
yycc/num/op.hpp
|
2025-07-25 10:49:07 +08:00
|
|
|
yycc/rust/prelude.hpp
|
|
|
|
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-08-14 20:17:02 +08:00
|
|
|
yycc/rust/env.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/windows/import_guard_head.hpp
|
|
|
|
yycc/windows/import_guard_tail.hpp
|
2025-08-13 15:29:47 +08:00
|
|
|
yycc/windows/com.hpp
|
|
|
|
#yycc/windows/dialog.hpp
|
|
|
|
yycc/windows/winfct.hpp
|
2025-06-20 23:38:34 +08:00
|
|
|
yycc/constraint.hpp
|
|
|
|
yycc/constraint/builder.hpp
|
2025-08-12 09:45:44 +08:00
|
|
|
yycc/encoding/stl.hpp
|
2025-07-02 10:36:33 +08:00
|
|
|
yycc/encoding/windows.hpp
|
|
|
|
yycc/encoding/iconv.hpp
|
2025-08-12 16:32:59 +08:00
|
|
|
|
|
|
|
yycc/carton/pycodec.hpp
|
2025-08-19 13:50:51 +08:00
|
|
|
yycc/carton/termcolor.hpp
|
2025-08-15 16:42:28 +08:00
|
|
|
yycc/carton/wcwidth.hpp
|
2025-08-19 20:53:51 +08:00
|
|
|
yycc/carton/tabulate.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-08-26 11:58:20 +08:00
|
|
|
# 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
|
|
|
# Iconv environment macro
|
2025-08-05 14:04:20 +08:00
|
|
|
$<$<BOOL:${Iconv_FOUND}>:YYCC_FEAT_ICONV>
|
2025-07-23 10:18:01 +08:00
|
|
|
# OS macro
|
2025-07-31 22:25:14 +08:00
|
|
|
$<$<PLATFORM_ID:Windows>:YYCC_OS_WINDOWS>
|
2025-07-23 10:18:01 +08:00
|
|
|
$<$<PLATFORM_ID:Linux>:YYCC_OS_LINUX>
|
2025-08-19 21:47:21 +08:00
|
|
|
$<$<PLATFORM_ID:Android>:YYCC_OS_LINUX> # We brutally think Android as Linux.
|
2025-07-31 22:25:14 +08:00
|
|
|
$<$<PLATFORM_ID:Darwin>:YYCC_OS_MACOS>
|
2025-08-19 21:47:21 +08:00
|
|
|
$<$<PLATFORM_ID:iOS>:YYCC_OS_MACOS> # We brutally think iOS as macOS.
|
2025-07-23 10:18:01 +08:00
|
|
|
# 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>
|
2025-08-05 10:54:15 +08:00
|
|
|
# Pointer size macro
|
|
|
|
$<$<EQUAL:${CMAKE_SIZEOF_VOID_P},4>:YYCC_PTRSIZE_32>
|
|
|
|
$<$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>:YYCC_PTRSIZE_64>
|
2025-07-25 09:35:26 +08:00
|
|
|
# Use Unicode charset on MSVC
|
2024-06-09 21:34:28 +08:00
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:UNICODE>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
2025-07-25 09:35:26 +08:00
|
|
|
# Fix MSVC shit
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_DEPRECATE>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_WARNINGS>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_DEPRECATE>
|
|
|
|
# Fix Windows header file shit
|
|
|
|
$<$<BOOL:${WIN32}>:WIN32_LEAN_AND_MEAN>
|
|
|
|
$<$<BOOL:${WIN32}>:NOMINMAX>
|
2024-05-29 23:11:52 +08:00
|
|
|
)
|
|
|
|
target_compile_options(YYCCommonplace
|
2025-07-25 09:35:26 +08:00
|
|
|
PUBLIC
|
|
|
|
# Order build as UTF-8 in MSVC
|
2024-05-29 23:11:52 +08:00
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
2025-08-13 09:24:19 +08:00
|
|
|
# Order preprocessor conformance mode (fix __VA_OPT__ error in MSVC)
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:/Zc:preprocessor>
|
2025-08-13 15:29:47 +08:00
|
|
|
# Resolve MSVC __cplusplus macro value error.
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>
|
2024-05-29 23:11:52 +08:00
|
|
|
)
|
2024-06-03 14:24:05 +08:00
|
|
|
|
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
|
|
|
)
|