diff --git a/CMakeLists.txt b/CMakeLists.txt index c1100e551..b9c5c7818 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,8 @@ find_package (Curses) endif (NOT CURSES_FOUND) find_package (SQLite3 REQUIRED) - -find_package(EXPAT REQUIRED) +find_package (IniParser REQUIRED) +find_package (EXPAT REQUIRED) find_package (ToLua REQUIRED) if (TOLUA_FOUND) if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2") @@ -55,7 +55,6 @@ enable_testing() add_subdirectory (cJSON) add_subdirectory (storage) -add_subdirectory (iniparser) add_subdirectory (clibs) add_subdirectory (process) add_subdirectory (src eressea) diff --git a/cmake/Modules/FindIniParser.cmake b/cmake/Modules/FindIniParser.cmake new file mode 100644 index 000000000..0f976429d --- /dev/null +++ b/cmake/Modules/FindIniParser.cmake @@ -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() + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b9273c11f..3ec49bf09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -301,6 +301,12 @@ if (HAVE_LIBBSD) target_link_libraries(parser bsd) 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) target_include_directories (game PRIVATE ${SQLite3_INCLUDE_DIRS}) target_link_libraries(eressea ${SQLite3_LIBRARIES})