# Configure version file configure_file( ${CMAKE_CURRENT_LIST_DIR}/yycc/version.hpp.in ${CMAKE_CURRENT_LIST_DIR}/yycc/version.hpp @ONLY ) # Create static library add_library(YYCCommonplace STATIC "") # Setup static library sources target_sources(YYCCommonplace PRIVATE # Sources yycc/string/reinterpret.cpp yycc/string/op.cpp yycc/rust/panic.cpp yycc/encoding/stlcvt.cpp yycc/encoding/windows.cpp yycc/encoding/iconv.cpp yycc/encoding/pycodec.cpp ) target_sources(YYCCommonplace PUBLIC FILE_SET HEADERS FILES # Headers yycc.hpp yycc/version.hpp yycc/macro/version_cmp.hpp yycc/macro/os_detector.hpp yycc/macro/endian_detector.hpp yycc/macro/compiler_detector.hpp yycc/macro/class_copy_move.hpp yycc/string/reinterpret.hpp yycc/string/op.hpp yycc/num/parse.hpp yycc/num/stringify.hpp yycc/rust/prelude.hpp yycc/rust/primitive.hpp yycc/rust/panic.hpp yycc/rust/option.hpp yycc/rust/result.hpp yycc/windows/import_guard_head.hpp yycc/windows/import_guard_tail.hpp yycc/constraint.hpp yycc/constraint/builder.hpp yycc/encoding/stlcvt.hpp yycc/encoding/windows.hpp yycc/encoding/iconv.hpp yycc/encoding/pycodec.hpp ) # Setup header infomations target_include_directories(YYCCommonplace PUBLIC "$" "$" ) # Link Iconv if we have import it if (Iconv_FOUND) target_link_libraries(YYCCommonplace PRIVATE Iconv::Iconv ) endif () # Link with DbgHelp.lib on Windows target_link_libraries(YYCCommonplace PRIVATE $<$:DbgHelp.lib> ) # Setup macros target_compile_definitions(YYCCommonplace PUBLIC # Iconv environment macro $<$:YYCC_FEAT_ICONV> # OS macro $<$:YYCC_OS_WINDOWS> $<$:YYCC_OS_LINUX> # Compiler macro $<$:YYCC_CC_GCC> $<$:YYCC_CC_CLANG> $<$:YYCC_CC_MSVC> # Endian macro $<$:YYCC_ENDIAN_LITTLE> $<$:YYCC_ENDIAN_BIG> # Use Unicode charset on MSVC $<$:UNICODE> $<$:_UNICODE> # Fix MSVC shit $<$:_CRT_SECURE_NO_WARNINGS> $<$:_CRT_SECURE_NO_DEPRECATE> $<$:_CRT_NONSTDC_NO_WARNINGS> $<$:_CRT_NONSTDC_NO_DEPRECATE> # Fix Windows header file shit $<$:WIN32_LEAN_AND_MEAN> $<$:NOMINMAX> ) target_compile_options(YYCCommonplace PUBLIC # Order build as UTF-8 in MSVC $<$:/utf-8> ) # TODO: Fix GCC stacktrace link issue # Install binary and headers install(TARGETS YYCCommonplace EXPORT YYCCommonplaceTargets 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} )