File 0001-cmake-fix.patch of Package rlottie
From a6ac624dff3bc6b2985541be2b238cedd8fb7e91 Mon Sep 17 00:00:00 2001
From: Zephyr Lykos <git@mochaa.ws>
Date: Fri, 3 Nov 2023 08:08:24 +0800
Subject: [PATCH 1/2] cmake: format CMakeLists.txt, add cmake-format config
---
CMakeLists.txt | 272 ++++++++++++++---------------
cmake-format.py | 241 +++++++++++++++++++++++++
cmake/rlottieConfig.cmake.in | 9 +-
example/CMakeLists.txt | 11 +-
inc/CMakeLists.txt | 5 +-
src/CMakeLists.txt | 1 -
src/binding/c/CMakeLists.txt | 9 +-
src/lottie/CMakeLists.txt | 26 ++-
src/lottie/zip/CMakeLists.txt | 10 +-
src/vector/CMakeLists.txt | 53 +++---
src/vector/freetype/CMakeLists.txt | 16 +-
src/vector/pixman/CMakeLists.txt | 18 +-
src/vector/stb/CMakeLists.txt | 43 ++---
test/CMakeLists.txt | 23 ++-
14 files changed, 461 insertions(+), 276 deletions(-)
create mode 100644 cmake-format.py
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 38a98622..2007647e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,31 +1,33 @@
-cmake_minimum_required( VERSION 3.3 )
+cmake_minimum_required(VERSION 3.3)
-#declare project
-project( rlottie VERSION 0.2 LANGUAGES C CXX ASM)
+# declare project
+project(
+ rlottie
+ VERSION 0.2
+ LANGUAGES C CXX ASM)
-if (NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE MinSizeRel)
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE MinSizeRel)
endif()
-if (NOT DEFINED BUILD_SHARED_LIBS)
- # Keep the previous behavior of the build system, consistent with Meson.
- set(BUILD_SHARED_LIBS ON)
+if(NOT DEFINED BUILD_SHARED_LIBS)
+ # Keep the previous behavior of the build system, consistent with Meson.
+ set(BUILD_SHARED_LIBS ON)
endif()
-#declare target
-add_library( rlottie )
-set_target_properties( rlottie PROPERTIES DEFINE_SYMBOL RLOTTIE_BUILD )
+# declare target
+add_library(rlottie)
+set_target_properties(rlottie PROPERTIES DEFINE_SYMBOL RLOTTIE_BUILD)
-#declare version of the target
+# declare version of the target
set(player_version_major 0)
set(player_version_minor 2)
set(player_version ${player_version_major}.${player_version_minor})
-set_target_properties(rlottie PROPERTIES
- VERSION ${player_version}
- SOVERSION ${player_version_major}
- )
+set_target_properties(rlottie PROPERTIES VERSION ${player_version}
+ SOVERSION ${player_version_major})
-#declare alias so that library can be used inside the build tree, e.g. when testing
+# declare alias so that library can be used inside the build tree, e.g. when
+# testing
add_library(rlottie::rlottie ALIAS rlottie)
option(LOTTIE_MODULE "Enable LOTTIE MODULE SUPPORT" ON)
@@ -35,169 +37,153 @@ option(LOTTIE_TEST "Build LOTTIE AUTOTESTS" OFF)
option(LOTTIE_CCACHE "Enable LOTTIE ccache SUPPORT" OFF)
option(LOTTIE_ASAN "Compile with asan" OFF)
-set(LOTTIE_MODULE_PATH "${CMAKE_SHARED_LIBRARY_PREFIX}rlottie-image-loader${CMAKE_SHARED_LIBRARY_SUFFIX}"
+set(LOTTIE_MODULE_PATH
+ "${CMAKE_SHARED_LIBRARY_PREFIX}rlottie-image-loader${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE STRING "Absolute or relative path to dynamic loader plugin.")
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in config.h)
-target_include_directories(rlottie
- PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
- PRIVATE
- "${CMAKE_CURRENT_BINARY_DIR}"
- )
+target_include_directories(
+ rlottie
+ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
+ PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
-#declare common target compilation options
+# declare common target compilation options
if(MSVC)
- target_compile_options(rlottie
- PUBLIC
- PRIVATE
- /std:c++14
- /EHs-c- # disable exceptions
- /GR- # disable RTTI
- /W3
- )
+ target_compile_options(
+ rlottie
+ PUBLIC
+ PRIVATE /std:c++14 /EHs-c- # disable exceptions
+ /GR- # disable RTTI
+ /W3)
else()
- target_compile_options(rlottie
- PUBLIC
- PRIVATE
- -std=c++14
- -fno-exceptions
- -fno-unwind-tables
- -fno-asynchronous-unwind-tables
- -fno-rtti
- -Wall
- -fvisibility=hidden
- -Wnon-virtual-dtor
- -Woverloaded-virtual
- -Wno-unused-parameter
- )
+ target_compile_options(
+ rlottie
+ PUBLIC
+ PRIVATE -std=c++14
+ -fno-exceptions
+ -fno-unwind-tables
+ -fno-asynchronous-unwind-tables
+ -fno-rtti
+ -Wall
+ -fvisibility=hidden
+ -Wnon-virtual-dtor
+ -Woverloaded-virtual
+ -Wno-unused-parameter)
endif()
-if (WIN32 AND NOT BUILD_SHARED_LIBS)
- target_compile_definitions(rlottie PUBLIC -DRLOTTIE_BUILD=0)
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+if(WIN32 AND NOT BUILD_SHARED_LIBS)
+ target_compile_definitions(rlottie PUBLIC -DRLOTTIE_BUILD=0)
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
-#declare dependancy
-set( CMAKE_THREAD_PREFER_PTHREAD TRUE )
-find_package( Threads )
+# declare dependancy
+set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+find_package(Threads)
-target_link_libraries(rlottie
- PUBLIC
- "${CMAKE_THREAD_LIBS_INIT}"
- )
+target_link_libraries(rlottie PUBLIC "${CMAKE_THREAD_LIBS_INIT}")
-if (NOT APPLE AND NOT WIN32)
- target_link_libraries(rlottie
- PRIVATE
- "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/rlottie.expmap"
- )
+if(NOT APPLE AND NOT WIN32)
+ target_link_libraries(
+ rlottie
+ PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/rlottie.expmap")
endif()
-if (LOTTIE_MODULE)
- # for dlopen, dlsym and dlclose dependancy
- target_link_libraries(rlottie PRIVATE ${CMAKE_DL_LIBS})
+if(LOTTIE_MODULE)
+ # for dlopen, dlsym and dlclose dependancy
+ target_link_libraries(rlottie PRIVATE ${CMAKE_DL_LIBS})
endif()
-if (NOT LOTTIE_ASAN)
- if(APPLE)
- target_link_libraries(rlottie
- PUBLIC
- "-Wl, -undefined error"
- )
- elseif(NOT MSVC)
- target_link_libraries(rlottie
- PUBLIC
- "-Wl,--no-undefined"
- )
- endif()
+if(NOT LOTTIE_ASAN)
+ if(APPLE)
+ target_link_libraries(rlottie PUBLIC "-Wl, -undefined error")
+ elseif(NOT MSVC)
+ target_link_libraries(rlottie PUBLIC "-Wl,--no-undefined")
+ endif()
endif()
-if (LOTTIE_CCACHE)
- find_program(CCACHE_FOUND ccache)
- if (CCACHE_FOUND)
- message(STATUS "Found ccache")
- set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
- set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
- else()
- message(STATUS "Could NOT find ccache (this is NOT an error)")
- endif()
+if(LOTTIE_CCACHE)
+ find_program(CCACHE_FOUND ccache)
+ if(CCACHE_FOUND)
+ message(STATUS "Found ccache")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+ else()
+ message(STATUS "Could NOT find ccache (this is NOT an error)")
+ endif()
endif()
-if (LOTTIE_ASAN)
- target_compile_options(rlottie PUBLIC -fsanitize=address)
- target_link_options(rlottie PUBLIC -fsanitize=address)
+if(LOTTIE_ASAN)
+ target_compile_options(rlottie PUBLIC -fsanitize=address)
+ target_link_options(rlottie PUBLIC -fsanitize=address)
endif()
-if (NOT LIB_INSTALL_DIR)
- set (LIB_INSTALL_DIR "/usr/lib")
-endif (NOT LIB_INSTALL_DIR)
+if(NOT LIB_INSTALL_DIR)
+ set(LIB_INSTALL_DIR "/usr/lib")
+endif(NOT LIB_INSTALL_DIR)
-#declare source and include files
+# declare source and include files
add_subdirectory(inc)
add_subdirectory(src)
add_subdirectory(example)
-if (LOTTIE_TEST)
- enable_testing()
- add_subdirectory(test)
+if(LOTTIE_TEST)
+ enable_testing()
+ add_subdirectory(test)
endif()
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_DIR ${PREFIX})
-SET(LIBDIR ${LIB_INSTALL_DIR})
-SET(INCDIR ${PREFIX}/include)
+set(PREFIX ${CMAKE_INSTALL_PREFIX})
+set(EXEC_DIR ${PREFIX})
+set(LIBDIR ${LIB_INSTALL_DIR})
+set(INCDIR ${PREFIX}/include)
-CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
+ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-
-#install header
-install(FILES
- inc/rlottie.h
- inc/rlottie_capi.h
- inc/rlottiecommon.h
+# install header
+install(FILES inc/rlottie.h inc/rlottie_capi.h inc/rlottiecommon.h
DESTINATION include)
-#install lib
-install( TARGETS rlottie EXPORT rlottie-targets
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
- INCLUDES DESTINATION include
- )
-
-#install config file.
+# install lib
+install(
+ TARGETS rlottie
+ EXPORT rlottie-targets
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ INCLUDES
+ DESTINATION include)
-install( EXPORT rlottie-targets
- FILE rlottieTargets.cmake
- NAMESPACE rlottie::
- DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
- )
+# install config file.
+install(
+ EXPORT rlottie-targets
+ FILE rlottieTargets.cmake
+ NAMESPACE rlottie::
+ DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie)
-#Create a ConfigVersion.cmake file
+# Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
- VERSION ${PROJECT_VERSION}
- COMPATIBILITY AnyNewerVersion
-)
-
-configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/rlottieConfig.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
- INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
-)
-
-#Install the config, configversion and custom find modules
-install(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
- DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
-)
-
-
-export(EXPORT rlottie-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/rlottieTargets.cmake NAMESPACE rlottie::)
-
-#Register package in user's package registry
+ ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion)
+
+configure_package_config_file(
+ ${CMAKE_CURRENT_LIST_DIR}/cmake/rlottieConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
+ INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie)
+
+# Install the config, configversion and custom find modules
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
+ DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie)
+
+export(
+ EXPORT rlottie-targets
+ FILE ${CMAKE_CURRENT_BINARY_DIR}/rlottieTargets.cmake
+ NAMESPACE rlottie::)
+
+# Register package in user's package registry
export(PACKAGE rlottie)
diff --git a/cmake-format.py b/cmake-format.py
new file mode 100644
index 00000000..3df985a2
--- /dev/null
+++ b/cmake-format.py
@@ -0,0 +1,241 @@
+# ----------------------------------
+# Options affecting listfile parsing
+# ----------------------------------
+with section("parse"):
+
+ # Specify structure for custom cmake functions
+ additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'],
+ 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}}
+
+ # Override configurations per-command where available
+ override_spec = {}
+
+ # Specify variable tags.
+ vartags = []
+
+ # Specify property tags.
+ proptags = []
+
+# -----------------------------
+# Options affecting formatting.
+# -----------------------------
+with section("format"):
+
+ # Disable formatting entirely, making cmake-format a no-op
+ disable = False
+
+ # How wide to allow formatted cmake files
+ line_width = 80
+
+ # How many spaces to tab for indent
+ tab_size = 2
+
+ # If true, lines are indented using tab characters (utf-8 0x09) instead of
+ # <tab_size> space characters (utf-8 0x20). In cases where the layout would
+ # require a fractional tab character, the behavior of the fractional
+ # indentation is governed by <fractional_tab_policy>
+ use_tabchars = False
+
+ # If <use_tabchars> is True, then the value of this variable indicates how
+ # fractional indentions are handled during whitespace replacement. If set to
+ # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
+ # to `round-up` fractional indentation is replaced with a single tab character
+ # (utf-8 0x09) effectively shifting the column to the next tabstop
+ fractional_tab_policy = 'use-space'
+
+ # If an argument group contains more than this many sub-groups (parg or kwarg
+ # groups) then force it to a vertical layout.
+ max_subgroups_hwrap = 2
+
+ # If a positional argument group contains more than this many arguments, then
+ # force it to a vertical layout.
+ max_pargs_hwrap = 6
+
+ # If a cmdline positional group consumes more than this many lines without
+ # nesting, then invalidate the layout (and nest)
+ max_rows_cmdline = 2
+
+ # If true, separate flow control names from their parentheses with a space
+ separate_ctrl_name_with_space = False
+
+ # If true, separate function names from parentheses with a space
+ separate_fn_name_with_space = False
+
+ # If a statement is wrapped to more than one line, than dangle the closing
+ # parenthesis on its own line.
+ dangle_parens = False
+
+ # If the trailing parenthesis must be 'dangled' on its on line, then align it
+ # to this reference: `prefix`: the start of the statement, `prefix-indent`:
+ # the start of the statement, plus one indentation level, `child`: align to
+ # the column of the arguments
+ dangle_align = 'prefix'
+
+ # If the statement spelling length (including space and parenthesis) is
+ # smaller than this amount, then force reject nested layouts.
+ min_prefix_chars = 4
+
+ # If the statement spelling length (including space and parenthesis) is larger
+ # than the tab width by more than this amount, then force reject un-nested
+ # layouts.
+ max_prefix_chars = 10
+
+ # If a candidate layout is wrapped horizontally but it exceeds this many
+ # lines, then reject the layout.
+ max_lines_hwrap = 2
+
+ # What style line endings to use in the output.
+ line_ending = 'unix'
+
+ # Format command names consistently as 'lower' or 'upper' case
+ command_case = 'canonical'
+
+ # Format keywords consistently as 'lower' or 'upper' case
+ keyword_case = 'unchanged'
+
+ # A list of command names which should always be wrapped
+ always_wrap = []
+
+ # If true, the argument lists which are known to be sortable will be sorted
+ # lexicographicall
+ enable_sort = True
+
+ # If true, the parsers may infer whether or not an argument list is sortable
+ # (without annotation).
+ autosort = False
+
+ # By default, if cmake-format cannot successfully fit everything into the
+ # desired linewidth it will apply the last, most agressive attempt that it
+ # made. If this flag is True, however, cmake-format will print error, exit
+ # with non-zero status code, and write-out nothing
+ require_valid_layout = False
+
+ # A dictionary mapping layout nodes to a list of wrap decisions. See the
+ # documentation for more information.
+ layout_passes = {}
+
+# ------------------------------------------------
+# Options affecting comment reflow and formatting.
+# ------------------------------------------------
+with section("markup"):
+
+ # What character to use for bulleted lists
+ bullet_char = '*'
+
+ # What character to use as punctuation after numerals in an enumerated list
+ enum_char = '.'
+
+ # If comment markup is enabled, don't reflow the first comment block in each
+ # listfile. Use this to preserve formatting of your copyright/license
+ # statements.
+ first_comment_is_literal = False
+
+ # If comment markup is enabled, don't reflow any comment block which matches
+ # this (regex) pattern. Default is `None` (disabled).
+ literal_comment_pattern = None
+
+ # Regular expression to match preformat fences in comments default=
+ # ``r'^\s*([`~]{3}[`~]*)(.*)$'``
+ fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
+
+ # Regular expression to match rulers in comments default=
+ # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
+ ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
+
+ # If a comment line matches starts with this pattern then it is explicitly a
+ # trailing comment for the preceeding argument. Default is '#<'
+ explicit_trailing_pattern = '#<'
+
+ # If a comment line starts with at least this many consecutive hash
+ # characters, then don't lstrip() them off. This allows for lazy hash rulers
+ # where the first hash char is not separated by space
+ hashruler_min_length = 10
+
+ # If true, then insert a space between the first hash char and remaining hash
+ # chars in a hash ruler, and normalize its length to fill the column
+ canonicalize_hashrulers = True
+
+ # enable comment markup parsing and reflow
+ enable_markup = True
+
+# ----------------------------
+# Options affecting the linter
+# ----------------------------
+with section("lint"):
+
+ # a list of lint codes to disable
+ disabled_codes = []
+
+ # regular expression pattern describing valid function names
+ function_pattern = '[0-9a-z_]+'
+
+ # regular expression pattern describing valid macro names
+ macro_pattern = '[0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with global
+ # (cache) scope
+ global_var_pattern = '[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with global
+ # scope (but internal semantic)
+ internal_var_pattern = '_[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with local
+ # scope
+ local_var_pattern = '[a-z][a-z0-9_]+'
+
+ # regular expression pattern describing valid names for privatedirectory
+ # variables
+ private_var_pattern = '_[0-9a-z_]+'
+
+ # regular expression pattern describing valid names for public directory
+ # variables
+ public_var_pattern = '[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for function/macro
+ # arguments and loop variables.
+ argument_var_pattern = '[a-z][a-z0-9_]+'
+
+ # regular expression pattern describing valid names for keywords used in
+ # functions or macros
+ keyword_pattern = '[A-Z][0-9A-Z_]+'
+
+ # In the heuristic for C0201, how many conditionals to match within a loop in
+ # before considering the loop a parser.
+ max_conditionals_custom_parser = 2
+
+ # Require at least this many newlines between statements
+ min_statement_spacing = 1
+
+ # Require no more than this many newlines between statements
+ max_statement_spacing = 2
+ max_returns = 6
+ max_branches = 12
+ max_arguments = 5
+ max_localvars = 15
+ max_statements = 50
+
+# -------------------------------
+# Options affecting file encoding
+# -------------------------------
+with section("encode"):
+
+ # If true, emit the unicode byte-order mark (BOM) at the start of the file
+ emit_byteorder_mark = False
+
+ # Specify the encoding of the input file. Defaults to utf-8
+ input_encoding = 'utf-8'
+
+ # Specify the encoding of the output file. Defaults to utf-8. Note that cmake
+ # only claims to support utf-8 so be careful when using anything else
+ output_encoding = 'utf-8'
+
+# -------------------------------------
+# Miscellaneous configurations options.
+# -------------------------------------
+with section("misc"):
+
+ # A dictionary containing any per-command configuration overrides. Currently
+ # only `command_case` is supported.
+ per_command = {}
+
diff --git a/cmake/rlottieConfig.cmake.in b/cmake/rlottieConfig.cmake.in
index 730672a1..9d5f4df7 100644
--- a/cmake/rlottieConfig.cmake.in
+++ b/cmake/rlottieConfig.cmake.in
@@ -3,14 +3,15 @@ include(CMakeFindDependencyMacro)
list(APPEND CMAKE_MODULE_PATH ${rlottie_CMAKE_DIR})
-# NOTE Had to use find_package because find_dependency does not support COMPONENTS or MODULE until 3.8.0
+# NOTE Had to use find_package because find_dependency does not support
+# COMPONENTS or MODULE until 3.8.0
-#find_dependency(RapidJSON 1.0 REQUIRED MODULE)
-#find_package(Boost 1.55 REQUIRED COMPONENTS regex)
+# find_dependency(RapidJSON 1.0 REQUIRED MODULE) find_package(Boost 1.55
+# REQUIRED COMPONENTS regex)
list(REMOVE_AT CMAKE_MODULE_PATH -1)
if(NOT TARGET rlottie::rlottie)
- include("${rlottie_CMAKE_DIR}/rlottieTargets.cmake")
+ include("${rlottie_CMAKE_DIR}/rlottieTargets.cmake")
endif()
set(rlottie_LIBRARIES rlottie::rlottie)
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index aacdc7c0..758dd5a2 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -1,17 +1,12 @@
add_executable(lottie2gif "lottie2gif.cpp")
if(MSVC)
- target_compile_options(lottie2gif
- PRIVATE
- /std:c++14)
+ target_compile_options(lottie2gif PRIVATE /std:c++14)
else()
- target_compile_options(lottie2gif
- PRIVATE
- -std=c++14)
+ target_compile_options(lottie2gif PRIVATE -std=c++14)
endif()
target_link_libraries(lottie2gif rlottie)
target_include_directories(lottie2gif
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/../inc/")
+ PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../inc/")
diff --git a/inc/CMakeLists.txt b/inc/CMakeLists.txt
index 96114430..34f3de1b 100644
--- a/inc/CMakeLists.txt
+++ b/inc/CMakeLists.txt
@@ -1,4 +1 @@
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8bdefec0..820cd199 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,3 @@
-
add_subdirectory(vector)
add_subdirectory(lottie)
diff --git a/src/binding/c/CMakeLists.txt b/src/binding/c/CMakeLists.txt
index 30a049ad..37a9bb0b 100644
--- a/src/binding/c/CMakeLists.txt
+++ b/src/binding/c/CMakeLists.txt
@@ -1,9 +1,4 @@
target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/lottieanimation_capi.cpp"
- )
+ PRIVATE "${CMAKE_CURRENT_LIST_DIR}/lottieanimation_capi.cpp")
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/lottie/CMakeLists.txt b/src/lottie/CMakeLists.txt
index a5895b0a..ec071120 100644
--- a/src/lottie/CMakeLists.txt
+++ b/src/lottie/CMakeLists.txt
@@ -1,18 +1,14 @@
add_subdirectory(zip)
-target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/lottieitem.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottieitem_capi.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottieloader.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottiemodel.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottieproxymodel.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottieparser.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottieanimation.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/lottiekeypath.cpp"
- )
+target_sources(
+ rlottie
+ PRIVATE "${CMAKE_CURRENT_LIST_DIR}/lottieitem.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottieitem_capi.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottieloader.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottiemodel.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottieproxymodel.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottieparser.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottieanimation.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/lottiekeypath.cpp")
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/lottie/zip/CMakeLists.txt b/src/lottie/zip/CMakeLists.txt
index 05ed8d03..27806d0b 100644
--- a/src/lottie/zip/CMakeLists.txt
+++ b/src/lottie/zip/CMakeLists.txt
@@ -1,9 +1,3 @@
-target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/zip.cpp"
- )
+target_sources(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}/zip.cpp")
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/vector/CMakeLists.txt b/src/vector/CMakeLists.txt
index 3ae96e66..a77218c3 100644
--- a/src/vector/CMakeLists.txt
+++ b/src/vector/CMakeLists.txt
@@ -2,33 +2,28 @@ add_subdirectory(freetype)
add_subdirectory(pixman)
add_subdirectory(stb)
+target_sources(
+ rlottie
+ PRIVATE "${CMAKE_CURRENT_LIST_DIR}/vrect.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdasher.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vbrush.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vbitmap.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vpainter.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper_common.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper_sse2.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper_neon.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vrle.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vpath.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vpathmesure.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vmatrix.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/velapsedtimer.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdebug.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vinterpolator.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vbezier.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vraster.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vdrawable.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/vimageloader.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/varenaalloc.cpp")
-target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/vrect.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdasher.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vbrush.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vbitmap.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vpainter.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper_common.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper_sse2.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdrawhelper_neon.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vrle.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vpath.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vpathmesure.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vmatrix.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/velapsedtimer.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdebug.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vinterpolator.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vbezier.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vraster.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vdrawable.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/vimageloader.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/varenaalloc.cpp"
- )
-
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/vector/freetype/CMakeLists.txt b/src/vector/freetype/CMakeLists.txt
index add0d422..d19b61b6 100644
--- a/src/vector/freetype/CMakeLists.txt
+++ b/src/vector/freetype/CMakeLists.txt
@@ -1,11 +1,7 @@
-target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/v_ft_math.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/v_ft_raster.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/v_ft_stroker.cpp"
- )
+target_sources(
+ rlottie
+ PRIVATE "${CMAKE_CURRENT_LIST_DIR}/v_ft_math.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/v_ft_raster.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/v_ft_stroker.cpp")
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/vector/pixman/CMakeLists.txt b/src/vector/pixman/CMakeLists.txt
index d904ca8d..67341c60 100644
--- a/src/vector/pixman/CMakeLists.txt
+++ b/src/vector/pixman/CMakeLists.txt
@@ -1,13 +1,7 @@
+if("${ARCH}" STREQUAL "arm")
+ set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
+ target_sources(rlottie
+ PRIVATE "${CMAKE_CURRENT_LIST_DIR}/pixman-arm-neon-asm.S")
+endif("${ARCH}" STREQUAL "arm")
-IF("${ARCH}" STREQUAL "arm")
-SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
-target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/pixman-arm-neon-asm.S"
- )
-ENDIF("${ARCH}" STREQUAL "arm")
-
-target_include_directories(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}"
- )
+target_include_directories(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/src/vector/stb/CMakeLists.txt b/src/vector/stb/CMakeLists.txt
index b668b43a..5c764f71 100644
--- a/src/vector/stb/CMakeLists.txt
+++ b/src/vector/stb/CMakeLists.txt
@@ -1,31 +1,22 @@
if(LOTTIE_MODULE)
- add_library(rlottie-image-loader SHARED
- stb_image.cpp
- )
- if(NOT MSVC)
- target_compile_options(rlottie-image-loader PRIVATE
- -fvisibility=hidden
- )
- endif()
+ add_library(rlottie-image-loader SHARED stb_image.cpp)
+ if(NOT MSVC)
+ target_compile_options(rlottie-image-loader PRIVATE -fvisibility=hidden)
+ endif()
- get_filename_component(LOTTIE_MODULE_FILENAME ${LOTTIE_MODULE_PATH} NAME)
- get_filename_component(LOTTIE_MODULE_DIR ${LOTTIE_MODULE_PATH} DIRECTORY)
- if (NOT LOTTIE_MODULE_DIR)
- set(LOTTIE_MODULE_DIR ${LIB_INSTALL_DIR})
- endif()
+ get_filename_component(LOTTIE_MODULE_FILENAME ${LOTTIE_MODULE_PATH} NAME)
+ get_filename_component(LOTTIE_MODULE_DIR ${LOTTIE_MODULE_PATH} DIRECTORY)
+ if(NOT LOTTIE_MODULE_DIR)
+ set(LOTTIE_MODULE_DIR ${LIB_INSTALL_DIR})
+ endif()
- set_target_properties(rlottie-image-loader PROPERTIES
- DEFINE_SYMBOL RLOTTIE_BUILD
- PREFIX ""
- SUFFIX ""
- OUTPUT_NAME ${LOTTIE_MODULE_FILENAME}
- )
- install(TARGETS rlottie-image-loader
- LIBRARY DESTINATION ${LOTTIE_MODULE_DIR}
- )
+ set_target_properties(
+ rlottie-image-loader
+ PROPERTIES DEFINE_SYMBOL RLOTTIE_BUILD
+ PREFIX ""
+ SUFFIX ""
+ OUTPUT_NAME ${LOTTIE_MODULE_FILENAME})
+ install(TARGETS rlottie-image-loader LIBRARY DESTINATION ${LOTTIE_MODULE_DIR})
else()
- target_sources(rlottie
- PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/stb_image.cpp"
- )
+ target_sources(rlottie PRIVATE "${CMAKE_CURRENT_LIST_DIR}/stb_image.cpp")
endif()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index de784113..14207b2c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -4,17 +4,22 @@ find_package(GTest REQUIRED)
add_definitions(-DDEMO_DIR="${CMAKE_SOURCE_DIR}/example/resource/")
link_libraries(GTest::GTest GTest::Main)
-add_executable(vectorTestSuite testsuite.cpp test_vrect.cpp test_vpath.cpp
- ${CMAKE_SOURCE_DIR}/src/vector/vbezier.cpp
- ${CMAKE_SOURCE_DIR}/src/vector/vdebug.cpp
- ${CMAKE_SOURCE_DIR}/src/vector/vmatrix.cpp
- ${CMAKE_SOURCE_DIR}/src/vector/vpath.cpp)
-target_include_directories(vectorTestSuite PRIVATE ${CMAKE_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/src/vector ${CMAKE_SOURCE_DIR}/src/vector/pixman)
+add_executable(
+ vectorTestSuite
+ testsuite.cpp
+ test_vrect.cpp
+ test_vpath.cpp
+ ${CMAKE_SOURCE_DIR}/src/vector/vbezier.cpp
+ ${CMAKE_SOURCE_DIR}/src/vector/vdebug.cpp
+ ${CMAKE_SOURCE_DIR}/src/vector/vmatrix.cpp
+ ${CMAKE_SOURCE_DIR}/src/vector/vpath.cpp)
+target_include_directories(
+ vectorTestSuite PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src/vector
+ ${CMAKE_SOURCE_DIR}/src/vector/pixman)
gtest_add_tests(vectorTestSuite "" AUTO)
-add_executable(animationTestSuite testsuite.cpp
- test_lottieanimation.cpp test_lottieanimation_capi.cpp)
+add_executable(animationTestSuite testsuite.cpp test_lottieanimation.cpp
+ test_lottieanimation_capi.cpp)
target_include_directories(animationTestSuite PRIVATE ${CMAKE_SOURCE_DIR}/inc)
target_link_libraries(animationTestSuite PRIVATE rlottie)
gtest_add_tests(animationTestSuite "" AUTO)
From 1c2988be3575142ae29b1e2d29bfd3e602bb0d62 Mon Sep 17 00:00:00 2001
From: Zephyr Lykos <git@mochaa.ws>
Date: Fri, 3 Nov 2023 08:38:46 +0800
Subject: [PATCH 2/2] cmake: Use more standard definitions
---
CMakeLists.txt | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2007647e..e38b9d04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,8 @@ project(
VERSION 0.2
LANGUAGES C CXX ASM)
+include(GNUInstallDirs)
+
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE MinSizeRel)
endif()
@@ -20,11 +22,11 @@ add_library(rlottie)
set_target_properties(rlottie PROPERTIES DEFINE_SYMBOL RLOTTIE_BUILD)
# declare version of the target
-set(player_version_major 0)
-set(player_version_minor 2)
-set(player_version ${player_version_major}.${player_version_minor})
-set_target_properties(rlottie PROPERTIES VERSION ${player_version}
- SOVERSION ${player_version_major})
+set(PLAYER_VERSION_MAJOR 0)
+set(PLAYER_VERSION_MINOR 2)
+set(PLAYER_VERSION ${PLAYER_VERSION_MAJOR}.${PLAYER_VERSION_MINOR})
+set_target_properties(rlottie PROPERTIES VERSION ${PLAYER_VERSION}
+ SOVERSION ${PLAYER_VERSION_MAJOR})
# declare alias so that library can be used inside the build tree, e.g. when
# testing
@@ -119,41 +121,33 @@ if(LOTTIE_ASAN)
target_link_options(rlottie PUBLIC -fsanitize=address)
endif()
-if(NOT LIB_INSTALL_DIR)
- set(LIB_INSTALL_DIR "/usr/lib")
-endif(NOT LIB_INSTALL_DIR)
-
# declare source and include files
add_subdirectory(inc)
add_subdirectory(src)
add_subdirectory(example)
-if(LOTTIE_TEST)
- enable_testing()
+include(CTest)
+
+if(BUILD_TESTING)
add_subdirectory(test)
endif()
-set(PREFIX ${CMAKE_INSTALL_PREFIX})
-set(EXEC_DIR ${PREFIX})
-set(LIBDIR ${LIB_INSTALL_DIR})
-set(INCDIR ${PREFIX}/include)
-
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
- DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# install header
install(FILES inc/rlottie.h inc/rlottie_capi.h inc/rlottiecommon.h
- DESTINATION include)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# install lib
install(
TARGETS rlottie
EXPORT rlottie-targets
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES
- DESTINATION include)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# install config file.
@@ -161,7 +155,7 @@ install(
EXPORT rlottie-targets
FILE rlottieTargets.cmake
NAMESPACE rlottie::
- DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rlottie)
# Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
@@ -173,12 +167,12 @@ write_basic_package_version_file(
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/rlottieConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
- INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie)
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rlottie)
# Install the config, configversion and custom find modules
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
- DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rlottie)
export(
EXPORT rlottie-targets