I got the sources for v0.17.1 (595fb32bbbec405ba6e38fa59a3064172b526a2e) of ITKElastix
There is Elastix on the system already, and it would be nice if I don’t have to rebuild it. Thus, I commented these lines out of CMakeLists.txt
I was bitten by a bug which complained about =lomp, for which I managed to work around by replacing =lomp (there is a space before = which is relevant) from build_elastix/Wrapping/Modules/Elastix/CMakeFiles/ElastixCastXML.dir/build.make with -fopenmp=lomp (is there a patch for this that I can use?)
Based on is_integral_v-related error messages, it looks like #include <type_traits> is missing somewhere. Possibly some other headers too. I am unsure about OpenMP-related errors. Perhaps @Niels_Dekker or someone else has an idea?
/usr/include/Core/Install/elxConversion.h:95:24: error: no template named 'is_integral_v' in namespace 'std'; did you mean 'is_integral'?
static_assert(std::is_integral_v<TInteger>, "An integer type expected!");
~~~~~^~~~~~~~~~~~~
is_integral
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/type_traits:441:12: note: 'is_integral' declared here
struct is_integral
However, elxConversion.h does have #include <type_traits>
std::is_integral_v was introduced with C++17 (and is still there with C++20) So I think it has somehow picked the wrong C++ standard version. (Possibly accidentally still C++14?) Would it help if you would explicitly set the CMake variable CXX_STANDARD? Or CMAKE_CXX_STANDARD?
deleted both =libomp and -std=c++14 from build_elastix/Wrapping/Modules/Elastix/CMakeFiles/ElastixCastXML.dir/build.make;
replaced set(INVALID_OPTIMIZATION_FLAGS "-fopenmp;-march=[a-zA-Z0-9\-]*;-mtune=[a-zA-Z0-9\-]*;-mfma")
with set(INVALID_OPTIMIZATION_FLAGS "-fopenmp[a-zA-Z0-9\-=]*;-march=[a-zA-Z0-9\-]*;-mtune=[a-zA-Z0-9\-]*;-mfma;-std=c++14")
in insight-toolkit/Wrapping/macro_files/itk_auto_load_submodules.cmake:31
added this to insight-toolkit/Modules/ThirdParty/pygccxml/src/pygccxml/utils/utils.py::300
(based on build/CMakeFiles/3.29.2/CompilerIdCXX/CMakeCXXCompilerId.cpp),
and re-executed make inside build_elastix,
but it told me that
CMake Warning at CMakeLists.txt:109 (message):
Python wrapping of ITKElastix is known not to work with RelWithDebInfo
configuration. Release is recommended. Your CMAKE_BUILD_TYPE:
CMake Error at CMakeLists.txt:117 (include):
include could not find requested file:
ITKModuleExternal
Thus, I am going to retry again from the start (building ITK again) with those modifications, and see if it helps. I’ll report back later. Thanks.
[EDIT]
I am also adding this to utils.py:
@property
def is_cxx20(self):
"""Returns true if -std=c++14 is being used"""
return self._cplusplus == cxx_standard.__STD_CXX['-std=c++20']
@property
def is_cxx20_or_greater(self):
"""Returns true if -std=c++14 or a newer standard is being used"""
return self._cplusplus >= cxx_standard.__STD_CXX['-std=c++20']
To make sure that -std=c++14 was removed. The error now is
[ 5%] Building C object Modules/ThirdParty/MINC/src/libminc/CMakeFiles/itkminc2.dir/libsrc2/dimension.c.o
In file included from /usr/src/googletest/src/gtest-all.cc:49:
In file included from /usr/src/googletest/src/gtest.cc:44:
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/chrono:2360:48: error: call to consteval function 'std::chrono::hh_mm_ss::_S_fractional_width' is not a constant expression
static constexpr unsigned fractional_width = {_S_fractional_width()};
^
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/chrono:2360:48: note: undefined function '_S_fractional_width' cannot be used in a constant expression
/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/chrono:2315:2: note: declared here
_S_fractional_width()
^
I will now replace the flag std=c++20 from "${_confopts[@]}" and let c++14 be
I only tried with ITKElastix, but setting it with ITK alone yields:
INFO: Running CMake...
-- The CXX compiler identification is Clang 14.0.6
-- The C compiler identification is Clang 14.0.6
-- Detecting CXX compiler ABI info
CMake Error in build/CMakeFiles/CMakeScratch/TryCompile-HiLhj7/CMakeLists.txt:
Target "cmTC_687fb" requires the language dialect "CXX-std=c++20". But
the current compiler "Clang" does not support this, or CMake does not know
the flags to enable it.
CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:64 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
CMakeLists.txt:46 (project)
The same thing happens with c++17. As a reminder, I am using clang14, because that is what ITK 5.3.0 needs. I will try to build again from scratch with c++14. What I did not try was to rebuild elastix (not ITKElastix) with that standard. I’ll check.
I’ll give up on this. I concluded that it is not possible to achieve 5.3.0 with ITKElastix, so I went for 5.4rc03 (the latest compatible with elastix). The compilation of ITK tried to download VXL (VNL) without internet. To go around it, I had to build DCMTK and tried to build vxl, but it is currently not working (Fails to build when dcmtk-3.6.5 is present: fatal error: 'dcistrma.h' file not found · Issue #768 · vxl/vxl · GitHub ; tested with mpicc and clang). I could check the building instructions of VXL inside of insight-toolkit, but I’ll just stop. Thanks.