add cmake support for iniparser package

This commit is contained in:
Enno Rehling 2021-02-13 14:36:45 +01:00 committed by Enno Rehling
parent d850b28d85
commit fb3047beb5
3 changed files with 67 additions and 3 deletions

View File

@ -40,8 +40,8 @@ find_package (Curses)
endif (NOT CURSES_FOUND) endif (NOT CURSES_FOUND)
find_package (SQLite3 REQUIRED) find_package (SQLite3 REQUIRED)
find_package (IniParser REQUIRED)
find_package(EXPAT REQUIRED) find_package (EXPAT REQUIRED)
find_package (ToLua REQUIRED) find_package (ToLua REQUIRED)
if (TOLUA_FOUND) if (TOLUA_FOUND)
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2") if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
@ -55,7 +55,6 @@ enable_testing()
add_subdirectory (cJSON) add_subdirectory (cJSON)
add_subdirectory (storage) add_subdirectory (storage)
add_subdirectory (iniparser)
add_subdirectory (clibs) add_subdirectory (clibs)
add_subdirectory (process) add_subdirectory (process)
add_subdirectory (src eressea) add_subdirectory (src eressea)

View File

@ -0,0 +1,59 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindIniParser
-----------
.. versionadded:: 3.20
Find the IniParser libraries, v3
IMPORTED targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target:
``Devillard::IniParser``
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables if found:
``IniParser_INCLUDE_DIRS``
where to find sqlite3.h, etc.
``IniParser_LIBRARIES``
the libraries to link against to use IniParser.
``IniParser_VERSION``
version of the IniParser library found
``IniParser_FOUND``
TRUE if found
#]=======================================================================]
# Look for the necessary header
find_path(IniParser_INCLUDE_DIR iniparser.h)
mark_as_advanced(IniParser_INCLUDE_DIR)
# Look for the necessary library
find_library(IniParser_LIBRARY iniparser)
mark_as_advanced(IniParser_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IniParser
REQUIRED_VARS IniParser_INCLUDE_DIR IniParser_LIBRARY
VERSION_VAR IniParser_VERSION)
# Create the imported target
if(IniParser_FOUND)
set(IniParser_INCLUDE_DIRS ${IniParser_INCLUDE_DIR})
set(IniParser_LIBRARIES ${IniParser_LIBRARY})
if(NOT TARGET Devillard::IniParser)
add_library(Devillard::IniParser UNKNOWN IMPORTED)
set_target_properties(Devillard::IniParser PROPERTIES
IMPORTED_LOCATION "${IniParser_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${IniParser_INCLUDE_DIR}")
endif()
endif()

View File

@ -301,6 +301,12 @@ if (HAVE_LIBBSD)
target_link_libraries(parser bsd) target_link_libraries(parser bsd)
endif (HAVE_LIBBSD) endif (HAVE_LIBBSD)
if (IniParser_FOUND)
target_include_directories(game PUBLIC ${IniParser_INCLUDE_DIRS})
target_link_libraries(eressea ${IniParser_LIBRARIES})
target_link_libraries(test_eressea ${IniParser_LIBRARIES})
endif (IniParser_FOUND)
if (SQLite3_FOUND) if (SQLite3_FOUND)
target_include_directories (game PRIVATE ${SQLite3_INCLUDE_DIRS}) target_include_directories (game PRIVATE ${SQLite3_INCLUDE_DIRS})
target_link_libraries(eressea ${SQLite3_LIBRARIES}) target_link_libraries(eressea ${SQLite3_LIBRARIES})