Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jasper] Add version 3.0.6 and cross-support Conan v1 and v2 #13285

Merged
merged 21 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions recipes/jasper/all/CMakeLists.txt

This file was deleted.

64 changes: 22 additions & 42 deletions recipes/jasper/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
sources:
"3.0.6":
url: "https://github.com/jasper-software/jasper/archive/refs/tags/version-3.0.6.tar.gz"
sha256: "c79961bc00158f5b5dc5f5fcfa792fde9bebb024432689d0f9e3f95a097d0ec3"
"2.0.33":
url: "https://github.com/jasper-software/jasper/archive/refs/tags/version-2.0.33.tar.gz"
sha256: "38b8f74565ee9e7fec44657e69adb5c9b2a966ca5947ced5717cde18a7d2eca6"
"2.0.32":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.32.tar.gz"
sha256: "a3583a06698a6d6106f2fc413aa42d65d86bedf9a988d60e5cfa38bf72bc64b9"
"2.0.28":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.28.tar.gz"
sha256: "6b4e5f682be0ab1a5acb0eeb6bf41d6ce17a658bb8e2dbda95de40100939cc88"
"2.0.27":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.27.tar.gz"
sha256: "df41bd015a9dd0cc2a2e696f8ca5cbfb633323ca9429621f7fa801778681f2dd"
"2.0.26":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.26.tar.gz"
sha256: "a82a119e85b7d1f448e61309777fa5f79053a9adca4a2b5bfe44be5439fb8fea"
"2.0.25":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.25.tar.gz"
sha256: "f5bc48e2884bcabd2aca1737baff4ca962ec665b6eb673966ced1f7adea07edb"
"2.0.24":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.24.tar.gz"
sha256: "d2d28e115968d38499163cf8086179503668ce0d71b90dd33855b3de96a1ca1d"
"2.0.23":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.23.tar.gz"
sha256: "20facc904bd9d38c20e0c090b1be3ae02ae5b2703b803013be2ecad586a18927"
"2.0.22":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.22.tar.gz"
sha256: "afc4166bff29b8a0dc46ed5e8d6a208d7976fccfd0b1146e3400c8b2948794a2"
"2.0.21":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.21.tar.gz"
sha256: "2482def06dfaa33b8d93cbe992a29723309f3c2b6e75674423a52fc82be10418"
"2.0.19":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.19.tar.gz"
sha256: "b9d16162a088617ada36450f2374d72165377cb64b33ed197c200bcfb73ec76c"
"2.0.16":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.16.tar.gz"
sha256: "f1d8b90f231184d99968f361884e2054a1714fdbbd9944ba1ae4ebdcc9bbfdb1"
"2.0.14":
url: "https://github.com/jasper-software/jasper/archive/version-2.0.14.tar.gz"
sha256: "85266eea728f8b14365db9eaf1edc7be4c348704e562bb05095b9a077cf1a97b"
patches:
"2.0.16":
- patch_file: "patches/fix-exported-symbols.patch"
base_path: "source_subfolder"
"2.0.14":
- patch_file: "patches/fix-exported-symbols.patch"
base_path: "source_subfolder"
"3.0.6":
- patch_file: "patches/3.0.6-0001-skip-rpath.patch"
patch_description: "Do not enforce rpath configuration"
patch_source: "https://github.com/jasper-software/jasper/pull/347"
patch_type: "conan"
- patch_file: "patches/3.0.6-0002-find-libjpeg.patch"
patch_description: "check_c_source_compilers does not work with conan gens. See https://github.com/conan-io/conan/issues/12180"
patch_type: "conan"
- patch_file: "patches/3.0.6-0003-deterministic-libname.patch"
patch_description: "No generator dependent libname"
patch_type: "conan"
"2.0.33":
- patch_file: "patches/2.0.33-0001-skip-rpath.patch"
patch_description: "Do not enforce rpath configuration"
patch_source: "https://github.com/jasper-software/jasper/pull/347"
patch_type: "conan"
- patch_file: "patches/2.0.33-0002-find-libjpeg.patch"
patch_description: "check_c_source_compilers does not work with conan gens. See https://github.com/conan-io/conan/issues/12180"
patch_type: "conan"
116 changes: 51 additions & 65 deletions recipes/jasper/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from conans import CMake
from conan import ConanFile
from conan.tools.files import get, save, rmdir, rm, replace_in_file, apply_conandata_patches, export_conandata_patches
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir, save
from conan.tools.microsoft import is_msvc
import os
import textwrap

Expand All @@ -14,9 +14,8 @@ class JasperConan(ConanFile):
license = "JasPer-2.0"
uilianries marked this conversation as resolved.
Show resolved Hide resolved
homepage = "https://jasper-software.github.io/jasper"
url = "https://github.com/conan-io/conan-center-index"
topics = ("tool-kit", "coding")
topics = ("toolkit", "coding", "jpeg", "images")
description = "JasPer Image Processing/Coding Tool Kit"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -29,92 +28,79 @@ class JasperConan(ConanFile):
"with_libjpeg": "libjpeg",
}

generators = "cmake", "cmake_find_package"
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def export_sources(self):
self.copy("CMakeLists.txt")
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")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.with_libjpeg == "libjpeg-turbo":
self.requires("libjpeg-turbo/2.1.2")
self.requires("libjpeg-turbo/2.1.4")
elif self.options.with_libjpeg == "libjpeg":
self.requires("libjpeg/9e")

def validate(self):
if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) == "16":
raise ConanInvalidConfiguration(f"{self.name} Current can not build in CCI due to windows SDK version. See https://github.com/conan-io/conan-center-index/pull/13285 for the solution hopefully")

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["JAS_ENABLE_DOC"] = False
self._cmake.definitions["JAS_ENABLE_PROGRAMS"] = False
self._cmake.definitions["JAS_ENABLE_SHARED"] = self.options.shared
self._cmake.definitions["JAS_LIBJPEG_REQUIRED"] = "REQUIRED"
self._cmake.definitions["JAS_ENABLE_OPENGL"] = False
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def _patch_sources(self):
apply_conandata_patches(self)
# Clean rpath in installed shared lib
cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt")
cmds_to_remove = [
"set(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\")",
"set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)",
"set(CMAKE_INSTALL_RPATH\n \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\")",
]
for cmd_to_remove in cmds_to_remove:
replace_in_file(self, cmakelists, cmd_to_remove, "")
destination=self.source_folder, strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["JAS_ENABLE_DOC"] = False
tc.variables["JAS_ENABLE_LATEX"] = False
tc.variables["JAS_ENABLE_PROGRAMS"] = False
tc.variables["JAS_ENABLE_SHARED"] = self.options.shared
tc.variables["JAS_LIBJPEG_REQUIRED"] = "REQUIRED"
tc.variables["JAS_ENABLE_OPENGL"] = False
tc.variables["JAS_ENABLE_LIBJPEG"] = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is already true, but it's good to express it here 👍


if cross_building(self):
tc.cache_variables["JAS_CROSSCOMPILING"] = True
tc.cache_variables["JAS_STDC_VERSION"] = "199901L"

# TODO: Remove after fixing https://github.com/conan-io/conan-center-index/issues/13159
# C3I workaround to force CMake to choose the highest version of
# the windows SDK available in the system
if is_msvc(self) and not self.conf.get("tools.cmake.cmaketoolchain:system_version"):
tc.variables["CMAKE_SYSTEM_VERSION"] = "10.0"
uilianries marked this conversation as resolved.
Show resolved Hide resolved

tc.generate()

cmakedeps = CMakeDeps(self)
cmakedeps.generate()

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "COPYRIGHT*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
if self.settings.os == "Windows":
for dll_prefix in ["concrt", "msvcp", "vcruntime"]:
rm(self, f"{dll_prefix}*.dll", os.path.join(self.package_folder, "bin"))
self._create_cmake_module_variables(
os.path.join(self.package_folder, self._module_file_rel_path)
)
self._create_cmake_module_variables(os.path.join(self.package_folder, self._module_file_rel_path))

# FIXME: Missing CMake alias variables. See https://github.com/conan-io/conan/issues/7691
def _create_cmake_module_variables(self, module_file):
content = textwrap.dedent("""\
if(DEFINED Jasper_FOUND)
set(JASPER_FOUND ${Jasper_FOUND})
endif()
set(JASPER_FOUND TRUE)
if(DEFINED Jasper_INCLUDE_DIR)
set(JASPER_INCLUDE_DIR ${Jasper_INCLUDE_DIR})
endif()
Expand All @@ -129,19 +115,19 @@ def _create_cmake_module_variables(self, module_file):

@property
def _module_file_rel_path(self):
return os.path.join("lib", "cmake", "conan-official-{}-variables.cmake".format(self.name))
return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake")

def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "Jasper")
self.cpp_info.set_property("cmake_target_name", "Jasper::Jasper")
self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path])
self.cpp_info.set_property("pkg_config_name", "jasper")
self.cpp_info.libs = ["jasper"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["m", "pthread"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pthread is a special library - gcc has a flag for it (looking into this..)

Copy link
Contributor

@SpaceIm SpaceIm Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a private dependendency I think, no need for the compilation flag. This block could even be omitted when jasper is shared.


# TODO: to remove in conan v2
self.cpp_info.names["cmake_find_package"] = "Jasper"
self.cpp_info.names["cmake_find_package_multi"] = "Jasper"
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]

self.cpp_info.libs = ["jasper"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
24 changes: 24 additions & 0 deletions recipes/jasper/all/patches/2.0.33-0001-skip-rpath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 230d88c..79081c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -298,19 +298,15 @@ if (JAS_ENABLE_SHARED)
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# The RPATH to be used when installing, but only if it's not a
# system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
- set(CMAKE_INSTALL_RPATH
- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif("${isSystemDir}" STREQUAL "-1")

endif()
18 changes: 18 additions & 0 deletions recipes/jasper/all/patches/2.0.33-0002-find-libjpeg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79081c2..38b6238 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -244,12 +244,7 @@ if (JAS_ENABLE_LIBJPEG AND JPEG_FOUND)
# (e.g., stdio.h and stdint.h). So, we cannot reliably use
# check_include_file here.
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIR})
- check_c_source_compiles("
- #include <stdio.h>
- #include <stdint.h>
- #include <jpeglib.h>
- int main() {}
- " JAS_HAVE_JPEGLIB_H)
+ set(JAS_HAVE_JPEGLIB_H 1)
if(JAS_HAVE_JPEGLIB_H)
set(JAS_HAVE_LIBJPEG 1)
include_directories(${JPEG_INCLUDE_DIR})
24 changes: 24 additions & 0 deletions recipes/jasper/all/patches/3.0.6-0001-skip-rpath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5cf594c..a0d253d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -740,19 +740,15 @@ if(JAS_ENABLE_SHARED)
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# The RPATH to be used when installing, but only if it's not a
# system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if(isSystemDir EQUAL -1)
- set(CMAKE_INSTALL_RPATH
- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()

18 changes: 18 additions & 0 deletions recipes/jasper/all/patches/3.0.6-0002-find-libjpeg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a0d253d..19518af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -680,12 +680,7 @@ if(JAS_ENABLE_LIBJPEG)
# (e.g., stdio.h and stdint.h). So, we cannot reliably use
# check_include_file here.
jas_get_includes_from_targets(CMAKE_REQUIRED_INCLUDES JPEG::JPEG)
- check_c_source_compiles("
- #include <stdio.h>
- #include <stdint.h>
- #include <jpeglib.h>
- int main() {}
- " JAS_HAVE_JPEGLIB_H)
+ set(JAS_HAVE_JPEGLIB_H 1)
Comment on lines +9 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue than conan-io/conan#12180?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, indeed it does not work with check_c_source_compiles

if(JAS_HAVE_JPEGLIB_H)
set(JAS_HAVE_LIBJPEG 1)
set(JAS_LIBJPEG_TARGET JPEG::JPEG)
11 changes: 11 additions & 0 deletions recipes/jasper/all/patches/3.0.6-0003-deterministic-libname.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -254,7 +254,7 @@ endif()
# If a multiconfiguration generator is used, ensure that various output
# files are not placed in subdirectories (such as Debug and Release)
# as this will cause the CTest test suite to fail.
-if(JAS_MULTICONFIGURATION_GENERATOR)
+if(0)
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_DEBUG_POSTFIX d)
endif()
Loading