Skip to content

Commit

Permalink
CMake: iconv on OSX (#4851)
Browse files Browse the repository at this point in the history
Check for iconv_open availability in libiconv on OSX due
to differences in ICONV builds on that platform
  • Loading branch information
hobu authored Nov 18, 2021
1 parent 97a0899 commit a663c88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmake/helpers/CheckDependentLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include(CheckFunctionExists)
include(CMakeDependentOption)
include(FeatureSummary)
include(DefineFindPackage2)
include(CheckSymbolExists)

# Macro to declare a package
# Accept a CAN_DISABLE option to specify that the package can be disabled
Expand Down
10 changes: 8 additions & 2 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ if (GDAL_USE_ICONV)
target_sources(cpl PRIVATE cpl_recode_iconv.cpp)
else ()
if (APPLE)
target_compile_definitions(cpl PRIVATE -DLIBICONV_PLUG)
endif ()
# linkage against OSX's system iconv is going to require LIBICONV_PLUG to be defined, but other self-built
# situations like CondaForge or Homebrew might not need this
set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARY})
check_symbol_exists(_iconv_close "iconv.h" HAVE_ICONV_CLOSE)
if (HAVE_ICONV_CLOSE)
target_compile_definitions(cpl PRIVATE -DLIBICONV_PLUG)
endif (HAVE_ICONV_CLOSE)
endif (APPLE)
target_sources(cpl PRIVATE cpl_recode_iconv.cpp)
target_include_directories(cpl PRIVATE $<TARGET_PROPERTY:Iconv::Iconv,INTERFACE_INCLUDE_DIRECTORIES>)
gdal_add_private_link_libraries(Iconv::Iconv)
Expand Down

0 comments on commit a663c88

Please sign in to comment.