Skip to content

Commit

Permalink
Merge pull request #130 from aous72/better_tiff_support
Browse files Browse the repository at this point in the history
For Windows, removes the hardcoded TIFF_PATH, must use CMAKE_PREFIX_PATH.
  • Loading branch information
aous72 authored Feb 25, 2024
2 parents 4d1dfe8 + 61ea3eb commit 1761bfe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ option(OJPH_ENABLE_TIFF_SUPPORT "Enables input and output support for TIFF files
option(OJPH_BUILD_TESTS "Enables building test code" OFF)
option(OJPH_BUILD_EXECUTABLES "Enables building command line executables" ON)

## specify the top directory for TIFF library (only for Microsoft Visual Studio)
if (MSVC)
set(TIFF_PATH "C:\\Program Files\\tiff")
endif()

## Setting some of the options if EMSCRIPTEN is the compiler
if(EMSCRIPTEN)
set(OJPH_DISABLE_INTEL_SIMD ON)
Expand Down Expand Up @@ -52,6 +47,7 @@ endif()
message(STATUS "Building ${CMAKE_BUILD_TYPE}")

## C++ version and flags
# C++14 is needed for gtest, otherwise, C++11 is sufficient for the library
set(CMAKE_CXX_STANDARD 14)
if (MSVC)
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
Expand Down
21 changes: 4 additions & 17 deletions src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,16 @@
############################################################
if( OJPH_ENABLE_TIFF_SUPPORT )

if( MSVC )

set(TIFF_INCLUDE_DIR "${TIFF_PATH}\\include" CACHE PATH "the directory containing the TIFF headers")
set(TIFF_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations")
set(TIFF_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations")
set(TIFFXX_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations")
set(TIFFXX_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations")

message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" )
message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " )
message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " )
message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " )
message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " )
message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " )

endif( MSVC )

FIND_PACKAGE( TIFF )

if( TIFF_FOUND )
set(USE_TIFF TRUE CACHE BOOL "Add TIFF support")
include_directories( ${TIFF_INCLUDE_DIR} )
add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT)
elseif(MSVC)
message(STATUS "TIFF support has been enabled by no path to the TIFF library "
"has been specified; please configure with -DCMAKE_PREFIX_PATH=<TIFF library directory>, "
"or disable TIFF support using -DOJPH_ENABLE_TIFF_SUPPORT=OFF.")
endif( TIFF_FOUND )

endif()
Expand Down
11 changes: 4 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@ if (MSVC)
COMMAND ${CMAKE_COMMAND} -E copy "./\$(Configuration)/mse_pae.exe" "./"
)
if (MSVC AND OJPH_ENABLE_TIFF_SUPPORT)
if (CMAKE_BUILD_TYPE MATCHES "Release")
file(COPY "${TIFF_PATH}\\bin\\tiff.dll" DESTINATION "./")
file(COPY "${TIFF_PATH}\\bin\\tiffxx.dll" DESTINATION "./")
elseif(CMAKE_BUILD_TYPE MATCHES "Debug")
file(COPY "${TIFF_PATH}\\bin\\tiffd.dll" DESTINATION "./")
file(COPY "${TIFF_PATH}\\bin\\tiffxxd.dll" DESTINATION "./")
endif()
file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiff.dll" DESTINATION "./")
file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiffxx.dll" DESTINATION "./")
file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiffd.dll" DESTINATION "./")
file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiffxxd.dll" DESTINATION "./")
endif()
else()
add_custom_command(TARGET test_executables POST_BUILD
Expand Down

0 comments on commit 1761bfe

Please sign in to comment.