CMake: Improve finding Iconv

Continue when Iconv can not be found.
Silence warnings when testing if second argument for iconv() is const.
Use correct include dir.
This commit is contained in:
Maarten Bent
2018-12-12 20:37:14 +01:00
parent 14570b4fa3
commit b9d31dffc5
4 changed files with 26 additions and 15 deletions

View File

@@ -154,15 +154,25 @@ if(wxUSE_LIBLZMA)
find_package(LibLZMA REQUIRED) find_package(LibLZMA REQUIRED)
endif() endif()
if(UNIX AND wxUSE_SECRETSTORE) if(UNIX)
# The required APIs are always available under MSW and OS X but we must if(wxUSE_SECRETSTORE)
# have GNOME libsecret under Unix to be able to compile this class. # The required APIs are always available under MSW and OS X but we must
find_package(Libsecret REQUIRED) # have GNOME libsecret under Unix to be able to compile this class.
if(NOT LIBSECRET_FOUND) find_package(Libsecret REQUIRED)
message(WARNING "libsecret not found, wxSecretStore won't be available") if(NOT LIBSECRET_FOUND)
wx_option_force_value(wxUSE_SECRETSTORE OFF) message(WARNING "libsecret not found, wxSecretStore won't be available")
wx_option_force_value(wxUSE_SECRETSTORE OFF)
endif()
endif() endif()
endif()
if(wxUSE_LIBICONV)
find_package(Iconv)
if(NOT ICONV_FOUND)
message(WARNING "iconv not found")
wx_option_force_value(wxUSE_LIBICONV OFF)
endif()
endif()
endif(UNIX)
if(wxUSE_GUI) if(wxUSE_GUI)
if(WXMSW AND wxUSE_METAFILE) if(WXMSW AND wxUSE_METAFILE)

View File

@@ -48,8 +48,8 @@ if(UNIX AND wxUSE_SECRETSTORE)
wx_lib_include_directories(base PRIVATE ${LIBSECRET_INCLUDE_DIRS}) wx_lib_include_directories(base PRIVATE ${LIBSECRET_INCLUDE_DIRS})
wx_lib_link_libraries(base PRIVATE ${LIBSECRET_LIBRARIES}) wx_lib_link_libraries(base PRIVATE ${LIBSECRET_LIBRARIES})
endif() endif()
if(wxUSE_LIBICONV AND ICONV_FOUND) if(wxUSE_LIBICONV)
wx_lib_include_directories(base PRIVATE ${ICONV_INCLUDE_DIRS}) wx_lib_include_directories(base PRIVATE ${ICONV_INCLUDE_DIR})
wx_lib_link_libraries(base PRIVATE ${ICONV_LIBRARIES}) wx_lib_link_libraries(base PRIVATE ${ICONV_LIBRARIES})
endif() endif()
if(wxUSE_THREADS AND CMAKE_THREAD_LIBS_INIT) if(wxUSE_THREADS AND CMAKE_THREAD_LIBS_INIT)

View File

@@ -25,6 +25,7 @@ ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
set(CMAKE_REQUIRED_QUIET ON)
IF(ICONV_FOUND) IF(ICONV_FOUND)
check_cxx_source_compiles(" check_cxx_source_compiles("
#include <iconv.h> #include <iconv.h>
@@ -41,6 +42,7 @@ IF(ICONV_FOUND)
ENDIF(ICONV_FOUND) ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_QUIET)
IF(ICONV_FOUND) IF(ICONV_FOUND)
IF(NOT ICONV_FIND_QUIETLY) IF(NOT ICONV_FIND_QUIETLY)

View File

@@ -217,9 +217,8 @@ macro(wx_get_socket_param_type name code)
endmacro() endmacro()
# the following tests are for Unix(like) systems only # the following tests are for Unix(like) systems only
if(NOT WIN32) if(UNIX)
if(wxUSE_LIBICONV AND NOT APPLE) if(wxUSE_LIBICONV)
find_package(Iconv REQUIRED)
set(HAVE_ICONV ON) set(HAVE_ICONV ON)
set(ICONV_CONST " ") set(ICONV_CONST " ")
if(ICONV_SECOND_ARGUMENT_IS_CONST) if(ICONV_SECOND_ARGUMENT_IS_CONST)
@@ -419,8 +418,8 @@ if(NOT WIN32)
check_symbol_exists(getservbyname netdb.h HAVE_GETSERVBYNAME) check_symbol_exists(getservbyname netdb.h HAVE_GETSERVBYNAME)
check_symbol_exists(inet_aton arpa/inet.h HAVE_INET_ATON) check_symbol_exists(inet_aton arpa/inet.h HAVE_INET_ATON)
check_symbol_exists(inet_addr arpa/inet.h HAVE_INET_ADDR) check_symbol_exists(inet_addr arpa/inet.h HAVE_INET_ADDR)
endif() # wxUSE_SOCKETS endif(wxUSE_SOCKETS)
endif() # NOT WIN32 endif(UNIX)
if(CMAKE_USE_PTHREADS_INIT) if(CMAKE_USE_PTHREADS_INIT)
cmake_push_check_state(RESET) cmake_push_check_state(RESET)