### Generate and Install Pkg-Config File Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Generates the .pc file from a template and installs it to the pkgconfig directory. ```cmake include(cmake/GeneratePkgConfig.cmake) generate_pkg_config_pc_file(aribcaption TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libaribcaption.pc.in OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libaribcaption.pc ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libaribcaption.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) ``` -------------------------------- ### Install Project Targets Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Defines the installation rules for the aribcaption library targets, including library, archive, runtime, and header destinations. ```cmake install( TARGETS aribcaption EXPORT aribcaption-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION Library/Frameworks INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### Configure and Install Package Config Files Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Generates and installs the CMake package configuration and version files required for find_package support. ```cmake include(CMakePackageConfigHelpers) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/aribcaption-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/aribcaption-config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/aribcaption ) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/aribcaption-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/aribcaption-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/aribcaption-config-version.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/aribcaption ) ``` -------------------------------- ### Install generated config header Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Installs the generated aribcc_config.h header file from the binary directory to the project's include directory. ```cmake install( FILES ${CMAKE_CURRENT_BINARY_DIR}/include/aribcc_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aribcaption ) ``` -------------------------------- ### Install decoder-related public headers Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Installs the core decoder public header files from the source directory to the project's include directory. ```cmake install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/aribcc_export.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/aribcaption.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/aribcaption.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/caption.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/caption.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/color.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/color.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/context.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/context.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/decoder.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/decoder.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aribcaption ) ``` -------------------------------- ### Install renderer-related public headers Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Conditionally installs renderer-related public header files if the ARIBCC_NO_RENDERER option is not set. ```cmake if(NOT ARIBCC_NO_RENDERER) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/aligned_alloc.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/image.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/image.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/renderer.h ${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/renderer.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aribcaption ) endif() ``` -------------------------------- ### Include GNUInstallDirs Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Includes the standard GNUInstallDirs module to define standard installation directory variables. ```cmake include(GNUInstallDirs) ``` -------------------------------- ### Import libaribcaption with find_package Source: https://github.com/xqq/libaribcaption/blob/master/README.md Use find_package to locate an installed libaribcaption package in your CMake project. ```cmake cmake_minimum_required(VERSION 3.28) project(testarib LANGUAGES C CXX) find_package(aribcaption REQUIRED) add_executable(testarib main.cpp) target_compile_features(testarib PRIVATE cxx_std_17 ) target_include_directories(testarib PRIVATE ${ARIBCAPTION_INCLUDE_DIR} ) target_link_libraries(testarib PRIVATE aribcaption::aribcaption ) ``` -------------------------------- ### Build libaribcaption with CMake Source: https://github.com/xqq/libaribcaption/blob/master/README.md Standard commands to configure and build the library from the source directory. ```bash cd libaribcaption mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . -j8 cmake --install . # Optional ``` -------------------------------- ### Configure sample_data build properties Source: https://github.com/xqq/libaribcaption/blob/master/test/sample_data/CMakeLists.txt Sets the C11 standard, includes the header directory, and defines the runtime output directory for the library. ```cmake target_compile_features(sample_data PRIVATE c_std_11 ) target_include_directories(sample_data PRIVATE include/ ) set_target_properties(sample_data PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### CMake Project Initialization Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Sets the minimum required CMake version and defines the project name, version, description, homepage, and supported languages. ```cmake cmake_minimum_required(VERSION 3.28) project(libaribcaption VERSION 1.1.2 DESCRIPTION "Portable ARIB STD-B24 Caption Decoder/Renderer" HOMEPAGE_URL "https://github.com/xqq/libaribcaption" LANGUAGES C CXX ) ``` -------------------------------- ### Link libaribcaption with pkg-config Source: https://github.com/xqq/libaribcaption/blob/master/README.md Use pkg-config to link against either the static or shared libaribcaption library. ```bash # Link to libaribcaption static library gcc main.c -o main `pkg-config --cflags --libs --static libaribcaption` # Link to libaribcaption shared library gcc main.c -o main `pkg-config --cflags --libs libaribcaption` ``` -------------------------------- ### Configure for Windows XP support Source: https://github.com/xqq/libaribcaption/blob/master/README.md Specific configuration to support Windows XP by disabling DirectWrite and enabling GDI and FreeType. ```bash cmake .. -DCMAKE_BUILD_TYPE=Release -ARIBCC_USE_DIRECTWRITE:BOOL=OFF -DARIBCC_USE_GDI_FONT:BOOL=ON -DARIBCC_USE_FREETYPE:BOOL=ON ``` -------------------------------- ### CPack Packaging Configuration Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Sets up CPack variables for packaging, including metadata, versioning, platform-specific generators, and ignored files. ```cmake set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) set(CPACK_PACKAGE_VENDOR "magicxqq") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CMAKE_PROJECT_DESCRIPTION}) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) if(WIN32) set(CPACK_GENERATOR ZIP) set(CPACK_SOURCE_GENERATOR ZIP) else() set(CPACK_GENERATOR TGZ) set(CPACK_SOURCE_GENERATOR TGZ) endif() set(CPACK_SOURCE_IGNORE_FILES /.idea /.vs /.vscode /.git /.*build.* /out /screenshots /\\.DS_Store CMakeSettings.json compile_commands.json ) include(CPack) ``` -------------------------------- ### Build as a shared library Source: https://github.com/xqq/libaribcaption/blob/master/README.md Use the ARIBCC_SHARED_LIBRARY flag to compile libaribcaption as a shared library instead of the default static library. ```bash cmake .. -DCMAKE_BUILD_TYPE=Release -DARIBCC_SHARED_LIBRARY:BOOL=ON # or -DBUILD_SHARED_LIBS:BOOL=ON ``` -------------------------------- ### Generate configuration header with configure_file Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Uses the configure_file command to generate a header file from an input template located in the source directory. ```cmake configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/include/aribcaption/aribcc_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/include/aribcc_config.h" ) ``` -------------------------------- ### CMake configuration options Source: https://github.com/xqq/libaribcaption/blob/master/README.md List of available CMake flags to customize the build, such as disabling exceptions, RTTI, or specific renderers. ```bash ARIBCC_BUILD_TESTS:BOOL # Compile test codes inside /test. Default to OFF ARIBCC_SHARED_LIBRARY:BOOL # Compile as shared library. Default to OFF ARIBCC_NO_EXCEPTIONS:BOOL # Disable C++ Exceptions. Default to OFF ARIBCC_NO_RTTI:BOOL # Disable C++ RTTI. Default to OFF ARIBCC_NO_RENDERER:BOOL # Disable the renderer and leave only the decoder behind. Default to OFF ARIBCC_IS_ANDROID:BOOL # Indicate target platform is Android. Detected automatically by default. ARIBCC_USE_DIRECTWRITE:BOOL # Enable DirectWrite font provider & renderer. Default to ON on Windows ARIBCC_USE_GDI_FONT:BOOL # Enable GDI font provider which is necessary for WinXP support. Default to OFF. ARIBCC_USE_CORETEXT:BOOL # Enable CoreText font provider & renderer. Default to ON on macOS / iOS ARIBCC_USE_FREETYPE:BOOL # Enable FreeType based renderer. Default to ON on Linux / Android ARIBCC_USE_EMBEDDED_FREETYPE:BOOL # Use embedded FreeType instead of searching system library. Default to OFF ARIBCC_USE_FONTCONFIG:BOOL # Enable Fontconfig font provider. Default to ON on Linux and other platforms ``` -------------------------------- ### Configure Library Linking Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Links necessary system frameworks and libraries to the aribcaption target based on enabled features. ```cmake target_link_libraries(aribcaption PRIVATE $<$:${COREFOUNDATION_FRAMEWORK}> $<$:${COREGRAPHICS_FRAMEWORK}> $<$:${CORETEXT_FRAMEWORK}> $<$:ole32> $<$:d2d1> $<$:dwrite> $<$:windowscodecs> $<$:gdi32> ) # vcpkg uses optimized/debug keyword in XXXXX_LIBRARIES variables # which is incompatible with generator expressions if(ARIBCC_USE_FONTCONFIG) target_link_libraries(aribcaption PRIVATE ${Fontconfig_LIBRARIES} ) endif() if(ARIBCC_USE_FREETYPE) target_link_libraries(aribcaption PRIVATE ${FREETYPE_LIBRARIES} ) endif() ``` -------------------------------- ### CMake Configuration for test_ffmpeg Source: https://github.com/xqq/libaribcaption/blob/master/test/ffmpeg/CMakeLists.txt Configures the build environment for the test_ffmpeg executable, including finding FFmpeg libraries and setting up include directories and link libraries. ```cmake cmake_minimum_required(VERSION 3.28) find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h) find_library(AVCODEC_LIBRARY avcodec) find_path(AVFORMAT_INCLUDE_DIR libavformat/avformat.h) find_library(AVFORMAT_LIBRARY avformat) add_executable(test_ffmpeg EXCLUDE_FROM_ALL test.cpp ) target_compile_features(test_ffmpeg PRIVATE cxx_std_17 ) target_include_directories(test_ffmpeg PRIVATE ../../include ../../src ../png_writer/include ../stopwatch/include ${AVCODEC_INCLUDE_DIR} ${AVFORMAT_INCLUDE_DIR} ) target_link_libraries(test_ffmpeg PRIVATE aribcaption png_writer ${AVCODEC_LIBRARY} ${AVFORMAT_LIBRARY} ) set_target_properties(test_ffmpeg PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Import libaribcaption with add_subdirectory Source: https://github.com/xqq/libaribcaption/blob/master/README.md Use add_subdirectory to include the libaribcaption source folder directly in your CMake project. ```cmake cmake_minimum_required(VERSION 3.28) project(testarib2 LANGUAGES C CXX) set(ARIBCC_USE_FREETYPE ON CACHE BOOL "Enable FreeType") # Indicate options here (optional) add_subdirectory(thirdparty/libaribcaption) add_executable(testarib2 main.cpp) target_compile_features(testarib2 PRIVATE cxx_std_17 ) target_link_libraries(testarib2 PRIVATE aribcaption::aribcaption ) ``` -------------------------------- ### Configure Compiler Options and Definitions Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Sets platform-specific compiler flags for Apple platforms and defines preprocessor macros for the aribcaption target. ```cmake # Disable aligned allocation on Apple platforms, which is only supported on macOS 10.14 / iOS 11 or newer if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(aribcaption PRIVATE -fno-aligned-allocation ) endif() target_compile_definitions(aribcaption PRIVATE ARIBCC_IMPLEMENTATION $<$: NOMINMAX UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS > ) ``` -------------------------------- ### Define library source files with add_library Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Defines the aribcaption library by listing all necessary header and source files. ```cmake add_library(aribcaption include/aribcaption/aligned_alloc.hpp include/aribcaption/aribcaption.h include/aribcaption/aribcaption.hpp include/aribcaption/aribcc_export.h include/aribcaption/caption.h include/aribcaption/caption.hpp include/aribcaption/color.h include/aribcaption/color.hpp include/aribcaption/context.h include/aribcaption/context.hpp include/aribcaption/decoder.h include/aribcaption/decoder.hpp src/base/aligned_alloc.cpp src/base/always_inline.hpp src/base/cfstr_helper.hpp src/base/floating_helper.hpp src/base/language_code.hpp src/base/logger.cpp src/base/logger.hpp src/base/md5.c src/base/md5.h src/base/md5_helper.hpp src/base/result.hpp src/base/scoped_cfref.hpp src/base/scoped_com_initializer.hpp src/base/scoped_holder.hpp src/base/unicode_helper.hpp src/base/utf_helper.hpp src/base/wchar_helper.hpp src/common/caption_capi.cpp src/common/context.cpp src/common/context_capi.cpp src/decoder/b24_codesets.cpp src/decoder/b24_codesets.hpp src/decoder/b24_colors.cpp src/decoder/b24_colors.hpp src/decoder/b24_controlsets.hpp src/decoder/b24_conv_tables.hpp src/decoder/b24_drcs_conv.cpp src/decoder/b24_drcs_conv.hpp src/decoder/b24_gaiji_table.hpp src/decoder/b24_macros.hpp src/decoder/decoder.cpp src/decoder/decoder_capi.cpp src/decoder/decoder_impl.cpp src/decoder/decoder_impl.hpp ) ``` -------------------------------- ### Configure Include Directories Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Defines public and private include directories for the aribcaption target, including conditional paths for Fontconfig and Freetype. ```cmake target_include_directories(aribcaption PUBLIC $ $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src $<$:${Fontconfig_INCLUDE_DIRS}> $<$:${FREETYPE_INCLUDE_DIRS}> ) ``` -------------------------------- ### CMake configuration for stopwatch library Source: https://github.com/xqq/libaribcaption/blob/master/test/stopwatch/CMakeLists.txt Defines the static library target, sets the C++17 requirement, specifies include directories, and configures the output directory. ```cmake cmake_minimum_required(VERSION 3.28) add_library(stopwatch STATIC EXCLUDE_FROM_ALL include/stopwatch.hpp ) target_compile_features(stopwatch PRIVATE cxx_std_17 ) target_include_directories(stopwatch PRIVATE include/ ) set_target_properties(stopwatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### CMake configuration for test_capi Source: https://github.com/xqq/libaribcaption/blob/master/test/capi/CMakeLists.txt Defines the test_capi executable, sets C11 standard, includes necessary directories, and links against aribcaption and png_writer libraries. ```cmake cmake_minimum_required(VERSION 3.28) add_executable(test_capi EXCLUDE_FROM_ALL test.c ) target_compile_features(test_capi PRIVATE c_std_11 ) target_include_directories(test_capi PRIVATE ../../include ../png_writer/include ../sample_data/include ) target_link_libraries(test_capi PRIVATE aribcaption png_writer ) set_target_properties(test_capi PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Define sample_data static library in CMake Source: https://github.com/xqq/libaribcaption/blob/master/test/sample_data/CMakeLists.txt Initializes the sample_data library as a static target, excluding it from the default build process. ```cmake cmake_minimum_required(VERSION 3.28) add_library(sample_data STATIC EXCLUDE_FROM_ALL include/sample_data.h ) ``` -------------------------------- ### CMake configuration for test_caption2srt Source: https://github.com/xqq/libaribcaption/blob/master/test/caption2srt/CMakeLists.txt Configures the build environment by locating FFmpeg dependencies and defining the test_caption2srt executable target. ```cmake cmake_minimum_required(VERSION 3.28) find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h) find_library(AVCODEC_LIBRARY avcodec) find_path(AVFORMAT_INCLUDE_DIR libavformat/avformat.h) find_library(AVFORMAT_LIBRARY avformat) add_executable(test_caption2srt EXCLUDE_FROM_ALL main.cpp ) target_compile_features(test_caption2srt PRIVATE cxx_std_17 ) target_include_directories(test_caption2srt PRIVATE ${AVCODEC_INCLUDE_DIR} ${AVFORMAT_INCLUDE_DIR} ) target_link_libraries(test_caption2srt PRIVATE aribcaption ${AVCODEC_LIBRARY} ${AVFORMAT_LIBRARY} ) set_target_properties(test_caption2srt PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Include test subdirectories Source: https://github.com/xqq/libaribcaption/blob/master/test/CMakeLists.txt Adds various subdirectories containing test-related source code and configurations. ```cmake add_subdirectory(alphablend) add_subdirectory(capi) add_subdirectory(caption2srt) add_subdirectory(png_writer) add_subdirectory(decode) add_subdirectory(drcs) add_subdirectory(ffmpeg) add_subdirectory(fontconfig_freetype) ``` -------------------------------- ### CMake configuration for png_writer Source: https://github.com/xqq/libaribcaption/blob/master/test/png_writer/CMakeLists.txt Defines the static library target, sets C++17 requirements, includes necessary directories, and links against aribcaption and PNG libraries. ```cmake cmake_minimum_required(VERSION 3.28) find_package(PNG) add_library(png_writer STATIC EXCLUDE_FROM_ALL include/png_writer.h include/png_writer.hpp png_writer.cpp ) target_compile_features(png_writer PRIVATE cxx_std_17 ) target_include_directories(png_writer PRIVATE include/ ../../include ../../src ${PNG_INCLUDE_DIRS} ) target_link_libraries(png_writer PRIVATE aribcaption ${PNG_LIBRARIES} ) set_target_properties(png_writer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### CMake configuration for test_decode Source: https://github.com/xqq/libaribcaption/blob/master/test/decode/CMakeLists.txt Defines the test_decode executable, sets C++17 requirements, includes necessary directories, links the aribcaption library, and sets the output directory. ```cmake cmake_minimum_required(VERSION 3.28) add_executable(test_decode EXCLUDE_FROM_ALL test.cpp ) target_compile_features(test_decode PRIVATE cxx_std_17 ) target_include_directories(test_decode PRIVATE ../../include ../sample_data/include ) target_link_libraries(test_decode PRIVATE aribcaption ) set_target_properties(test_decode PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### CMake configuration for test_alphablend Source: https://github.com/xqq/libaribcaption/blob/master/test/alphablend/CMakeLists.txt Defines the test_alphablend executable, sets C++17 requirements, includes necessary directories, and links the aribcaption library. ```cmake cmake_minimum_required(VERSION 3.28) add_executable(test_alphablend EXCLUDE_FROM_ALL test.cpp ) target_compile_features(test_alphablend PRIVATE cxx_std_17 ) target_include_directories(test_alphablend PRIVATE ../../include ../../src ../stopwatch/include ) target_link_libraries(test_alphablend PRIVATE aribcaption ) set_target_properties(test_alphablend PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Main Project Detection Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Checks if the current directory is the root source directory to determine if the project is being built as a standalone project or a subproject. ```cmake if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(ARIBCC_IS_MAIN_PROJECT TRUE) endif() ``` -------------------------------- ### Enable SSE instructions for GCC/Clang Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Enables SSE and SSE2 instruction sets for x86/x64 architectures when using GNU or Clang compilers. ```cmake if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|X86|x64|X64|amd64|AMD64|i386|i686)") target_compile_options(aribcaption PRIVATE -msse -msse2 ) endif() ``` -------------------------------- ### Define library alias and compile features Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Creates an alias for the aribcaption library and enforces the C++17 standard for the target. ```cmake add_library(aribcaption::aribcaption ALIAS aribcaption) target_compile_features(aribcaption PRIVATE cxx_std_17 ) ``` -------------------------------- ### CMake configuration for test_fontconfig_freetype Source: https://github.com/xqq/libaribcaption/blob/master/test/fontconfig_freetype/CMakeLists.txt Configures the build environment for the test_fontconfig_freetype executable, including dependency resolution and target properties. ```cmake cmake_minimum_required(VERSION 3.28) if(NOT ARIBCC_USE_FREETYPE) find_package(Freetype) endif() if(NOT ARIBCC_USE_FONTCONFIG) find_package(Fontconfig) endif() add_executable(test_fontconfig_freetype EXCLUDE_FROM_ALL test.cpp ) target_compile_features(test_fontconfig_freetype PRIVATE cxx_std_17 ) target_include_directories(test_fontconfig_freetype PRIVATE ../../include ../../src ../png_writer/include ${FREETYPE_INCLUDE_DIRS} ${Fontconfig_INCLUDE_DIRS} ) target_link_libraries(test_fontconfig_freetype PRIVATE aribcaption png_writer ${FREETYPE_LIBRARIES} ${Fontconfig_LIBRARIES} ) set_target_properties(test_fontconfig_freetype PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Default Build Type Configuration Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Sets the default build type to Release if CMAKE_BUILD_TYPE is not already defined. ```cmake if(NOT CMAKE_BUILD_TYPE) message("Build type will be Release. Set CMAKE_BUILD_TYPE to indicate other types.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default to Release build" FORCE) endif() ``` -------------------------------- ### Export CMake Targets Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Exports the aribcaption targets to a CMake script file for use by other projects. ```cmake install( EXPORT aribcaption-targets FILE aribcaption-targets.cmake NAMESPACE aribcaption:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/aribcaption ) ``` -------------------------------- ### Enable UTF-8 for MSVC Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Applies the /utf-8 compiler flag specifically when using the MSVC compiler. ```cmake target_compile_options(aribcaption PRIVATE $<$:/utf-8> ) ``` -------------------------------- ### Conditionally add renderer source files Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Uses target_sources to conditionally include renderer-related header and source files based on the ARIBCC_NO_RENDERER flag and various platform-specific feature flags. ```cmake if(NOT ARIBCC_NO_RENDERER) target_sources(aribcaption PRIVATE include/aribcaption/image.h include/aribcaption/image.hpp include/aribcaption/renderer.h include/aribcaption/renderer.hpp $<$:src/base/tinyxml2.cpp> $<$:src/base/tinyxml2.h> src/renderer/alphablend.hpp src/renderer/alphablend_generic.hpp src/renderer/alphablend_x86.hpp src/renderer/bitmap.cpp src/renderer/bitmap.hpp src/renderer/canvas.cpp src/renderer/canvas.hpp src/renderer/drcs_renderer.cpp src/renderer/drcs_renderer.hpp src/renderer/font_provider.cpp src/renderer/font_provider.hpp $<$:src/renderer/font_provider_android.cpp> $<$:src/renderer/font_provider_android.hpp> $<$:src/renderer/font_provider_coretext.cpp> $<$:src/renderer/font_provider_coretext.hpp> $<$:src/renderer/font_provider_directwrite.cpp> $<$:src/renderer/font_provider_directwrite.hpp> $<$:src/renderer/font_provider_fontconfig.cpp> $<$:src/renderer/font_provider_fontconfig.hpp> $<$:src/renderer/font_provider_gdi.cpp> $<$:src/renderer/font_provider_gdi.hpp> src/renderer/image_capi.cpp src/renderer/rect.hpp src/renderer/region_renderer.cpp src/renderer/region_renderer.hpp src/renderer/renderer.cpp src/renderer/renderer_capi.cpp src/renderer/renderer_impl.cpp src/renderer/renderer_impl.hpp src/renderer/text_renderer.cpp src/renderer/text_renderer.hpp $<$:src/renderer/open_type_gsub.cpp> $<$:src/renderer/open_type_gsub.hpp> $<$:src/renderer/text_renderer_coretext.cpp> $<$:src/renderer/text_renderer_coretext.hpp> $<$:src/renderer/text_renderer_directwrite.cpp> $<$:src/renderer/text_renderer_directwrite.hpp> $<$:src/renderer/text_renderer_freetype.cpp> $<$:src/renderer/text_renderer_freetype.hpp> ) endif() ``` -------------------------------- ### CMake Configuration for test_drcs Source: https://github.com/xqq/libaribcaption/blob/master/test/drcs/CMakeLists.txt Defines the test_drcs executable, sets C++17 requirements, includes necessary directories, and links required libraries like aribcaption and png_writer. ```cmake cmake_minimum_required(VERSION 3.28) if(NOT ARIBCC_USE_FREETYPE) find_package(Freetype) endif() if(NOT ARIBCC_USE_FONTCONFIG) find_package(Fontconfig) endif() add_executable(test_drcs EXCLUDE_FROM_ALL test.cpp ) target_compile_features(test_drcs PRIVATE cxx_std_17 ) target_include_directories(test_drcs PRIVATE ../../include ../../src ../png_writer/include ../sample_data/include ${FREETYPE_INCLUDE_DIRS} ${Fontconfig_INCLUDE_DIRS} ) target_link_libraries(test_drcs PRIVATE aribcaption png_writer ${FREETYPE_LIBRARIES} ${Fontconfig_LIBRARIES} ) set_target_properties(test_drcs PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Set symbol visibility for aribcaption Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Hides non-exported symbols by setting visibility properties to hidden. ```cmake set_target_properties(aribcaption PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden ) ``` -------------------------------- ### Conditional Test Inclusion Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Adds the test subdirectory only if the project is the main project and testing is enabled. ```cmake if(ARIBCC_IS_MAIN_PROJECT AND ARIBCC_BUILD_TESTS) add_subdirectory(test EXCLUDE_FROM_ALL) endif() ``` -------------------------------- ### Disable BUILD_SHARED_LIBS Source: https://github.com/xqq/libaribcaption/blob/master/test/CMakeLists.txt Forces the BUILD_SHARED_LIBS option to OFF if it was previously enabled. ```cmake if(BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS OFF) endif() ``` -------------------------------- ### Disable C++ exceptions Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Conditionally disables C++ exceptions based on the ARIBCC_NO_EXCEPTIONS flag and the compiler type. ```cmake if(ARIBCC_NO_EXCEPTIONS) if(MSVC) string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") target_compile_options(aribcaption PRIVATE /EHs-c- ) target_compile_definitions(aribcaption PRIVATE _HAS_EXCEPTIONS=0 ) else() string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") target_compile_options(aribcaption PRIVATE $<$:-fno-exceptions> ) endif() endif() ``` -------------------------------- ### Disable C++ RTTI Source: https://github.com/xqq/libaribcaption/blob/master/CMakeLists.txt Conditionally disables Run-Time Type Information (RTTI) based on the ARIBCC_NO_RTTI flag. ```cmake if(ARIBCC_NO_RTTI) if(MSVC) string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") target_compile_options(aribcaption PUBLIC /GR- ) else() string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") target_compile_options(aribcaption PUBLIC $<$:-fno-rtti> ) endif() endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.