From e21522dd9a8db7679c5cb84e6bf0930747d91ced Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sun, 10 Mar 2024 14:53:53 +0800 Subject: [PATCH] improved macOS portability --- CMakeLists.txt | 19 +++++++++++++++---- ext/libetpan/CMakeLists.txt | 18 +++++++----------- src/nmail.1 | 2 +- src/util.cpp | 5 ----- src/util.h | 1 - src/version.cpp | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6804188..055d820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ include(CheckIncludeFile) set(CMAKE_CXX_STANDARD 14) message(STATUS "Using cmake ${CMAKE_VERSION}") +# Modules +include(CheckIncludeFiles) + # Ccache find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) @@ -204,10 +207,18 @@ endif() # Dependency platform specifics if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if (NOT HAS_CUSTOM_LIBETPAN) - FIND_LIBRARY(CARBON_LIBRARY CoreFoundation) - FIND_LIBRARY(CARBON_LIBRARY Security) - FIND_LIBRARY(CARBON_LIBRARY CFNetwork) - target_link_libraries(nmail PUBLIC z iconv "-framework CoreFoundation" "-framework Security" "-framework CFNetwork") + find_package(ZLIB REQUIRED) + find_library(ICONV_LIBRARY iconv REQUIRED) + find_library(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED) + find_library(SECURITY_LIBRARY Security REQUIRED) + target_link_libraries(nmail PUBLIC ${ZLIB_LIBRARIES} "${ICONV_LIBRARY}" "${COREFOUNDATION_LIBRARY}" "${SECURITY_LIBRARY}") + + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}) + check_include_files("CFNetwork/CFNetwork.h" HAVE_CFNETWORK LANGUAGE C) + if (HAVE_CFNETWORK) + find_library(CFNETWORK_LIBRARY CFNetwork REQUIRED) + target_link_libraries(nmail PUBLIC "${CFNETWORK_LIBRARY}") + endif() endif() endif() diff --git a/ext/libetpan/CMakeLists.txt b/ext/libetpan/CMakeLists.txt index 65173d7..5d4c743 100644 --- a/ext/libetpan/CMakeLists.txt +++ b/ext/libetpan/CMakeLists.txt @@ -357,15 +357,6 @@ find_path(CYRUS_SASL_INCLUDE_DIR sasl/sasl.h PATH_SUFFIXES include) find_package_handle_standard_args(sasl2 DEFAULT_MSG CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) target_include_directories(${LIBNAME} PRIVATE ${CYRUS_SASL_INCLUDE_DIR}) -# Find Dependencies - System Libs -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - find_library(CARBON_LIBRARY CoreFoundation REQUIRED) - if(${HAVE_CFNETWORK}) - find_library(CARBON_LIBRARY CFNetwork REQUIRED) - endif() - find_library(CARBON_LIBRARY Security REQUIRED) -endif() - # Find Dependencies - zlib find_package(ZLIB REQUIRED) target_include_directories(${LIBNAME} PRIVATE ${ZLIB_INCLUDE_DIRS}) @@ -378,9 +369,14 @@ target_link_libraries(${LIBNAME} PUBLIC ${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${Z # Linking (macOS) if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - target_link_libraries(${LIBNAME} PUBLIC iconv "-framework CoreFoundation" "-framework Security") + find_library(ICONV_LIBRARY iconv REQUIRED) + find_library(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED) + find_library(SECURITY_LIBRARY Security REQUIRED) + + target_link_libraries(${LIBNAME} PUBLIC "${ICONV_LIBRARY}" "${COREFOUNDATION_LIBRARY}" "${SECURITY_LIBRARY}") if(${HAVE_CFNETWORK}) - target_link_libraries(${LIBNAME} PUBLIC "-framework CFNetwork") + find_library(CFNETWORK_LIBRARY CFNetwork REQUIRED) + target_link_libraries(${LIBNAME} PUBLIC "${CFNETWORK_LIBRARY}") endif() endif() diff --git a/src/nmail.1 b/src/nmail.1 index c98b01b..2ffbdec 100644 --- a/src/nmail.1 +++ b/src/nmail.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NMAIL "1" "March 2024" "nmail v4.53" "User Commands" +.TH NMAIL "1" "March 2024" "nmail v4.54" "User Commands" .SH NAME nmail \- ncurses mail .SH SYNOPSIS diff --git a/src/util.cpp b/src/util.cpp index 2cb55c5..410ad04 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -386,11 +386,6 @@ void Util::Move(const std::string& p_From, const std::string& p_To) apathy::Path::move(p_From, p_To); } -void Util::Touch(const std::string& p_Path) -{ - utimensat(0, p_Path.c_str(), NULL, 0); -} - std::string Util::GetApplicationDir() { return m_ApplicationDir; diff --git a/src/util.h b/src/util.h index 3c75bdf..b172132 100644 --- a/src/util.h +++ b/src/util.h @@ -133,7 +133,6 @@ class Util static void MkDir(const std::string& p_Path); static void RmDir(const std::string& p_Path); static void Move(const std::string& p_From, const std::string& p_To); - static void Touch(const std::string& p_Path); static std::string GetApplicationDir(); static void SetApplicationDir(const std::string& p_Path); static std::string GetTempDir(); diff --git a/src/version.cpp b/src/version.cpp index b61f159..157c0bd 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -7,7 +7,7 @@ #include "version.h" -#define NMAIL_VERSION "4.53" +#define NMAIL_VERSION "4.54" std::string Version::GetBuildOs() {