Skip to content

Commit

Permalink
Don't strictly require inih
Browse files Browse the repository at this point in the history
inih isn't used by anything in liblcf directly, relaxing this requirement
and allowing it to be disabled enables outside projects to more easily
integrate this library into their application.

This PR enables this while still making it the default, so the current behavior
is the default one requiring no changes in existing apps (easyrpg-player)
  • Loading branch information
Antidote committed Jan 3, 2025
1 parent 5e77d3e commit 0c57f77
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include(MiscUtils)

# Compilation options
option(BUILD_SHARED_LIBS "Build shared library, disable for building the static library (default: ON)" ON)
option(LIBLCF_WITH_INIH "INI parsing support, (inih, default: ON)" ON)
option(LIBLCF_WITH_ICU "ICU encoding handling (when disabled only windows-1252 is supported, default: ON)" ON)
option(LIBLCF_WITH_XML "XML reading support (expat, default: ON)" ON)
option(LIBLCF_UPDATE_MIMEDB "Whether to run update-mime-database after install (default: ON)" ON)
Expand All @@ -30,7 +31,6 @@ set(LCF_SOURCES
src/dbarray.cpp
src/dbstring_struct.cpp
src/encoder.cpp
src/inireader.cpp
src/ldb_equipment.cpp
src/ldb_eventcommand.cpp
src/ldb_parameters.cpp
Expand Down Expand Up @@ -203,7 +203,6 @@ set(LCF_HEADERS
src/lcf/encoder.h
src/lcf/enum_tags.h
src/lcf/flag_set.h
src/lcf/inireader.h
src/lcf/ldb/reader.h
src/lcf/lmt/reader.h
src/lcf/lmu/reader.h
Expand Down Expand Up @@ -295,6 +294,19 @@ set(LCF_HEADERS
src/lcf/third_party/string_view.h
)



set(LCF_SUPPORT_INIH 0)
if(LIBLCF_WITH_INIH)
list(APPEND LCF_SOURCES
src/inireader.cpp
)
list(APPEND LCF_HEADERS
src/lcf/inireader.h
)
set(LCF_SUPPORT_INIH 1)
endif()

add_library(lcf ${LCF_SOURCES} ${LCF_HEADERS})

# IDE source grouping
Expand Down Expand Up @@ -345,8 +357,10 @@ set_property(TARGET lcf PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
set_property(TARGET lcf PROPERTY EXPORT_NAME liblcf)

# inih
find_package(inih REQUIRED)
target_link_libraries(lcf inih::inih)
if (LCF_SUPPORT_INIH)
find_package(inih REQUIRED)
target_link_libraries(lcf inih::inih)
endif ()

# icu
set(LCF_SUPPORT_ICU 0)
Expand Down

0 comments on commit 0c57f77

Please sign in to comment.