Skip to content

Commit

Permalink
Refactor FindHistory.cmake
Browse files Browse the repository at this point in the history
* use all lower case keywords for consistency
* add target for libhistory: History::History
  • Loading branch information
bencsikandrei authored and Pentarctagon committed Apr 29, 2022
1 parent 195cc4c commit 5796ae5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
36 changes: 31 additions & 5 deletions cmake/FindHistory.cmake
@@ -1,11 +1,37 @@
# Locale GNU history library
#[=======================================================================[.rst:
FindHistory
-----------

find_path(HISTORY_INCLUDE_DIR readline/history.h)
Find the GNU History includes and library.

IMPORTED Targets
^^^^^^^^^^^^^^^^

This module defines the `IMPORTED` target ``History::History``, if
History has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

HISTORY_FOUND - True if history found.
HISTORY_INCLUDE_DIR - Where to find readline/history.h.
HISTORY_LIBRARY - Library when using history.

#]=======================================================================]

find_path(HISTORY_INCLUDE_DIR readline/history.h)
find_library(HISTORY_LIBRARY history)

# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(History DEFAULT_MSG HISTORY_LIBRARY HISTORY_INCLUDE_DIR)
# handle the QUIETLY and REQUIRED arguments and set HISTORY_FOUND to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(History DEFAULT_MSG HISTORY_LIBRARY HISTORY_INCLUDE_DIR)

mark_as_advanced(HISTORY_INCLUDE_DIR HISTORY_LIBRARY)

if(HISTORY_FOUND AND (NOT TARGET History::History))
add_library(History::History UNKNOWN IMPORTED)
set_target_properties(History::History PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${HISTORY_INCLUDE_DIR}")
set_target_properties(History::History PROPERTIES IMPORTED_LOCATION "${HISTORY_LIBRARY}")
endif()
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -67,7 +67,7 @@ if(NOT MSVC)
endif()

if(HISTORY_FOUND)
set(game-external-libs ${game-external-libs} ${HISTORY_LIBRARY})
set(game-external-libs ${game-external-libs} History::History)
endif()

# get source lists
Expand Down

0 comments on commit 5796ae5

Please sign in to comment.