Skip to content

Commit

Permalink
[libconfig] Cleanup, fix libconfig++ cmake export (microsoft#34646)
Browse files Browse the repository at this point in the history
* [libconfig] No vendored CMakeLists.txt

* [libconfig] Cleanup

* [libconfig] Fix libconfig++ cmake export
  • Loading branch information
dg0yt authored Oct 23, 2023
1 parent af4749f commit bcc8b84
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 95 deletions.
53 changes: 0 additions & 53 deletions ports/libconfig/CMakeLists.txt

This file was deleted.

22 changes: 22 additions & 0 deletions ports/libconfig/libconfig++-cmake-export.diff
Original file line number Diff line number Diff line change
@@ -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
56 changes: 16 additions & 40 deletions ports/libconfig/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion ports/libconfig/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4042,7 +4042,7 @@
},
"libconfig": {
"baseline": "1.7.3",
"port-version": 3
"port-version": 4
},
"libconfuse": {
"baseline": "2019-07-14",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "378d40ce036cf220dfaedf27f625a28d6e72d3e9",
"version": "1.7.3",
"port-version": 4
},
{
"git-tree": "9056cd67b1885ed4721a931467fb7fd1eb5b4bf3",
"version": "1.7.3",
Expand Down

0 comments on commit bcc8b84

Please sign in to comment.