From 814a2441e76b54bfc2d4dd8961a9b43d996bcc0c Mon Sep 17 00:00:00 2001 From: Jeremy Maitin-Shepard Date: Wed, 21 Sep 2022 13:42:08 -0700 Subject: Fix CMake build to be compatible with FetchContent Recent versions of CMake have improved support for including dependencies, using the FetchContent module, which allows a dependency to be imported as a subproject and then later found automatically by calls to `find_package`. This change makes libtiff's CMake better behaved when used as a sub-project: - CMake has a single global namespace for all target names in all sub-projects. This commit renames the following CMake targets: - port -> tiff_port - mkg3states -> tiff_mkg3states - faxtable -> tiff_faxtable - release -> tiff_release - When building TIFF as a sub-project, it is not normally useful to create install rules for its targets. This commit adds a `tiff-install` option that controls whether the install rules are added and defaults to OFF when libtiff is included as a sub-project. - Previously, libtiff set `BUILD_SHARED_LIBS` to ON by default. With this commit, that default is only set if libtiff is the top-level project. - When using `find_package(TIFF)`, the targets `TIFF::TIFF` and `TIFF::CXX` are defined. This commit makes libtiff itself define those targets as aliases, to allow other cmake projects to use either `find_package` or `FetchContent` interchangeably. - Adds ZSTD_HAVE_DECOMPRESS_STREAM variable which may be set to bypass `check_symbol_exists` call. Fixes https://gitlab.com/libtiff/libtiff/-/issues/472. --- port/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'port') diff --git a/port/CMakeLists.txt b/port/CMakeLists.txt index fd459162..04bd3ea8 100755 --- a/port/CMakeLists.txt +++ b/port/CMakeLists.txt @@ -31,21 +31,21 @@ set(port_HEADERS libport.h) # Only build if any needed features are missing if(NOT HAVE_GETOPT) - add_library(port STATIC ../placeholder.h) + add_library(tiff_port STATIC ../placeholder.h) # Add getopt if missing if(NOT HAVE_GETOPT) - target_sources(port PUBLIC + target_sources(tiff_port PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/getopt.c) endif() - target_include_directories(port PUBLIC + target_include_directories(tiff_port PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) else() # Dummy interface library - add_library(port INTERFACE) - target_include_directories(port INTERFACE + add_library(tiff_port INTERFACE) + target_include_directories(tiff_port INTERFACE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) endif() -- cgit v1.2.1