48 lines
2.0 KiB
CMake
48 lines
2.0 KiB
CMake
find_package(Gint 2.1 REQUIRED)
|
|
|
|
# Ask the fxSDK to find a library called libexample.a, and find its version in
|
|
# the macro EX_VERSION of the header file <example/config.h>.
|
|
#
|
|
# Store the path to libexample.a in EX_PATH and store the version number in
|
|
# EX_VERSION.
|
|
include(FindSimpleLibrary)
|
|
find_simple_library(libexample.a example/config.h "EX_VERSION"
|
|
PATH_VAR EX_PATH
|
|
VERSION_VAR EX_VERSION)
|
|
|
|
# The fxSDK looks for libexample.a in ${FXSDK_LIB}, then <example/config.h> in
|
|
# ${FXSDK_INCLUDE}, and extracts the version number from a macro like
|
|
#
|
|
# #define EX_VERSION "..."
|
|
#
|
|
# See the source code for the FindSimpleLibrary module for more detail.
|
|
|
|
# We then use a CMake function to finish searching the library. We specify:
|
|
# * REQUIRED_VARS ... which requires the variables to be non-empty, otherwise
|
|
# find_library() says the library was not found.
|
|
# * VERSION_VAR ... which provides the version number, so that find_library()
|
|
# can compare with the version requested by the user (if any) and fail if
|
|
# the version we found isn't compatible.
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(LibExample
|
|
REQUIRED_VARS EX_PATH EX_VERSION
|
|
VERSION_VAR EX_VERSION)
|
|
|
|
# We now have a LibExample_FOUND variable indicating if everything went well.
|
|
# If so we can now create an *imported target* that is not built in the project
|
|
# but can still be linked against with target_link_libraries().
|
|
if(LibExample_FOUND)
|
|
# This is an imported target, we don't build it, we just claim it's here.
|
|
add_library(LibExample::LibExample UNKNOWN IMPORTED)
|
|
# Here we declare the compiler and linker flags that every user of LibExample
|
|
# needs to use.
|
|
set_target_properties(LibExample::LibExample PROPERTIES
|
|
# If we specify where the library comes from, CMake will watch that file
|
|
# and relink any user application when the library is updated!
|
|
IMPORTED_LOCATION "${EX_PATH}"
|
|
# Linking options
|
|
INTERFACE_LINK_OPTIONS -lexample
|
|
# Dependencies (for order on the command-line)
|
|
INTERFACE_LINK_LIBRARIES Gint::Gint)
|
|
endif()
|