Skip to content

Commit

Permalink
[inih] Build with Meson + update to r57 (microsoft#33001)
Browse files Browse the repository at this point in the history
* [inih] Use meson build, bump version

* [inih] Versioning

* Specify c++11 to meson to fix osx?

* [inih] Version

* Restore line endings

* Version

* Address review comments

- Removed CMake package versioning
  - Wasn't that useful as upstream don't use semver
- Use straight configure_file to install CMake package config
- Make cpp feature default
- Prefer PkgConfig usage

* Version

* Actually delete the CMakeList

* Version

* separate C and C++ library usage

* Version

* Remove unofficial CMake config

* Revert "Remove unofficial CMake config"

This reverts commit 94ff6a9.

* Take Javier's suggestion
  • Loading branch information
DownerCase authored Aug 11, 2023
1 parent 9434026 commit 0fa8459
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 79 deletions.
56 changes: 0 additions & 56 deletions ports/inih/CMakeLists.txt

This file was deleted.

40 changes: 24 additions & 16 deletions ports/inih/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,42 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO benhoyt/inih
REF 5e1d9e2625842dddb3f9c086a50f22e4f45dfc2b # r56
SHA512 477a66643f6636a5826a1206c6588a12827e24a4a2609e11f0695888998e2bfcba8bdb2240c561404ee675bf4c72e85d7d008a1fbddb142c0d263b413de8d358
REF r57
SHA512 9f758df876df54ed7e228fd82044f184eefbe47e806cd1e6d62e1b0ea28e2c08e67fa743042d73b4baef0b882480e6afe2e72878b175822eb2bdbb6d89c0e411
HEAD_REF master
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
cpp with_INIReader
)

vcpkg_cmake_configure(
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(INIH_CONFIG_DEBUG ON)
else()
set(INIH_CONFIG_DEBUG OFF)
endif()

# Install unofficial CMake package
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-inihConfig.cmake.in" "${CURRENT_PACKAGES_DIR}/share/unofficial-inih/unofficial-inihConfig.cmake" @ONLY)

# meson build
string(REPLACE "OFF" "false" FEATURE_OPTIONS "${FEATURE_OPTIONS}")
string(REPLACE "ON" "true" FEATURE_OPTIONS "${FEATURE_OPTIONS}")

vcpkg_configure_meson(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
"${FEATURE_OPTIONS}"
"-Dcpp_std=c++11"
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-inih)
vcpkg_install_meson()
vcpkg_fixup_pkgconfig()

vcpkg_copy_pdbs()

file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" [=[
inih provides CMake targets:
find_package(unofficial-inih CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::inih::inih)
]=])
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/debug/include")
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
60 changes: 60 additions & 0 deletions ports/inih/unofficial-inihConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
if(TARGET unofficial::inih::libinih)
return()
endif()

set(INIH_WITH_INI_READER @with_INIReader@)
set(INIH_WITH_DEBUG @INIH_CONFIG_DEBUG@)

# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)

###################
#### libinih ####

add_library(unofficial::inih::libinih UNKNOWN IMPORTED)

find_library(INIH_INIHLIB_RELEASE NAMES inih PATHS "${_IMPORT_PREFIX}/lib/" REQUIRED NO_DEFAULT_PATH)
set_target_properties(unofficial::inih::libinih PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_RELEASE "${INIH_INIHLIB_RELEASE}"
IMPORTED_CONFIGURATIONS "RELEASE"
)

if(INIH_WITH_DEBUG)
set_property(TARGET unofficial::inih::libinih APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
find_library(INIH_INIHLIB_DEBUG NAMES inih PATHS "${_IMPORT_PREFIX}/debug/lib/" REQUIRED NO_DEFAULT_PATH)
set_target_properties(unofficial::inih::libinih PROPERTIES
IMPORTED_LOCATION_DEBUG "${INIH_INIHLIB_DEBUG}"
)
endif()

#### libinih ####
###################
#### INIReader ####

if(INIH_WITH_INI_READER)
add_library(unofficial::inih::inireader UNKNOWN IMPORTED)

find_library(INIH_INIREADER_RELEASE NAMES INIReader PATHS "${_IMPORT_PREFIX}/lib/" REQUIRED NO_DEFAULT_PATH)
set_target_properties(unofficial::inih::inireader PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX"
IMPORTED_LOCATION_RELEASE "${INIH_INIREADER_RELEASE}"
INTERFACE_LINK_LIBRARIES "unofficial::inih::libinih"
IMPORTED_CONFIGURATIONS "RELEASE"
)

if(INIH_WITH_DEBUG)
set_property(TARGET unofficial::inih::inireader APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
find_library(INIH_INIREADER_DEBUG NAMES INIReader PATHS "${_IMPORT_PREFIX}/debug/lib/" NO_DEFAULT_PATH)
set_target_properties(unofficial::inih::inireader PROPERTIES
IMPORTED_LOCATION_DEBUG "${INIH_INIREADER_DEBUG}"
)
endif()
endif()

#### INIReader ####
###################
7 changes: 7 additions & 0 deletions ports/inih/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The package inih provides unofficial CMake targets:
find_package(unofficial-inih CONFIG REQUIRED)
# C API
target_link_libraries(main PRIVATE unofficial::inih::libinih)
# C++ API (Requires "cpp" feature)
target_link_libraries(main PRIVATE unofficial::inih::inireader)
Alternatively, if you are using pckgconfig use the name "inih" for the C API and "inireader" for the C++ API
11 changes: 5 additions & 6 deletions ports/inih/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"name": "inih",
"version": "56",
"version": "57",
"description": "Simple .INI file parser",
"homepage": "https://github.com/benhoyt/inih",
"license": "BSD-3-Clause",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"name": "vcpkg-tool-meson",
"host": true
}
],
"default-features": [
"cpp"
],
"features": {
"cpp": {
"description": "Build the C++ library"
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,7 @@
"port-version": 0
},
"inih": {
"baseline": "56",
"baseline": "57",
"port-version": 0
},
"iniparser": {
Expand Down
5 changes: 5 additions & 0 deletions versions/i-/inih.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c5a05cc38f61274fdbef602c91505397b7cd43e8",
"version": "57",
"port-version": 0
},
{
"git-tree": "ccae9a4d18198ac2d9303cac12c4dbb1fbe0bf24",
"version": "56",
Expand Down

0 comments on commit 0fa8459

Please sign in to comment.