[cmake] Allow LibRaw to be optional dependency of IO [ci skip]

It is not easy to install pre-built libraw on Windows and Mac OSX:
  - Conan does not seem to offer it
  - Vcpkg does offer to be build it, but CI resources are too precious.
This commit is contained in:
Mateusz Łoskot 2019-01-04 14:06:25 +01:00
parent 762af55d08
commit 6d0729b86b
No known key found for this signature in database
GPG Key ID: 928D7C2ABB2AC1F2
2 changed files with 29 additions and 18 deletions

View File

@ -109,7 +109,7 @@ target_compile_definitions(gil_dependencies
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:BOOST_TEST_DYN_LINK>)
#-----------------------------------------------------------------------------
# Dependency: libpng, libjpeg, libtiff via Vcpkg or Conan
# Dependency: libpng, libjpeg, libtiff, libraw via Vcpkg or Conan
#-----------------------------------------------------------------------------
if(GIL_ENABLE_EXT_IO)
if(GIL_USE_CONAN)
@ -152,18 +152,6 @@ if(GIL_ENABLE_EXT_IO)
TIFF::TIFF)
if(UNIX)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake/FindLibRaw.cmake")
message(STATUS "Boost.GIL: Downloading FindLibRaw.cmake from https://github.com/LibRaw/LibRaw-cmake")
file(DOWNLOAD
"https://raw.githubusercontent.com/LibRaw/LibRaw-cmake/master/cmake/modules/FindLibRaw.cmake"
"${CMAKE_BINARY_DIR}/cmake/FindLibRaw.cmake")
endif()
find_package(LibRaw REQUIRED)
target_include_directories(gil_dependencies INTERFACE ${LibRaw_INCLUDE_DIR})
target_link_libraries(gil_dependencies INTERFACE ${LibRaw_LIBRARIES})
target_compile_definitions(gil_dependencies INTERFACE ${LibRaw_DEFINITIONS})
# Typically, Linux packages provide C++ stream interface for TIFF
find_path(TIFFXX_INCLUDE_DIR NAMES tiffio.hxx)
find_library(TIFFXX_LIBRARY NAMES tiffxx)
@ -171,6 +159,20 @@ if(GIL_ENABLE_EXT_IO)
target_link_libraries(gil_dependencies INTERFACE ${TIFFXX_LIBRARY})
endif()
# LibRaw is optional, because it is not easy to install pre-built libraw on Windows and Mac OSX
if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake/FindLibRaw.cmake")
message(STATUS "Boost.GIL: Downloading FindLibRaw.cmake from https://github.com/LibRaw/LibRaw-cmake")
file(DOWNLOAD
"https://raw.githubusercontent.com/LibRaw/LibRaw-cmake/master/cmake/modules/FindLibRaw.cmake"
"${CMAKE_BINARY_DIR}/cmake/FindLibRaw.cmake")
endif()
find_package(LibRaw)
set(GIL_ENABLE_EXT_IO_RAW ${LibRaw_FOUND} CACHE BOOL "Enable IO RAW extension (requires libraw)" FORCE)
if(GIL_ENABLE_EXT_IO_RAW)
target_include_directories(gil_dependencies INTERFACE ${LibRaw_INCLUDE_DIR})
target_link_libraries(gil_dependencies INTERFACE ${LibRaw_LIBRARIES})
target_compile_definitions(gil_dependencies INTERFACE ${LibRaw_DEFINITIONS})
endif()
endif()
endif()

View File

@ -8,15 +8,20 @@
#
message(STATUS "Boost.GIL: Configuring IO extension tests")
foreach(_name
set(_formats
bmp
jpeg
png
pnm
raw
simple
targa
tiff)
if(GIL_ENABLE_EXT_IO_RAW)
list(APPEND _formats raw)
endif()
foreach(_name ${_formats})
set(_target test_ext_io_${_name})
add_executable(${_target} "")
@ -35,6 +40,8 @@ foreach(_name
unset(_target)
endforeach()
unset(_formats)
target_sources(test_ext_io_simple
PRIVATE
all_formats_test.cpp)
@ -55,9 +62,11 @@ target_sources(test_ext_io_pnm
PRIVATE
pnm_test.cpp pnm_old_test.cpp pnm_read_test.cpp pnm_write_test.cpp)
target_sources(test_ext_io_raw
PRIVATE
raw_test.cpp)
if(GIL_ENABLE_EXT_IO_RAW)
target_sources(test_ext_io_raw
PRIVATE
raw_test.cpp)
endif()
target_sources(test_ext_io_targa
PRIVATE