Initial commit

This commit is contained in:
2026-01-23 22:15:36 +01:00
commit ca60108606
167 changed files with 5311 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
sources:
"1.0.3":
url: "https://github.com/jwmcglynn/pixelmatch-cpp17/archive/refs/tags/v1.0.3.tar.gz"
sha256: "7ed08fe1916413f88b4411a6bd510afb7e39260ce9f79c80373b252d01a80d1d"
"09102024":
url: "https://github.com/jwmcglynn/pixelmatch-cpp17/archive/bfc8c6c20cd89688f8b5412af7f89ad5e761d189.tar.gz"
sha256: "360c11ae82fc7dd70427d4a32fb3b8c5e2d5e9bd85dfb90933747967a898ab2d"
"23052024":
url: "https://github.com/jwmcglynn/pixelmatch-cpp17/archive/e65772b1a00d9fa4fe69d1553010f98f01e6156b.tar.gz"
sha256: "786ad1b1ec0323257002a6c100e00db55f305d8d4d92ff2ba5dbf846c687c67e"
"01082023":
url: "https://github.com/jwmcglynn/pixelmatch-cpp17/archive/5cec7dd16fa02babbc7efdccfb4d130ede29f621.tar.gz"
sha256: "a7224d397c61a3819e4e68188c338cbfe4b7f5513ad7b543b7d65e821296708d"
patches:
"1.0.3":
- patch_file: "patches/1.0.3-conan-dependencies.patch"
patch_description: "Include conan dependencies"
patch_type: "conan"

View File

@@ -0,0 +1,77 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd, valid_min_cppstd
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
import os
required_conan_version = ">=1.52.0"
class PixelMatchCPP17Conan(ConanFile):
name = "pixelmatch-cpp17"
description = "A C++17 port of the JavaScript pixelmatch library, providing a small pixel-level image comparison library."
license = "Apache-2.0"
topics = ("image", "comparison")
homepage = "https://github.com/jwmcglynn/pixelmatch-cpp17"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
@property
def _source_subfolder(self):
return "source_subfolder"
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
apply_conandata_patches(self)
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
CMakeDeps(self).generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(
self,
"LICENSE",
src=self._source_subfolder,
dst=os.path.join(self.package_folder, "licenses"),
)
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["pixelmatch-cpp17"]
def requirements(self):
if(Version(self.version) == "1.0.3"):
self.requires("stb/cci.20240531", transitive_headers=True)

View File

@@ -0,0 +1,61 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4ed9a7..a5b6a69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,14 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(PIXELMATCH_BUILD_TESTS "Enable building tests" OFF)
-# stb libraries for tests and image_utils. Not used in pixelmatch-cpp17 itself.
-add_library(pixelmatch_third_party_stb_image STATIC third_party/stb/stb_image.cpp)
-target_include_directories(pixelmatch_third_party_stb_image PUBLIC third_party)
-target_compile_options(pixelmatch_third_party_stb_image PRIVATE -Wno-unused-function -Wno-self-assign)
-
-add_library(pixelmatch_third_party_stb_image_write STATIC third_party/stb/stb_image_write.cpp)
-target_include_directories(pixelmatch_third_party_stb_image_write PUBLIC third_party)
-target_compile_options(pixelmatch_third_party_stb_image_write PRIVATE -Wno-unused-function -Wno-self-assign)
+find_package(stb)
# Main library
add_library(pixelmatch-cpp17 src/pixelmatch/pixelmatch.cc)
@@ -22,16 +15,18 @@ target_include_directories(pixelmatch-cpp17 PUBLIC src)
# image_utils helper library (uses stb to load and save images)
add_library(image_utils src/pixelmatch/image_utils.cc)
target_include_directories(image_utils PUBLIC src)
-target_link_libraries(image_utils PUBLIC pixelmatch-cpp17 pixelmatch_third_party_stb_image pixelmatch_third_party_stb_image_write)
+target_link_libraries(image_utils PUBLIC pixelmatch-cpp17 stb::stb)
+
+install(FILES src/pixelmatch/pixelmatch.h DESTINATION include/pixelmatch)
+install(TARGETS pixelmatch-cpp17 DESTINATION lib)
+
+if ((MSVC) AND (MSVC_VERSION GREATER_EQUAL 1914))
+ target_compile_options(${PROJECT_NAME} PRIVATE "/Zc:preprocessor")
+ target_compile_options(${PROJECT_NAME} PRIVATE "/Zc:__cplusplus")
+endif()
if(PIXELMATCH_BUILD_TESTS)
-include(FetchContent)
-FetchContent_Declare(
- googletest
- URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
-)
-set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
-FetchContent_MakeAvailable(googletest)
+find_package(GTest)
enable_testing()
add_library(test_base INTERFACE)
diff --git a/src/pixelmatch/image_utils.cc b/src/pixelmatch/image_utils.cc
index 74ec434..068e75d 100644
--- a/src/pixelmatch/image_utils.cc
+++ b/src/pixelmatch/image_utils.cc
@@ -1,7 +1,7 @@
#include "pixelmatch/image_utils.h"
-#include <stb/stb_image.h>
-#include <stb/stb_image_write.h>
+#include <stb_image.h>
+#include <stb_image_write.h>
#include <cassert>
#include <cstring> // For memcmp.

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)
find_package(pixelmatch-cpp17 REQUIRED)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} pixelmatch-cpp17::pixelmatch-cpp17)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)

View File

@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,13 @@
#include <pixelmatch/pixelmatch.h>
int main()
{
pixelmatch::pixelmatch(
{},
{},
{},
2,
2,
2);
return 0;
}

View File

@@ -0,0 +1,9 @@
versions:
"1.0.3":
folder: all
"09102024":
folder: all
"23052024":
folder: all
"01082023":
folder: all