From 570c9dfab7fafab1515cf3cd1c9fa76a68ef195a Mon Sep 17 00:00:00 2001 From: star9029 Date: Mon, 24 Jun 2024 21:57:38 +0800 Subject: [PATCH] cppp-reiconv: fix install (#4451) --- .../c/cppp-reiconv/patches/2.1.0/cmake.patch | 49 +++++++++++++++++++ packages/c/cppp-reiconv/xmake.lua | 38 +++++++------- 2 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 packages/c/cppp-reiconv/patches/2.1.0/cmake.patch diff --git a/packages/c/cppp-reiconv/patches/2.1.0/cmake.patch b/packages/c/cppp-reiconv/patches/2.1.0/cmake.patch new file mode 100644 index 000000000..4acf2212c --- /dev/null +++ b/packages/c/cppp-reiconv/patches/2.1.0/cmake.patch @@ -0,0 +1,49 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6d3c761..0689164 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -48,7 +48,7 @@ if(MSVC) + endif() + + # Generate header file for build +-if(WIN32) ++if(WIN32 AND BUILD_SHARED_LIBS) + set(DLL_VARIABLE "__declspec(dllexport)") + elseif(HAVE_VISIBILITY) + set(DLL_VARIABLE "__attribute__((__visibility__(\"default\")))") +@@ -59,7 +59,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/reiconv.hpp.in" "${outp + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/windows/libcppp-reiconv.rc.in" "${CMAKE_BINARY_DIR}/windows/libcppp-reiconv.rc") + + # Generate header file for install +-if(WIN32) ++if(WIN32 AND BUILD_SHARED_LIBS) + set(DLL_VARIABLE "__declspec(dllimport)") + else() + set(DLL_VARIABLE "") +@@ -83,7 +83,7 @@ cppp_build_library(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/lib/iconv.cpp" T + + # Include test suite. + include("tests/tests.cmake") +- ++if (NOT BUILD_SHARED_LIBS) + # Install + # Static + # PERMISSIONS 0644 +@@ -94,7 +94,7 @@ install(TARGETS libcppp-reiconv.static + ARCHIVE DESTINATION "${install_staticdir}" + RUNTIME DESTINATION "${install_bindir}" + INCLUDES DESTINATION "${install_includedir}" ) +- ++else() + # Shared + # PERMISSIONS 0755 + install(TARGETS libcppp-reiconv.shared +@@ -105,7 +105,7 @@ install(TARGETS libcppp-reiconv.shared + ARCHIVE DESTINATION "${install_staticdir}" + RUNTIME DESTINATION "${install_bindir}" + INCLUDES DESTINATION "${install_includedir}" ) +- ++endif() + # Includes + # install includes + # PERMISSIONS 0644 diff --git a/packages/c/cppp-reiconv/xmake.lua b/packages/c/cppp-reiconv/xmake.lua index b43cbd986..cb8b19189 100644 --- a/packages/c/cppp-reiconv/xmake.lua +++ b/packages/c/cppp-reiconv/xmake.lua @@ -1,39 +1,39 @@ package("cppp-reiconv") - set_homepage("https://github.com/cppp-project/cppp-reiconv") set_description("A character set conversion library based on GNU LIBICONV.") + set_license("LGPL-3.0") - add_urls("https://github.com/cppp-project/cppp-reiconv/releases/download/$(version)/cppp-reiconv-$(version).zip") + add_urls("https://github.com/cppp-project/cppp-reiconv/releases/download/$(version)/cppp-reiconv-$(version).zip", + "https://github.com/cppp-project/cppp-reiconv.git") add_versions("v2.1.0", "3e539785a437843793c5ce2f8a72cb08f2b543cba11635b06db25cfc6d9cc3a4") + add_patches("2.1.0", "patches/2.1.0/cmake.patch", "21bd2fcb5874f8774af1360aaac51073b67bf4c754096f0fe162d66632c1b7f9") + add_deps("cmake", "python") on_install(function (package) - local configs = {} - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + local configs = {"-DENABLE_TEST=OFF", "-DENABLE_EXTRA=ON"} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) - table.insert(configs, "-DENABLE_EXTRA=ON") - table.insert(configs, "-DENABLE_TEST=OFF") import("package.tools.cmake").install(package, configs) end) on_test(function (package) assert(package:check_cxxsnippets({test = [[ - #include - #include - #include - using namespace cppp::base::reiconv; + #include + #include + #include + using namespace cppp::base::reiconv; - void test() - { - iconv_t cd = iconv_open("UTF-8", "UTF-8"); - if (cd == (iconv_t)(-1)) + void test() { - abort(); + iconv_t cd = iconv_open("UTF-8", "UTF-8"); + if (cd == (iconv_t)(-1)) + { + abort(); + } + iconv_close(cd); } - iconv_close(cd); - } - ]]}, {configs = {languages = "c++14"}})) + ]]}, {configs = {languages = "c++14"}})) end) -