Error building 4.2.16-2 on MacOS Ventura with ARM CPU

Hi everybody,

while trying to build 4.2.16-2 on a Ventura 13.5 with an M1 CPU, I encounter the following error message:

CMake Error at /hdf/CMake-hdf-4.2.16-2/HDF4config.cmake:204 (else):
Flow control statements are not properly nested.

Up to that point I followed the instructions on

Any hints appreciated!


Yes, line 203 and line 204 in HDF4config.cmake should be removed.The two lines at 205 and 206 should be moved to line 187 after the “else ()”.

That the quick change - we will need to properly fix it.