diff --git a/recipes/libraw/all/CMakeLists.txt b/recipes/libraw/all/CMakeLists.txt index 867dedb15eb72..f6b105c027f9d 100644 --- a/recipes/libraw/all/CMakeLists.txt +++ b/recipes/libraw/all/CMakeLists.txt @@ -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) @@ -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 diff --git a/recipes/libraw/all/conanfile.py b/recipes/libraw/all/conanfile.py index 4fda00c094ccf..27f826a27275a 100644 --- a/recipes/libraw/all/conanfile.py +++ b/recipes/libraw/all/conanfile.py @@ -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" @@ -18,6 +20,7 @@ class LibRawConan(ConanFile): 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], @@ -25,6 +28,7 @@ class LibRawConan(ConanFile): default_options = { "shared": False, "fPIC": True, + "build_thread_safe": False, "with_jpeg": "libjpeg", "with_lcms": True, "with_jasper": True, @@ -38,6 +42,8 @@ def _min_cppstd(self): 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: @@ -71,6 +77,7 @@ 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 @@ -91,20 +98,37 @@ def package(self): 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))