Open NikkittaP opened 5 years ago
I'm still facing the same problem on Ubuntu 18.04. Any ideas?
Oookaay, here is my solution for now:
In the main CMakeLists.txt I commented out lines 179-189. These lines checks functions in TIFF library and somehow it fails on Linux. I will add more info if I have any problems while using this built libgeotiff library.
I think this can be fixed by adding this line to CMakeLists.txt
:
cmake_policy(SET CMP0075 NEW)
Specifically, the CMake checks don't seem to honor the CMAKE_REQUIRED_LIBRARIES
. This causes failure when you try to link against libraries on your system.
Another option is to pass -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
to cmake
.
For me this happened because cmake was looking for libtiff using FIND_PACKAGE and found it, but only the variables TIFF_FOUND, TIFF_DIR, TIFF_VERSION were set, the variable TIFF_LIBRARIES was not, but was needed. I actually had to explicitly set the libraries in the /usr/share/cmake-3.22/Modules/CheckFunctionExists.cmake
file to circumvent the issue.
Yes, the CMake package generated by libtiff upstream does not provide TIFF_LIBRARIES
, so nothing ends up being passed to the try_compile
for linking.in order to pass. The check needs reworked to handle this case. Something like this may be fine:
if (NOT TIFF_LIBRARIES AND TARGET TIFF::tiff)
get_property(TIFF_LIBRARIES TARGET TIFF::tiff PROPERTY LOCATION)
# request a `STATIC` library in `try_compile` as dependent libraries are not provided this way?
endif ()
I use libgeotiff 1.5.1 and libtiff 4.0.10. To build everything I use CMake and make.
TIFF:
cmake -G 'Unix Makefiles' ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/nikita/OSG/test_osg/install/libtiff/Release -DZLIB_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/zlib/Release/include/ -DZLIB_LIBRARY_RELEASE=/home/nikita/OSG/test_osg/install/zlib/Release/lib/libz.so -DJPEG_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/libjpeg/Release/include/ -DJPEG_LIBRARY=/home/nikita/OSG/test_osg/install/libjpeg/Release/lib/libjpeg.so
libgeotiff:
cmake -G 'Unix Makefiles' ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/nikita/OSG/test_osg/install/libgeotiff/Release -DWITH_UTILITIES=OFF -DWITH_JPEG=ON -DWITH_TIFF=ON -DWITH_ZLIB=ON -DPROJ_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/proj/Release/include/ -DPROJ_LIBRARY=/home/nikita/OSG/test_osg/install/proj/Release/lib/libproj.so -DZLIB_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/zlib/Release/include/ -DZLIB_LIBRARY_RELEASE=/home/nikita/OSG/test_osg/install/zlib/Release/lib/libz.so -DJPEG_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/libjpeg/Release/include/ -DJPEG_LIBRARY=/home/nikita/OSG/test_osg/install/libjpeg/Release/lib/libjpeg.so -DTIFF_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/libtiff/Release/include/ -DTIFF_LIBRARY_RELEASE=/home/nikita/OSG/test_osg/install/libtiff/Release/lib/libtiff.so
And while configuring CMake for geotiff I get the following error:
The same sources on Windows with CMake and MSVC 2015 are built properly with no errors.