Skip to content

Instantly share code, notes, and snippets.

@TrinityCoder
Last active April 23, 2019 10:27
Show Gist options
  • Save TrinityCoder/76285eb2fcd4cc20a63f3448af788aab to your computer and use it in GitHub Desktop.
Save TrinityCoder/76285eb2fcd4cc20a63f3448af788aab to your computer and use it in GitHub Desktop.
This CMake module finds the ThorsSerializer library (JSON & YAML C++ parser) - both include directory and .so file.
# ------------------------------------------------------------------------
# If target ThorsSerializer::ThorsSerializer does not exist, create it.
# We'll need to find two variables to do it:
#
# 1) ThorsSerializer_INCLUDE_DIR (i. e. /usr/local/include/ThorSerialize)
# 2) ThorsSerializer_LIBRARY (i. e. /usr/local/lib/libThorSerialize17.so)
# ------------------------------------------------------------------------
find_path(ThorsSerializer_INCLUDE_DIR
NAMES JsonThor.h YamlThor.h
PATH_SUFFIXES ThorSerialize)
find_library(ThorsSerializer_LIBRARY
NAMES ThorSerialize17
PATH_SUFFIXES ThorSerialize)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ThorsSerializer
FOUND_VAR
ThorsSerializer_FOUND
REQUIRED_VARS
ThorsSerializer_LIBRARY
ThorsSerializer_INCLUDE_DIR)
if(ThorsSerializer_FOUND)
set(ThorsSerializer_LIBRARIES "${ThorsSerializer_LIBRARY}")
set(ThorsSerializer_INCLUDE_DIRS "${ThorsSerializer_INCLUDE_DIR}")
if (NOT TARGET ThorsSerializer::ThorsSerializer)
add_library(ThorsSerializer::ThorsSerializer UNKNOWN IMPORTED)
set_target_properties(ThorsSerializer::ThorsSerializer
PROPERTIES
IMPORTED_LOCATION "${ThorsSerializer_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ThorsSerializer_INCLUDE_DIR}")
endif()
endif()
mark_as_advanced(
ThorsSerializer_INCLUDE_DIR
ThorsSerializer_LIBRARY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment