From bcc8b849b3739b7655d8cf95c3d00c4e6298c15b Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Mon, 23 Oct 2023 20:29:14 +0200 Subject: [PATCH] [libconfig] Cleanup, fix libconfig++ cmake export (#34646) * [libconfig] No vendored CMakeLists.txt * [libconfig] Cleanup * [libconfig] Fix libconfig++ cmake export --- ports/libconfig/CMakeLists.txt | 53 ------------------ ports/libconfig/libconfig++-cmake-export.diff | 22 ++++++++ ports/libconfig/portfile.cmake | 56 ++++++------------- ports/libconfig/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/l-/libconfig.json | 5 ++ 6 files changed, 45 insertions(+), 95 deletions(-) delete mode 100644 ports/libconfig/CMakeLists.txt create mode 100644 ports/libconfig/libconfig++-cmake-export.diff diff --git a/ports/libconfig/CMakeLists.txt b/ports/libconfig/CMakeLists.txt deleted file mode 100644 index ab6711ad9c8a74..00000000000000 --- a/ports/libconfig/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.5.1) -project(libconfig C CXX) - -if(MSVC) - add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS -DYY_NO_UNISTD_H -DYY_USE_CONST) -endif() - -set(C_SOURCES - lib/grammar.c - lib/libconfig.c - lib/scanctx.c - lib/scanner.c - lib/strbuf.c - lib/strvec.c - lib/util.c - lib/wincompat.c -) - -set(CPP_SOURCES - lib/libconfigcpp.cc -) - -set(CMAKE_C_STANDARD 99) - -include_directories(lib ${STDINT_H}) - -add_library(libconfig ${C_SOURCES}) -add_library(libconfig++ ${CPP_SOURCES}) - -if(BUILD_SHARED_LIBS) - target_compile_definitions(libconfig PRIVATE -DLIBCONFIG_EXPORTS) - target_compile_definitions(libconfig++ PRIVATE -DLIBCONFIGXX_EXPORTS) -else() - target_compile_definitions(libconfig PUBLIC -DLIBCONFIG_STATIC) - target_compile_definitions(libconfig++ PUBLIC -DLIBCONFIGXX_STATIC) -endif() - -if (WIN32) - # Linux doesn't have shlwapi - target_link_libraries(libconfig shlwapi) -endif() -target_link_libraries(libconfig++ PRIVATE libconfig) - -install( - TARGETS libconfig libconfig++ - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) - -if(NOT DISABLE_INSTALL_HEADERS) - install(FILES lib/libconfig.h++ lib/libconfig.h DESTINATION include) -endif() diff --git a/ports/libconfig/libconfig++-cmake-export.diff b/ports/libconfig/libconfig++-cmake-export.diff new file mode 100644 index 00000000000000..d7ef5911abca57 --- /dev/null +++ b/ports/libconfig/libconfig++-cmake-export.diff @@ -0,0 +1,22 @@ +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 3a64deb..233c89f 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -112,7 +112,7 @@ install(TARGETS ${libname} + ) + + install(TARGETS ${libname}++ +- EXPORT libconfig++Targets ++ EXPORT libconfigTargets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +@@ -121,7 +121,7 @@ install(TARGETS ${libname}++ + + + include(CMakePackageConfigHelpers) +-foreach(target_name libconfig libconfig++) ++foreach(target_name libconfig) + write_basic_package_version_file("${target_name}ConfigVersion.cmake" + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMajorVersion diff --git a/ports/libconfig/portfile.cmake b/ports/libconfig/portfile.cmake index a5471ba9034ebd..d4022d721edd8a 100644 --- a/ports/libconfig/portfile.cmake +++ b/ports/libconfig/portfile.cmake @@ -1,52 +1,28 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO hyperrealm/libconfig - REF v1.7.3 + REF "v${VERSION}" SHA512 3749bf9eb29bab0f6b14f4fc759f0c419ed27a843842aaabed1ec1fbe0faa8c93322ff875ca1291d69cb28a39ece86d512aec42c2140d566c38c56dc616734f4 HEAD_REF master + PATCHES + libconfig++-cmake-export.diff ) -if (NOT VCPKG_USE_HEAD_VERSION) - message("If you would like to use cmake with the port, use `--head` option with vcpkg install.") - file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") -endif() - -if (NOT VCPKG_USE_HEAD_VERSION) - vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON - ) -else() - vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - -DBUILD_EXAMPLES=OFF - -DBUILD_TESTS=OFF - ) -endif() - +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_EXAMPLES=OFF + -DBUILD_TESTS=OFF +) vcpkg_cmake_install() - vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libconfig) -if (VCPKG_USE_HEAD_VERSION) - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libconfig) -endif() - -foreach(FILE "${CURRENT_PACKAGES_DIR}/include/libconfig.h++" "${CURRENT_PACKAGES_DIR}/include/libconfig.h") - file(READ ${FILE} _contents) - string(REPLACE "defined(LIBCONFIGXX_EXPORTS)" "0" _contents "${_contents}") - string(REPLACE "defined(LIBCONFIG_EXPORTS)" "0" _contents "${_contents}") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - string(REPLACE "defined(LIBCONFIGXX_STATIC)" "0" _contents "${_contents}") - string(REPLACE "defined(LIBCONFIG_STATIC)" "0" _contents "${_contents}") - else() - string(REPLACE "defined(LIBCONFIGXX_STATIC)" "1" _contents "${_contents}") - string(REPLACE "defined(LIBCONFIG_STATIC)" "1" _contents "${_contents}") - endif() - file(WRITE ${FILE} "${_contents}") -endforeach() +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libconfig.h" "defined(LIBCONFIG_STATIC)" "1") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libconfig.h++" "defined(LIBCONFIGXX_STATIC)" "1") +endif() -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/libconfig/vcpkg.json b/ports/libconfig/vcpkg.json index 46e5a2b8161bdc..794e91f4642103 100644 --- a/ports/libconfig/vcpkg.json +++ b/ports/libconfig/vcpkg.json @@ -1,7 +1,7 @@ { "name": "libconfig", "version": "1.7.3", - "port-version": 3, + "port-version": 4, "description": "C/C++ library for processing configuration files", "homepage": "https://github.com/hyperrealm/libconfig", "dependencies": [ diff --git a/versions/baseline.json b/versions/baseline.json index 7610dd90fbaa0c..be39ab665b2bc4 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4042,7 +4042,7 @@ }, "libconfig": { "baseline": "1.7.3", - "port-version": 3 + "port-version": 4 }, "libconfuse": { "baseline": "2019-07-14", diff --git a/versions/l-/libconfig.json b/versions/l-/libconfig.json index 7f98184b0bd1a3..38ee00e4698c22 100644 --- a/versions/l-/libconfig.json +++ b/versions/l-/libconfig.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "378d40ce036cf220dfaedf27f625a28d6e72d3e9", + "version": "1.7.3", + "port-version": 4 + }, { "git-tree": "9056cd67b1885ed4721a931467fb7fd1eb5b4bf3", "version": "1.7.3",