Skip to content

gdcm: add 3.0.20 #14362

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

Merged
merged 4 commits into from
Nov 28, 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
33 changes: 31 additions & 2 deletions recipes/gdcm/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
sources:
"3.0.20":
url: "https://github.com/malaterre/GDCM/archive/refs/tags/v3.0.20.tar.gz"
sha256: "18161bd76008f4e8a0a33dab72fa34684147e8164f25a4735f373ad4bd909636"
"3.0.9":
url: "https://github.com/malaterre/GDCM/archive/refs/tags/v3.0.9.tar.gz"
sha256: "fcfc50ea8809bd4a173550c7d7bb4f8722ae0781fbf17240ce84a04e90af0e9b"
patches:
"3.0.20":
- patch_file: "patches/0001-charls-linking.patch"
patch_description: "fix symbol export for gdcmcharls"
patch_type: "portability"
- patch_file: "patches/0002-3.0.20-openjpeg.patch"
patch_description: "fix variable names for openjpeg"
patch_type: "conan"
- patch_file: "patches/0004-3.0.20-find-expat.patch"
patch_description: "enforce usage of FindEXPAT.cmake"
patch_type: "conan"
- patch_file: "patches/0005-3.0.20-openssl.patch"
patch_description: "skip check_cxx_source_compiles usage for openssl"
patch_type: "conan"
- patch_file: "patches/0006-json.patch"
patch_description: "skip check_cxx_source_compiles usage for json-c"
patch_type: "conan"
"3.0.9":
- patch_file: "patches/0001-charls-linking.patch"
- patch_file: "patches/0002-openjpeg-integration.patch"
patch_description: "fix symbol export for gdcmcharls"
patch_type: "portability"
- patch_file: "patches/0002-3.0.9-openjpeg.patch"
patch_description: "fix variable names for openjpeg"
patch_type: "conan"
- patch_file: "patches/0003-gcc-11-compilation.patch"
patch_description: "add missing includes for GCC 11"
patch_type: "backport"
patch_source: "https://github.com/malaterre/GDCM/commit/4404b770be337bd0d5d3c2289abfd34426433db2"
- patch_file: "patches/0004-find-expat.patch"
- patch_file: "patches/0004-3.0.9-find-expat.patch"
patch_description: "enforce usage of FindEXPAT.cmake"
patch_type: "conan"
- patch_file: "patches/0005-3.0.9-openssl.patch"
patch_description: "skip check_cxx_source_compiles usage for openssl"
patch_type: "conan"
- patch_file: "patches/0006-json.patch"
patch_description: "skip check_cxx_source_compiles usage for json-c"
patch_type: "conan"
32 changes: 26 additions & 6 deletions recipes/gdcm/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ class GDCMConan(ConanFile):
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://gdcm.sourceforge.net/"
topics = ("dicom", "images")
topics = ("dicom", "images", "medical-imaging")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_json": [True, False],
"with_openssl": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_json": True,
"with_openssl": True,
}

@property
Expand All @@ -49,9 +53,17 @@ def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("expat/2.4.9")
self.requires("expat/2.5.0")
self.requires("openjpeg/2.5.0")
self.requires("zlib/1.2.13")
if self.settings.os != "Windows":
self.requires("libuuid/1.0.3")
if Version(self.version) >= Version("3.0.20"):
self.requires("libiconv/1.17")
if self.options.with_json:
self.requires("json-c/0.16")
if self.options.with_openssl:
self.requires("openssl/1.1.1s")

def validate(self):
if self.info.settings.compiler.get_safe("cppstd"):
Expand All @@ -69,8 +81,12 @@ def generate(self):
tc.variables["GDCM_BUILD_SHARED_LIBS"] = bool(self.options.shared)
# FIXME: unvendor deps https://github.com/conan-io/conan-center-index/pull/5705#discussion_r647224146
tc.variables["GDCM_USE_SYSTEM_EXPAT"] = True
tc.variables["GDCM_USE_SYSTEM_JSON"] = self.options.with_json
Copy link
Contributor

@SpaceIm SpaceIm Nov 28, 2022

Choose a reason for hiding this comment

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

I don't understand. What happen when with_json option is False? gdcm still uses json-c but bundled one?

Copy link
Contributor

@SpaceIm SpaceIm Nov 28, 2022

Choose a reason for hiding this comment

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

Moreover the json patch could be more robust, upstream doesn't rely on official json-c config filen but on a custom FindJSON.cmake file.

Copy link
Contributor Author

@Nekto89 Nekto89 Nov 28, 2022

Choose a reason for hiding this comment

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

If I understood correctly, without GDCM_USE_SYSTEM_JSON json functionality just won't work - there is no gdcm internal analogue. Same with openssl. Theoretically some people might want to use it but it's not part of core functionality - I didn't even know that gdcm has it for many years.

tc.variables["GDCM_USE_SYSTEM_OPENJPEG"] = True
tc.variables["GDCM_USE_SYSTEM_OPENSSL"] = self.options.with_openssl
tc.variables["GDCM_USE_SYSTEM_UUID"] = self.settings.os != "Windows"
tc.variables["GDCM_USE_SYSTEM_ZLIB"] = True

if not valid_min_cppstd(self, self._min_cppstd):
tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd
tc.generate()
Expand Down Expand Up @@ -178,8 +194,6 @@ def _gdcm_libraries(self):
"socketxx"]
if self.settings.os == "Windows":
gdcm_libs.append("gdcmgetopt")
else:
gdcm_libs.append("gdcmuuid")
return gdcm_libs

@property
Expand All @@ -202,9 +216,17 @@ def package_info(self):
self.cpp_info.components[lib].build_modules["cmake_find_package"] = self._gdcm_build_modules
self.cpp_info.components[lib].build_modules["cmake_find_package_multi"] = self._gdcm_build_modules

if self.options.with_openssl:
self.cpp_info.components["gdcmCommon"].requires.append("openssl::openssl")
self.cpp_info.components["gdcmDSED"].requires.extend(["gdcmCommon", "zlib::zlib"])
self.cpp_info.components["gdcmIOD"].requires.extend(["gdcmDSED", "gdcmCommon", "expat::expat"])
self.cpp_info.components["gdcmMSFF"].requires.extend(["gdcmIOD", "gdcmDSED", "gdcmDICT", "openjpeg::openjpeg"])
if self.options.with_json:
self.cpp_info.components["gdcmMSFF"].requires.append("json-c::json-c")
if self.settings.os != "Windows":
self.cpp_info.components["gdcmMSFF"].requires.append("libuuid::libuuid")
if Version(self.version) >= Version("3.0.20"):
self.cpp_info.components["gdcmMSFF"].requires.append("libiconv::libiconv")
if not self.options.shared:
self.cpp_info.components["gdcmDICT"].requires.extend(["gdcmDSED", "gdcmIOD"])
self.cpp_info.components["gdcmMEXD"].requires.extend(["gdcmMSFF", "gdcmDICT", "gdcmDSED", "gdcmIOD", "socketxx"])
Expand All @@ -215,8 +237,6 @@ def package_info(self):
self.cpp_info.components["gdcmMSFF"].system_libs = ["rpcrt4"]
self.cpp_info.components["socketxx"].system_libs = ["ws2_32"]
else:
self.cpp_info.components["gdcmMSFF"].requires.append("gdcmuuid")

self.cpp_info.components["gdcmCommon"].system_libs = ["dl"]
if is_apple_os(self):
self.cpp_info.components["gdcmCommon"].frameworks = ["CoreFoundation"]
Expand Down
22 changes: 22 additions & 0 deletions recipes/gdcm/all/patches/0002-3.0.20-openjpeg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -360,7 +360,7 @@ endif()

if(GDCM_USE_SYSTEM_OPENJPEG)
find_package(OpenJPEG 2.0.0 REQUIRED)
- set(GDCM_OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARIES})
+ set(GDCM_OPENJPEG_LIBRARIES ${OpenJPEG_LIBRARIES})
else()
set(GDCM_OPENJPEG_LIBRARIES gdcmopenjp2)
endif()
--- a/Source/MediaStorageAndFileFormat/CMakeLists.txt
+++ b/Source/MediaStorageAndFileFormat/CMakeLists.txt
@@ -161,7 +161,7 @@ else()
)
endif()
if(GDCM_USE_SYSTEM_OPENJPEG)
- include_directories(${OPENJPEG_INCLUDE_DIRS} )
+ include_directories(${OpenJPEG_INCLUDE_DIRS} )
else()
include_directories(
"${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg"
11 changes: 11 additions & 0 deletions recipes/gdcm/all/patches/0004-3.0.20-find-expat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -419,7 +419,7 @@ endif()

if(GDCM_USE_SYSTEM_EXPAT)
# If user say so, then this is a requirement !
- find_package(EXPAT REQUIRED)
+ find_package(EXPAT REQUIRED MODULE)
set(GDCM_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
else()
set(GDCM_EXPAT_LIBRARIES "gdcmexpat")
23 changes: 23 additions & 0 deletions recipes/gdcm/all/patches/0005-3.0.20-openssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/Source/Common/CMakeLists.txt
+++ b/Source/Common/CMakeLists.txt
@@ -68,18 +68,8 @@ CHECK_CXX_SOURCE_COMPILES(
"\#include <string>\n#include <codecvt>\n#include <locale>\nint main() { std::u16string u16; std::string utf8 = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(u16); }"
GDCM_HAVE_CODECVT)
if(GDCM_USE_SYSTEM_OPENSSL)
-set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
-set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}
- ${CMAKE_DL_LIBS} # FIXME ??
- )
-CHECK_CXX_SOURCE_COMPILES(
- # "\#include <openssl/cms.h>\nint main() { CMS_add0_recipient_key(0); return 0;}"
- #HAVE_CMS_RECIPIENT_KEY)
- "\#include <openssl/cms.h>\nint main() { CMS_add0_recipient_password(0,0,0,0,0,0,0); return 0;}"
- GDCM_HAVE_CMS_RECIPIENT_PASSWORD)
-CHECK_CXX_SOURCE_COMPILES(
- "\#include <openssl/bio.h>\nint main() { const void*mem; int len; BIO_new_mem_buf(mem, len); }"
- OPENSSL_HAS_CONST_VOID_BIO_NEW_MEM_BUF)
+ set(GDCM_HAVE_CMS_RECIPIENT_PASSWORD ON CACHE INTERNAL "")
+ set(OPENSSL_HAS_CONST_VOID_BIO_NEW_MEM_BUF ON CACHE INTERNAL "")
endif()

#-----------------------------------------------------------------------------
19 changes: 19 additions & 0 deletions recipes/gdcm/all/patches/0005-3.0.9-openssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/Source/Common/CMakeLists.txt
+++ b/Source/Common/CMakeLists.txt
@@ -65,15 +65,7 @@ CHECK_CXX_SOURCE_COMPILES(
"\#include <fstream>\nint main() { const wchar_t fn[10] = {}; std::ifstream is( fn ); return 0;}"
GDCM_HAVE_WCHAR_IFSTREAM)
if(GDCM_USE_SYSTEM_OPENSSL)
-set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
-set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}
- ${CMAKE_DL_LIBS} # FIXME ??
- )
-CHECK_CXX_SOURCE_COMPILES(
- # "\#include <openssl/cms.h>\nint main() { CMS_add0_recipient_key(0); return 0;}"
- #HAVE_CMS_RECIPIENT_KEY)
- "\#include <openssl/cms.h>\nint main() { CMS_add0_recipient_password(0,0,0,0,0,0,0); return 0;}"
- GDCM_HAVE_CMS_RECIPIENT_PASSWORD)
+ set(GDCM_HAVE_CMS_RECIPIENT_PASSWORD ON CACHE INTERNAL "")
endif()

#-----------------------------------------------------------------------------
13 changes: 13 additions & 0 deletions recipes/gdcm/all/patches/0006-json.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/Source/Common/CMakeLists.txt
+++ b/Source/Common/CMakeLists.txt
@@ -52,9 +52,7 @@ unset(CMAKE_REQUIRED_LIBRARIES)
CHECK_FUNCTION_EXISTS(gettimeofday GDCM_HAVE_GETTIMEOFDAY)
# json-c API changed:
if(GDCM_USE_SYSTEM_JSON)
- set(CMAKE_REQUIRED_INCLUDES ${JSON_INCLUDE_DIRS})
- set(CMAKE_REQUIRED_LIBRARIES ${JSON_LIBRARIES})
- CHECK_SYMBOL_EXISTS(json_object_object_get_ex "json.h" GDCM_HAVE_JSON_OBJECT_OBJECT_GET_EX)
+ set(GDCM_HAVE_JSON_OBJECT_OBJECT_GET_EX ON CACHE INTERNAL "")
endif()

include(CheckCXXSourceCompiles)
26 changes: 26 additions & 0 deletions recipes/gdcm/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,37 @@
*/

#include "gdcmReader.h"
#include "gdcmUIDGenerator.h"
#include "gdcmWriter.h"
#include "gdcmAttribute.h"

#include <iostream>

#ifdef GDCM_USE_SYSTEM_OPENSSL
#include "gdcmCryptoFactory.h"
void test_openssl_link()
{
(void)gdcm::CryptoFactory::GetFactoryInstance(gdcm::CryptoFactory::OPENSSL);
}
#endif

#ifdef GDCM_USE_SYSTEM_JSON
#include "gdcmJSON.h"
void test_json_link()
{
gdcm::JSON json;
json.PrettyPrintOn();
}
#endif

bool test_uid()
{
gdcm::UIDGenerator uid;
uid.SetRoot( "1.2.3.4.0.0.1" );
const char *s = uid.Generate();
return gdcm::UIDGenerator::IsValid(s);
}

int main(int argc, char* argv[])
{
if (argc < 3)
Expand Down
2 changes: 2 additions & 0 deletions recipes/gdcm/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"3.0.20":
folder: "all"
"3.0.9":
folder: "all"