From 4ac54f114e7ca27c761ee8ead3a85d6506c93759 Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 11:20:57 +0100 Subject: [PATCH 1/8] Updated infra submodule with CMake modules addition --- lib/infra | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/infra b/lib/infra index bb9090c..c52c3fe 160000 --- a/lib/infra +++ b/lib/infra @@ -1 +1 @@ -Subproject commit bb9090ceb0838e3f145c6e40b1cbc26fa48fd12e +Subproject commit c52c3fed4bf4cdc243800d84a0c0f43942cf5923 From 934480692345a5dbbd93ad07746b9a235c288d56 Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 11:23:10 +0100 Subject: [PATCH 2/8] Bump minimum CMake version to 3.18 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e19867..bb5c2ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # # Distributed under the MIT License (https://opensource.org/licenses/MIT) ############################################################################### -cmake_minimum_required(VERSION 3.7.2...3.15.0) +cmake_minimum_required(VERSION 3.18.0) include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) project(artist LANGUAGES C CXX) From 08ac063b7f274e3046ad473ac6a27f2540ee9afd Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 11:28:13 +0100 Subject: [PATCH 3/8] Move include(ExternalProject) where/if needed it will be replaced with file(DOWNLOAD|ARCHIVE_EXTRACT) or FetchContent, which work at configure time, not build time --- CMakeLists.txt | 1 - lib/CMakeLists.txt | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb5c2ab..2b844fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ # Distributed under the MIT License (https://opensource.org/licenses/MIT) ############################################################################### cmake_minimum_required(VERSION 3.18.0) -include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) project(artist LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index c2adb4c..fd2998a 100755 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -46,6 +46,8 @@ endif() if (ARTIST_SKIA) + include(ExternalProject) + ############################################################################ # Prebuilt binaries ############################################################################ From 3f99594fc11486e63f473ae1f11388648474ab44 Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 12:37:43 +0100 Subject: [PATCH 4/8] Make use of infra CMake modules --- CMakeLists.txt | 76 ++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b844fd..8400707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,51 +6,43 @@ cmake_minimum_required(VERSION 3.18.0) project(artist LANGUAGES C CXX) -set(CMAKE_CXX_STANDARD 17) if (POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() -# Ensure presence of Git submodules (when not using a source tarball) -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") - find_package(Git REQUIRED) - function(git_submodule_check dir) - if (NOT EXISTS "${dir}/CMakeLists.txt") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND_ERROR_IS_FATAL ANY) - endif() - endfunction() - git_submodule_check(lib/external/libunibreak) - git_submodule_check(lib/infra) -endif() +############################################################################### +# Settings +############################################################################### -set(DEFAULT_BUILD_TYPE "Release") -if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") - set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE - STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +# Add our CMake modules to path +list(APPEND CMAKE_MODULE_PATH + "${CMAKE_SOURCE_DIR}/lib/infra/cmake" + "${CMAKE_SOURCE_DIR}/cmake" +) +if(CMAKE_CXX_STANDARD LESS 17) + set(CMAKE_CXX_STANDARD 17) endif() +############################################################################### +# Module utilities +############################################################################### + +include(BuildType) # Default build type. +include(GitUtilities) # git_submodule_check(). +include(OptionEx) # Conditional based options, adding a [default: ON/OFF] to the documentation. include(CheckIPOSupported) -check_ipo_supported(RESULT IPO_SUPPORTED) -if (IPO_SUPPORTED) - message(STATUS "Link-time optimization supported. Will be enabled in Release build type") -endif() -if (APPLE) - option(ARTIST_QUARTZ_2D "build Artist using quartz 2d on MacOS" ON) - option(ARTIST_SKIA "build Artist using skia" OFF) -else() - option(ARTIST_SKIA "build Artist using skia" ON) +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") + git_submodule_check(lib/external/libunibreak) + git_submodule_check(lib/infra) endif() -if (ARTIST_SKIA) - set(ARTIST_QUARTZ_2D OFF) +if (CYCFI_ENABLE_LTO) + check_ipo_supported(RESULT IPO_SUPPORTED) + if (IPO_SUPPORTED) + message(STATUS "Link-time optimization supported. Will be enabled in Release build type") + endif() endif() if (ARTIST_SKIA AND WIN32) @@ -61,6 +53,7 @@ elseif (ARTIST_QUARTZ_2D AND APPLE) message(STATUS "Building Artist lib for MacOS with Quartz2D.") endif() +# TODO: Move compiler settings to a settings module if (APPLE) if (NOT CMAKE_OSX_ARCHITECTURES) set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) @@ -73,13 +66,22 @@ if (APPLE) message(FATAL_ERROR "Unsupported MacOS compiler") endif() endif() - message(STATUS "Compiler: ${CMAKE_C_COMPILER_ID}") -add_subdirectory(lib) +############################################################################### +# Options +############################################################################### + +option_ex(ARTIST_QUARTZ_2D "Build Artist using Quartz 2D on macOS." APPLE) +option_ex(ARTIST_SKIA "Build Artist using Skia." NOT APPLE) +option_ex(ARTIST_BUILD_EXAMPLES "Build Artist library examples." ON) +option_ex(ARTIST_BUILD_TESTS "Build Artist library tests." ON) + +############################################################################### +# Sub projects +############################################################################### -option(ARTIST_BUILD_EXAMPLES "build Artist library examples" ON) -option(ARTIST_BUILD_TESTS "build Artist library tests" ON) +add_subdirectory(lib) if (ARTIST_BUILD_EXAMPLES) add_subdirectory(examples) From 2ed89a6b545393a324d8825d48a304a6a5ab2898 Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 12:53:26 +0100 Subject: [PATCH 5/8] Recognize more systems to be used in log message, use current macOS brand instead previous MacOS --- CMakeLists.txt | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8400707..c221a68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,31 @@ if(CMAKE_CXX_STANDARD LESS 17) set(CMAKE_CXX_STANDARD 17) endif() +# TODO: Move compiler settings to a settings module +if (APPLE) + if (NOT CMAKE_OSX_ARCHITECTURES) + set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if (${CMAKE_OSX_ARCHITECTURES} STREQUAL "arm64") + message(STATUS "Artist lib macOS target processor: arm64.") + elseif (${CMAKE_OSX_ARCHITECTURES} STREQUAL "x86_64") + message(STATUS "Artist lib macOS target processor: x86_64.") + else() + message(FATAL_ERROR "Unsupported macOS compiler") + endif() +endif() +message(STATUS "Compiler: ${CMAKE_C_COMPILER_ID}") + +set(ARTIST_HOST_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_NAME}) +if (ARTIST_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(ARTIST_HOST_SYSTEM_NAME "macOS") + set(ARTIST_BACKEND_NAME "Quartz2D") +else() + set(ARTIST_BACKEND_NAME "Skia") +endif() +message(STATUS "Building Artist library for ${ARTIST_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION}\ + using ${ARTIST_BACKEND_NAME} backend.") + ############################################################################### # Module utilities ############################################################################### @@ -45,29 +70,6 @@ if (CYCFI_ENABLE_LTO) endif() endif() -if (ARTIST_SKIA AND WIN32) - message(STATUS "Building Artist lib for Win32 with Skia.") -elseif (ARTIST_SKIA AND APPLE) - message(STATUS "Building Artist lib for MacOS with Skia.") -elseif (ARTIST_QUARTZ_2D AND APPLE) - message(STATUS "Building Artist lib for MacOS with Quartz2D.") -endif() - -# TODO: Move compiler settings to a settings module -if (APPLE) - if (NOT CMAKE_OSX_ARCHITECTURES) - set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) - endif() - if (${CMAKE_OSX_ARCHITECTURES} STREQUAL "arm64") - message(STATUS "Artist lib MacOS target processor: arm64.") - elseif (${CMAKE_OSX_ARCHITECTURES} STREQUAL "x86_64") - message(STATUS "Artist lib MacOS target processor: x86_64.") - else() - message(FATAL_ERROR "Unsupported MacOS compiler") - endif() -endif() -message(STATUS "Compiler: ${CMAKE_C_COMPILER_ID}") - ############################################################################### # Options ############################################################################### From 0a398b644e4c2435c8981c72ded1b1fc865433fa Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 12:58:39 +0100 Subject: [PATCH 6/8] Updated lib/CMakeLists.txt - use optional empty source_groups - specify the detail file, CMake can't add directories without using file(GLOB[_RECURSE]) --- lib/CMakeLists.txt | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fd2998a..ec23268 100755 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -3,13 +3,9 @@ # # Distributed under the MIT License (https://opensource.org/licenses/MIT) ############################################################################### -cmake_minimum_required(VERSION 3.7.2...3.15.0) +add_subdirectory(infra) -if (POLICY CMP0135) - cmake_policy(SET CMP0135 NEW) -endif() - -add_library(libunibreak +set(LIBUNIBREAK_FILES external/libunibreak/src/emojidef.c external/libunibreak/src/graphemebreak.c external/libunibreak/src/linebreak.c @@ -19,6 +15,11 @@ add_library(libunibreak external/libunibreak/src/unibreakdef.c external/libunibreak/src/wordbreak.c ) +add_library(libunibreak ${LIBUNIBREAK_FILES}) + +if(CYCFI_USE_EMPTY_SOURCE_GROUPS) + source_group("" FILES ${LIBUNIBREAK_FILES}) +endif() target_include_directories( libunibreak @@ -219,7 +220,7 @@ set(ARTIST_HEADERS include/artist/canvas.hpp include/artist/circle.hpp include/artist/color.hpp - include/artist/detail + include/artist/detail/canvas_impl.hpp include/artist/font.hpp include/artist/image.hpp include/artist/path.hpp @@ -267,17 +268,27 @@ if (ARTIST_SKIA) ) endif() -source_group("Source Files\\artist" +if(CYCFI_USE_EMPTY_SOURCE_GROUPS) + set(_artist_hdr "") + set(_artist_src "") + set(_artist_impl "") +else() + set(_artist_hdr "Header Files\\artist") + set(_artist_src "Source Files\\artist") + set(_artist_impl "Source Files\\impl") +endif() + +source_group("${_artist_src}" FILES ${ARTIST_SOURCES} ) -source_group("Source Files\\impl" +source_group("${_artist_impl}" FILES ${ARTIST_IMPL} ) -source_group("Header Files\\artist" +source_group("${_artist_hdr}" FILES ${ARTIST_HEADERS} ) @@ -402,8 +413,6 @@ elseif (WIN32) MSVC_RUNTIME_LIBRARY "MultiThreadedDebug" ) endif() - - endif() if (CMAKE_BUILD_TYPE STREQUAL "Debug") From ff8ff9321cf9908f2f7fcbef84ff7021efaee354 Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 13:44:30 +0100 Subject: [PATCH 7/8] CMake: update copyright headers using SPDX specification [no ci] --- CMakeLists.txt | 6 +++--- examples/CMakeLists.txt | 5 ++--- lib/CMakeLists.txt | 6 +++--- test/CMakeLists.txt | 5 ++--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c221a68..6676700 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### -# Copyright (c) 2016-2023 Joel de Guzman -# -# Distributed under the MIT License (https://opensource.org/licenses/MIT) +# SPDX-FileCopyrightText: 2016-2024 Joel de Guzman +# SPDX-FileContributor: Modified by Andrea Zanellato +# SPDX-License-Identifier: MIT ############################################################################### cmake_minimum_required(VERSION 3.18.0) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1fc8b41..970415b 100755 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,6 @@ ############################################################################### -# Copyright (c) 2016-2023 Joel de Guzman -# -# Distributed under the MIT License (https://opensource.org/licenses/MIT) +# SPDX-FileCopyrightText: 2016-2024 Joel de Guzman +# SPDX-License-Identifier: MIT ############################################################################### project(examples) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ec23268..4b8b587 100755 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### -# Copyright (c) 2016-2023 Joel de Guzman -# -# Distributed under the MIT License (https://opensource.org/licenses/MIT) +# SPDX-FileCopyrightText: 2016-2024 Joel de Guzman +# SPDX-FileContributor: Modified by Andrea Zanellato +# SPDX-License-Identifier: MIT ############################################################################### add_subdirectory(infra) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3f9afb9..4740b21 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,6 @@ ############################################################################### -# Copyright (c) 2016-2023 Joel de Guzman -# -# Distributed under the MIT License (https://opensource.org/licenses/MIT) +# SPDX-FileCopyrightText: 2016-2024 Joel de Guzman +# SPDX-License-Identifier: MIT ############################################################################### project(artist_test) From 56a9dc7d81f54daec66f6809ef536513cc4fd540 Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 9 Mar 2024 14:25:11 +0100 Subject: [PATCH 8/8] CMake: make submodules check optional [no ci] --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6676700..f9c473e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,14 +53,16 @@ message(STATUS "Building Artist library for ${ARTIST_HOST_SYSTEM_NAME} ${CMAKE_H # Module utilities ############################################################################### -include(BuildType) # Default build type. -include(GitUtilities) # git_submodule_check(). -include(OptionEx) # Conditional based options, adding a [default: ON/OFF] to the documentation. +include(BuildType) # Default build type. +include(OptionEx) # Conditional based options, adding a [default: ON/OFF] to the documentation. include(CheckIPOSupported) -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") - git_submodule_check(lib/external/libunibreak) - git_submodule_check(lib/infra) +if (CYCFI_ENABLE_GIT_SUBMODULE_CHECK) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") + include(GitUtilities) + git_submodule_check(lib/external/libunibreak) + git_submodule_check(lib/infra) + endif() endif() if (CYCFI_ENABLE_LTO)