Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not vendor inih #479

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/stable-compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
apt-get update
apt-get install -y --no-install-recommends --no-install-suggests \
ca-certificates build-essential cmake ninja-build git \
libicu-dev libexpat1-dev
libicu-dev libexpat1-dev libinih-dev

- name: Clone Repository
uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ build/
# IntelliJ / CLion
.idea/

# VS Code
.vscode/
.cache/
compile_commands.json

# doxygen generated files
/doc/

Expand All @@ -72,3 +77,4 @@ test_runner*

# distribution archives
liblcf-*.tar.*

8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ set(LCF_SOURCES
src/dbarray.cpp
src/dbstring_struct.cpp
src/encoder.cpp
src/ini.cpp
src/inireader.cpp
src/ldb_equipment.cpp
src/ldb_eventcommand.cpp
Expand Down Expand Up @@ -201,7 +200,6 @@ set(LCF_HEADERS
src/lcf/encoder.h
src/lcf/enum_tags.h
src/lcf/flag_set.h
src/lcf/ini.h
src/lcf/inireader.h
src/lcf/ldb/reader.h
src/lcf/lmt/reader.h
Expand Down Expand Up @@ -343,6 +341,10 @@ set_property(TARGET lcf PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Name of the exported library
set_property(TARGET lcf PROPERTY EXPORT_NAME liblcf)

# inih
find_package(inih REQUIRED)
target_link_libraries(lcf inih::inih)

# icu
set(LCF_SUPPORT_ICU 0)
if(LIBLCF_WITH_ICU)
Expand Down Expand Up @@ -380,7 +382,6 @@ set_property(TARGET lcf PROPERTY SOVERSION 0)

# installation
if(LIBLCF_ENABLE_INSTALL)

# pkg-config file generation
set(LCF_LIBDIR ${CMAKE_INSTALL_LIBDIR})
if(IS_ABSOLUTE ${LCF_LIBDIR})
Expand Down Expand Up @@ -441,6 +442,7 @@ if(LIBLCF_ENABLE_INSTALL)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/liblcf-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/liblcf-config-version.cmake
${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules/Findinih.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/liblcf
)

Expand Down
6 changes: 4 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ liblcf_la_CXXFLAGS = \
-std=gnu++17 \
-fno-math-errno \
$(AM_CXXFLAGS) \
$(INIH_CFLAGS) \
$(EXPAT_CFLAGS) \
$(ICU_CFLAGS)
liblcf_la_LIBADD = \
$(INIH_LIBS) \
$(EXPAT_LIBS) \
$(ICU_LIBS)
liblcf_la_LDFLAGS = \
Expand All @@ -46,7 +48,6 @@ liblcf_la_SOURCES = \
src/dbarray.cpp \
src/dbstring_struct.cpp \
src/encoder.cpp \
src/ini.cpp \
src/inireader.cpp \
src/ldb_equipment.cpp \
src/ldb_eventcommand.cpp \
Expand Down Expand Up @@ -219,7 +220,6 @@ lcfinclude_HEADERS = \
src/lcf/encoder.h \
src/lcf/enum_tags.h \
src/lcf/flag_set.h \
src/lcf/ini.h \
src/lcf/inireader.h \
src/lcf/log_handler.h \
src/lcf/reader_lcf.h \
Expand Down Expand Up @@ -347,10 +347,12 @@ test_runner_CPPFLAGS = \
test_runner_CXXFLAGS = \
-std=gnu++17 \
-DDOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING=1 \
$(INIH_CXXFLAGS) \
$(EXPAT_CXXFLAGS) \
$(ICU_CXXFLAGS)
test_runner_LDADD = \
liblcf.la \
$(INIH_LIBS) \
$(EXPAT_LIBS) \
$(ICU_LIBS)
test_runner_LDFLAGS = -no-install
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Documentation is available at the documentation wiki: https://wiki.easyrpg.org

## Requirements

- [inih] for INI file reading. (required)
- [Expat] for XML reading support.
- [ICU] for character encoding detection and conversion (recommended).

Expand Down
63 changes: 63 additions & 0 deletions builds/cmake/Modules/Findinih.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#.rst:
# Findinih
# --------
#
# Find the inih Library
#
# Imported Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` targets:
#
# ``inih::inih``
# The ``inih`` library, if found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``INIH_INCLUDE_DIRS``
# where to find inih headers.
# ``INIH_LIBRARIES``
# the libraries to link against to use inih.
# ``INIH_FOUND``
# true if the inih headers and libraries were found.

find_package(PkgConfig QUIET)

pkg_check_modules(PC_INIH QUIET libinih)

# Look for the header file.
find_path(INIH_INCLUDE_DIR
NAMES ini.h
HINTS ${PC_INIH_INCLUDE_DIRS})

# Look for the library.
# Allow INIH_LIBRARY to be set manually, as the location of the inih library
if(NOT INIH_LIBRARY)
find_library(INIH_LIBRARY
NAMES libinih inih
HINTS ${PC_INIH_LIBRARY_DIRS})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(inih
REQUIRED_VARS INIH_LIBRARY INIH_INCLUDE_DIR)

if(INIH_FOUND)
set(INIH_INCLUDE_DIRS ${INIH_INCLUDE_DIR})

if(NOT INIH_LIBRARIES)
set(INIH_LIBRARIES ${INIH_LIBRARIES})
endif()

if(NOT TARGET inih::inih)
add_library(inih::inih UNKNOWN IMPORTED)
set_target_properties(inih::inih PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${INIH_INCLUDE_DIRS}"
IMPORTED_LOCATION "${INIH_LIBRARY}")
endif()
endif()

mark_as_advanced(INIH_INCLUDE_DIR INIH_LIBRARY)
5 changes: 5 additions & 0 deletions builds/cmake/liblcf-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

include(CMakeFindDependencyMacro)

# Required to find our installed Findinih.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

find_dependency(inih REQUIRED)

if(@LCF_SUPPORT_ICU@)
find_dependency(ICU COMPONENTS i18n uc data REQUIRED)
endif()
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ LT_INIT([win32-dll])
AM_CONDITIONAL(CROSS_COMPILING,[test "x$cross_compiling" = "xyes"])

# Checks for libraries.
AX_PKG_CHECK_MODULES([INIH],[],[inih],[])

AC_SUBST([LCF_SUPPORT_ICU],[0])
AC_ARG_ENABLE([icu],[AS_HELP_STRING([--disable-icu],[Disable ICU encoding handling (only windows-1252 supported) [default=no]])])
AS_IF([test "x$enable_icu" != "xno"],[
Expand Down
Loading