Skip to content

Commit

Permalink
dcmtk: maintenance changes (conan-io#25997)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcar87 authored and OMGtechy committed Dec 31, 2024
1 parent b1cb2ce commit 676cd39
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 47 deletions.
58 changes: 37 additions & 21 deletions recipes/dcmtk/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building, check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir, save
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rename, rmdir, save
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
from conan.tools.scm import Version

required_conan_version = ">=1.54.0"
required_conan_version = ">=2.0"


class DCMTKConan(ConanFile):
Expand Down Expand Up @@ -64,6 +64,7 @@ class DCMTKConan(ConanFile):

def export_sources(self):
export_conandata_patches(self)
copy(self, "*.h", os.path.join(self.recipe_folder, "crossbuild"), os.path.join(self.export_sources_folder, "src"))

def config_options(self):
if self.settings.os == "Windows":
Expand Down Expand Up @@ -97,13 +98,13 @@ def requirements(self):
elif self.options.charset_conversion == "icu":
self.requires("icu/73.2")
if self.options.with_libxml2:
self.requires("libxml2/2.11.4")
self.requires("libxml2/[2.12.5 <3]")
if self.options.with_zlib:
self.requires("zlib/[>=1.2.11 <2]")
if self.options.with_openssl:
self.requires("openssl/[>=1 <4]")
if self.options.with_libpng:
self.requires("libpng/1.6.40")
self.requires("libpng/[>=1.6 <2]")
if self.options.with_libtiff:
self.requires("libtiff/4.6.0")
if self.options.get_safe("with_tcpwrappers"):
Expand All @@ -114,12 +115,16 @@ def package_id(self):
del self.info.options.builtin_dictionary
del self.info.options.external_dictionary

def validate_build(self):
if cross_building(self):
if self.settings.os == "Macos" and self.settings.arch != "x86_64":
raise ConanInvalidConfiguration("MacOS crossbuilding is only supported to target x86_64")
else:
# Note: other cross-building scenarios have not been tested and may also need to be marked as invalid
self.output.warning("Crossbuilding has not been tested and may not work")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, 11)
if hasattr(self, "settings_build") and cross_building(self) and self.settings.os == "Macos":
# FIXME: Probable issue with flags, build includes header 'mmintrin.h'
raise ConanInvalidConfiguration("Cross building on Macos is not supported (yet)")
check_min_cppstd(self, 11)

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand Down Expand Up @@ -161,6 +166,29 @@ def generate(self):
if is_msvc(self):
tc.variables["DCMTK_ICONV_FLAGS_ANALYZED"] = True
tc.variables["DCMTK_COMPILE_WIN32_MULTITHREADED_DLL"] = not is_msvc_static_runtime(self)

if Version(self.version) >= "3.6.7" and cross_building(self):
# See https://support.dcmtk.org/redmine/projects/dcmtk/wiki/Cross_Compiling
tc.cache_variables["DCMTK_NO_TRY_RUN"] = True
if self.options.charset_conversion == "libiconv":
tc.cache_variables["DCMTK_ICONV_FLAGS_ANALYZED"] = True
tc.cache_variables["DCMTK_FIXED_ICONV_CONVERSION_FLAGS"] = "AbortTranscodingOnIllegalSequence"
if self.options.enable_stl:
# The recipe has C++11 as the minimum, and these should be available
# under that assumption
variables = ['HAVE_STL_VECTOR_TEST_RESULT', 'HAVE_STL_ALGORITHM_TEST_RESULT',
'HAVE_STL_LIMITS_TEST_RESULT', 'HAVE_STL_LIST_TEST_RESULT', 'HAVE_STL_MAP_TEST_RESULT',
'HAVE_STL_MEMORY_TEST_RESULT', 'HAVE_STL_STACK_TEST_RESULT',
'HAVE_STL_STRING_TEST_RESULT', 'HAVE_STL_TYPE_TRAITS_TEST_RESULT',
'HAVE_STL_TUPLE_TEST_RESULT', 'HAVE_STL_SYSTEM_ERROR_TEST_RESULT']
for var in variables:
tc.cache_variables[var] = True
if self.settings.os == "Macos" and self.settings.arch == "x86_64":
dst_dir = os.path.join(self.build_folder, "config", "include", "dcmtk", "config")
arith_h = "arith_h_Macos_x86_64.h"
copy(self, arith_h, self.source_folder, dst_dir)
rename(self, os.path.join(dst_dir, arith_h), os.path.join(dst_dir, "arith.h"))

tc.generate()

deps = CMakeDeps(self)
Expand Down Expand Up @@ -346,10 +374,6 @@ def package_info(self):
self.cpp_info.components[target_lib].includedirs.append(os.path.join("include", "dcmtk"))
self.cpp_info.components[target_lib].requires = requires

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.components[target_lib].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components[target_lib].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]

if is_msvc(self):
# Required for the __cplusplus check at
# https://github.com/DCMTK/dcmtk/blob/DCMTK-3.6.8/config/include/dcmtk/config/osconfig.h.in#L1489
Expand All @@ -374,11 +398,3 @@ def package_info(self):
self.runenv_info.define_path("DCMDICTPATH", dcmdictpath)
if self.options.with_applications:
self.buildenv_info.define_path("DCMDICTPATH", dcmdictpath)

# TODO: to remove in conan v2
self.cpp_info.names["cmake_find_package"] = "DCMTK"
self.cpp_info.names["cmake_find_package_multi"] = "DCMTK"
if self.options.default_dict == "external":
self.env_info.DCMDICTPATH = dcmdictpath
if self.options.with_applications:
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
58 changes: 58 additions & 0 deletions recipes/dcmtk/all/crossbuild/arith_h_Macos_x86_64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef CONFIG_ARITH_H
#define CONFIG_ARITH_H

#define DCMTK_SIGNED_CHAR_DIGITS10 2
#define DCMTK_UNSIGNED_CHAR_DIGITS10 2
#define DCMTK_SIGNED_SHORT_DIGITS10 4
#define DCMTK_UNSIGNED_SHORT_DIGITS10 4
#define DCMTK_SIGNED_INT_DIGITS10 9
#define DCMTK_UNSIGNED_INT_DIGITS10 9
#define DCMTK_SIGNED_LONG_DIGITS10 18
#define DCMTK_UNSIGNED_LONG_DIGITS10 19
#define DCMTK_FLOAT_MAX_DIGITS10 9
#define DCMTK_DOUBLE_MAX_DIGITS10 17
#define DCMTK_CHAR_TRAPS OFTrue
#define DCMTK_CHAR_MODULO OFTrue
#define DCMTK_SIGNED_CHAR_TRAPS OFTrue
#define DCMTK_SIGNED_CHAR_MODULO OFTrue
#define DCMTK_UNSIGNED_CHAR_TRAPS OFTrue
#define DCMTK_UNSIGNED_CHAR_MODULO OFTrue
#define DCMTK_SIGNED_SHORT_TRAPS OFTrue
#define DCMTK_SIGNED_SHORT_MODULO OFTrue
#define DCMTK_UNSIGNED_SHORT_TRAPS OFTrue
#define DCMTK_UNSIGNED_SHORT_MODULO OFTrue
#define DCMTK_SIGNED_INT_TRAPS OFTrue
#define DCMTK_SIGNED_INT_MODULO OFTrue
#define DCMTK_UNSIGNED_INT_TRAPS OFTrue
#define DCMTK_UNSIGNED_INT_MODULO OFTrue
#define DCMTK_SIGNED_LONG_TRAPS OFTrue
#define DCMTK_SIGNED_LONG_MODULO OFTrue
#define DCMTK_UNSIGNED_LONG_TRAPS OFTrue
#define DCMTK_UNSIGNED_LONG_MODULO OFTrue
#define DCMTK_FLOAT_TRAPS OFFalse
#define DCMTK_DOUBLE_TRAPS OFFalse
#define DCMTK_FLOAT_HAS_INFINITY OFTrue
#define DCMTK_FLOAT_INFINITY *OFreinterpret_cast( const float*, "\000\000\200\177" )
#define DCMTK_DOUBLE_HAS_INFINITY OFTrue
#define DCMTK_DOUBLE_INFINITY *OFreinterpret_cast( const double*, "\000\000\000\000\000\000\360\177" )
#define DCMTK_FLOAT_HAS_QUIET_NAN OFTrue
#define DCMTK_FLOAT_QUIET_NAN *OFreinterpret_cast( const float*, "\000\000\300\177" )
#define DCMTK_DOUBLE_HAS_QUIET_NAN OFTrue
#define DCMTK_DOUBLE_QUIET_NAN *OFreinterpret_cast( const double*, "\000\000\000\000\000\000\370\177" )
#define DCMTK_FLOAT_HAS_SIGNALING_NAN OFFalse
#define DCMTK_FLOAT_SIGNALING_NAN *OFreinterpret_cast( const float*, "\001\000\200\177" )
#define DCMTK_DOUBLE_HAS_SIGNALING_NAN OFFalse
#define DCMTK_DOUBLE_SIGNALING_NAN *OFreinterpret_cast( const double*, "\001\000\000\000\000\000\360\177" )
#define DCMTK_FLOAT_IS_IEC559 OFFalse
#define DCMTK_DOUBLE_IS_IEC559 OFFalse
#define DCMTK_FLOAT_HAS_DENORM OFdenorm_present
#define DCMTK_FLOAT_DENORM_MIN *OFreinterpret_cast( const float*, "\001\000\000\000" )
#define DCMTK_DOUBLE_HAS_DENORM OFdenorm_present
#define DCMTK_DOUBLE_DENORM_MIN *OFreinterpret_cast( const double*, "\001\000\000\000\000\000\000\000" )
#define DCMTK_FLOAT_TINYNESS_BEFORE OFTrue
#define DCMTK_DOUBLE_TINYNESS_BEFORE OFTrue
#define DCMTK_FLOAT_HAS_DENORM_LOSS OFTrue
#define DCMTK_DOUBLE_HAS_DENORM_LOSS OFTrue
#define DCMTK_ROUND_STYLE 1

#endif // CONFIG_ARITH_H
2 changes: 1 addition & 1 deletion recipes/dcmtk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(DCMTK REQUIRED CONFIG)
Expand Down
8 changes: 0 additions & 8 deletions recipes/dcmtk/all/test_v1_package/CMakeLists.txt

This file was deleted.

17 changes: 0 additions & 17 deletions recipes/dcmtk/all/test_v1_package/conanfile.py

This file was deleted.

0 comments on commit 676cd39

Please sign in to comment.