From 07a01ab860c3c6949d6d871f84b5527c96804eb0 Mon Sep 17 00:00:00 2001 From: sameeul Date: Thu, 1 Feb 2024 15:10:39 -0500 Subject: [PATCH] Fix for JSON initialization issue in Clang --- CMakeLists.txt | 2 ++ src/ome_tiff_to_chunked_pyramid.cpp | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42b468c..f108dbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,9 +79,11 @@ pybind11_add_module(libargolid target_compile_definitions(libargolid PRIVATE VERSION_INFO=${VERSION_INFO}) #target_compile_definitions(libargolid PRIVATE WITH_PYTHON_H) +set(NLJSON_HACK ON) # more details here: https://github.com/nlohmann/json/issues/2311 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") target_link_libraries(libargolid PRIVATE stdc++fs) + set(NLJSON_HACK OFF) endif() target_link_libraries(libargolid PRIVATE tensorstore::tensorstore tensorstore::all_drivers filepattern::filepattern) diff --git a/src/ome_tiff_to_chunked_pyramid.cpp b/src/ome_tiff_to_chunked_pyramid.cpp index fbc64bf..766490c 100644 --- a/src/ome_tiff_to_chunked_pyramid.cpp +++ b/src/ome_tiff_to_chunked_pyramid.cpp @@ -124,8 +124,7 @@ void OmeTiffToChunkedPyramid::WriteTSZattrFile(const std::string& tiff_file_name combined_metadata["name"] = tiff_file_name; combined_metadata["metadata"] = {{"method", "mean"}}; json final_formated_metadata; -#if defined(__clang__) || defined(_MSC_VER) -// more details here: https://github.com/nlohmann/json/issues/2311 +#if defined(NLJSON_HACK) final_formated_metadata["multiscales"][0] = {combined_metadata}; #else final_formated_metadata["multiscales"] = {combined_metadata};