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

libraw: fix inconsistencies with upstream project #25302

Merged
merged 1 commit into from
Sep 19, 2024
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
33 changes: 24 additions & 9 deletions recipes/libraw/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.8)
project(LibRaw LANGUAGES CXX)

option(LIBRAW_BUILD_THREAD_SAFE "Build raw_r library with -pthread enabled" OFF)
option(LIBRAW_WITH_JPEG "Build with libjpeg" ON)
option(LIBRAW_WITH_LCMS "Build with LCMS" ON)
option(LIBRAW_WITH_JASPER "Build with Jasper" ON)
Expand Down Expand Up @@ -32,33 +33,47 @@ if(LIBRAW_WITH_JASPER)
endif()

add_library(raw ${libraw_LIB_SRCS})
target_compile_features(raw PRIVATE cxx_std_11)
target_compile_features(raw PUBLIC cxx_std_11)
target_include_directories(raw PUBLIC "${LIBRAW_SRC_DIR}")
if(WIN32)
target_link_libraries(raw PUBLIC ws2_32)
if(BUILD_SHARED_LIBS)
target_compile_definitions(raw PRIVATE LIBRAW_BUILDLIB)
target_compile_definitions(raw PUBLIC LIBRAW_BUILDLIB)
else()
target_compile_definitions(raw PUBLIC LIBRAW_NODLL)
endif()
endif()
if(MSVC)
target_compile_options(raw PRIVATE /wd4018 /wd4101 /wd4244 /wd4251 /wd4267 /wd4996)
target_compile_options(raw PUBLIC /wd4018 /wd4101 /wd4244 /wd4251 /wd4267 /wd4996)
endif()
if(LIBRAW_WITH_JPEG)
target_compile_definitions(raw PRIVATE USE_JPEG USE_JPEG8)
target_link_libraries(raw PRIVATE JPEG::JPEG)
target_compile_definitions(raw PUBLIC USE_JPEG USE_JPEG8)
target_link_libraries(raw PUBLIC JPEG::JPEG)
endif ()
if (LIBRAW_WITH_LCMS)
target_compile_definitions(raw PRIVATE USE_LCMS2)
target_link_libraries(raw PRIVATE lcms::lcms)
target_compile_definitions(raw PUBLIC USE_LCMS2)
target_link_libraries(raw PUBLIC lcms::lcms)
endif ()
if (LIBRAW_WITH_JASPER)
target_compile_definitions(raw PRIVATE USE_JASPER)
target_link_libraries(raw PRIVATE Jasper::Jasper)
target_compile_definitions(raw PUBLIC USE_JASPER)
target_link_libraries(raw PUBLIC Jasper::Jasper)
endif ()

include(GNUInstallDirs)
if(LIBRAW_BUILD_THREAD_SAFE)
add_library(raw_r ${libraw_LIB_SRCS})
target_link_libraries(raw_r INTERFACE raw)
target_compile_options(raw_r PRIVATE -pthread)
target_link_options(raw_r PRIVATE -pthread)
target_include_directories(raw_r PUBLIC "${LIBRAW_SRC_DIR}")
install(
TARGETS raw_r
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()

install(DIRECTORY "${LIBRAW_SRC_DIR}/libraw" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
TARGETS raw
Expand Down
44 changes: 34 additions & 10 deletions recipes/libraw/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.build import check_min_cppstd, stdcpp_library
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get
import os
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.53.0"

Expand All @@ -18,13 +20,15 @@
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_thread_safe": [True, False],
"with_jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"],
"with_lcms": [True, False],
"with_jasper": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_thread_safe": False,
"with_jpeg": "libjpeg",
"with_lcms": True,
"with_jasper": True,
Expand All @@ -38,6 +42,8 @@
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if is_msvc(self):
del self.options.build_thread_safe

def configure(self):
if self.options.shared:
Expand Down Expand Up @@ -65,12 +71,13 @@
check_min_cppstd(self, self._min_cppstd)

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

Check warning on line 74 in recipes/libraw/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Bad indentation. Found 7 spaces, expected 8

def generate(self):
tc = CMakeToolchain(self)
tc.variables["RAW_LIB_VERSION_STRING"] = self.version
tc.variables["LIBRAW_SRC_DIR"] = self.source_folder.replace("\\", "/")
tc.variables["LIBRAW_BUILD_THREAD_SAFE"] = self.options.get_safe("build_thread_safe", False)
tc.variables["LIBRAW_WITH_JPEG"] = bool(self.options.with_jpeg)
tc.variables["LIBRAW_WITH_LCMS"] = self.options.with_lcms
tc.variables["LIBRAW_WITH_JASPER"] = self.options.with_jasper
Expand All @@ -91,20 +98,37 @@
cmake.install()

def package_info(self):
self.cpp_info.libs = ["raw"]
self.cpp_info.components["libraw_"].set_property("pkg_config_name", "libraw")
self.cpp_info.components["libraw_"].libs = ["raw"]
self.cpp_info.components["libraw_"].includedirs.append(os.path.join("include", "libraw"))

if self.settings.os == "Windows":
self.cpp_info.system_libs.append("ws2_32")
self.cpp_info.components["libraw_"].system_libs.append("ws2_32")
if not self.options.shared:
self.cpp_info.defines.append("LIBRAW_NODLL")
self.cpp_info.components["libraw_"].defines.append("LIBRAW_NODLL")

requires = []
if self.options.with_jpeg == "libjpeg":
self.cpp_info.requires.append("libjpeg::libjpeg")
requires.append("libjpeg::libjpeg")
elif self.options.with_jpeg == "libjpeg-turbo":
self.cpp_info.requires.append("libjpeg-turbo::jpeg")
requires.append("libjpeg-turbo::jpeg")
elif self.options.with_jpeg == "mozjpeg":
self.cpp_info.requires.append("mozjpeg::libjpeg")
requires.append("mozjpeg::libjpeg")
if self.options.with_lcms:
self.cpp_info.requires.append("lcms::lcms")
requires.append("lcms::lcms")
if self.options.with_jasper:
self.cpp_info.requires.append("jasper::jasper")
requires.append("jasper::jasper")
self.cpp_info.components["libraw_"].requires = requires

if self.options.get_safe("build_thread_safe"):
self.cpp_info.components["libraw_r"].set_property("pkg_config_name", "libraw_r")
self.cpp_info.components["libraw_r"].libs = ["raw_r"]
self.cpp_info.components["libraw_r"].includedirs.append(os.path.join("include", "libraw"))
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libraw_r"].system_libs.append("pthread")
self.cpp_info.components["libraw_r"].requires = requires

if not self.options.shared and stdcpp_library(self):
self.cpp_info.components["libraw_"].system_libs.append(stdcpp_library(self))
if self.options.get_safe("build_thread_safe"):
self.cpp_info.components["libraw_r"].system_libs.append(stdcpp_library(self))
Loading