Commit 49142116 authored by Adriaan de Groot's avatar Adriaan de Groot

CMake: massage the FindfreeDiameter logic

 - munge include paths only if they were found (although the
   munge doesn't apply if the string value is NOTFOUND)
 - don't *always* set version to UNKNOWN before trying to
   find it, because it obscures when freeDiameter isn't found
   at all: you get a "unsuitable version UNKNOWN" error rather
   than a "library not found" error

This is a bit of spinning wheels for when freeDiameter comes
with a proper (CMake) config instead.
parent aafa39ec
Pipeline #217481973 passed with stage
in 5 minutes and 2 seconds
......@@ -19,8 +19,21 @@
# The module also provides a rule to define a new extension,
# - add_freeDiameter_extension (EXTNAME [EXCLUDE_FROM_ALL] SOURCE...)
#
# Extensions install into ${freeDiameter_EXTENSION_DIR} for boh their
# LIBRARY and RUNTIME DESTINATION.
# This macro adds a new (shared) library for use as a freeDiameter plugin,
# but freeDiameter plugin-library naming is non-standard: there is no "lib"
# prefix, and they use the extension ".fdx" instead of ".so"
#
# Extensions install into ${freeDiameter_EXTENSION_DIR} for both their
# LIBRARY and RUNTIME DESTINATION, so the target (EXTNAME) should
# have a custom install command as well:
#
# ```
# install (...
# LIBRARY DESTINATION ${freeDiameter_EXTENSION_DIR}
# RUNTIME DESTINATION ${freeDiameter_EXTENSION_DIR}
# )
# ```
#
#
# From: Rick van Rein <rick@openfortress.nl>
......@@ -34,7 +47,6 @@ find_path (freeDiameter_EXTENSION_DIR
dict_nasreq.fdx
PATH_SUFFIXES lib/freeDiameter
)
find_path (freeDiameter_INCLUDE_DIR
libfdcore.h
PATHS ${CMAKE_INCLUDE_PATH} ${CMAKE_SYSTEM_INCLUDE_PATH}
......@@ -42,19 +54,23 @@ find_path (freeDiameter_INCLUDE_DIR
PATH_SUFFIXES freeDiameter
)
string (REGEX REPLACE "[/\\]freeDiameter$" ""
freeDiameter_INCLUDE_DIR
"${freeDiameter_INCLUDE_DIR}")
find_program (freeDiameter_EXECUTABLE
freeDiameterd)
set (freeDiameter_VERSION "UNKNOWN")
# Munge the path if it is found
if (freeDiameter_INCLUDE_DIR)
string (REGEX REPLACE "[/\\]freeDiameter$" ""
freeDiameter_INCLUDE_DIR
"${freeDiameter_INCLUDE_DIR}")
endif ()
if (freeDiameter_EXECUTABLE)
execute_process (COMMAND ${freeDiameter_EXECUTABLE} --version
OUTPUT_VARIABLE freeDiameter_VERSION_OUTPUT)
if ("${freeDiameter_VERSION_OUTPUT}" MATCHES "^.*version *([^ \n]+)")
set (freeDiameter_VERSION "${CMAKE_MATCH_1}")
else ()
set (freeDiameter_VERSION "UNKNOWN")
endif ()
endif ()
......@@ -85,17 +101,6 @@ if (freeDiameter_FOUND)
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${freeDiameter_INCLUDE_DIR}")
endif ()
# add_freeDiameter_extension (EXTNAME [EXCLUDE_FROM_ALL] SOURCE...)
#
# Library naming is non-standard: no "libX" and extension ".fdx" instead of ".so"
#
# Extensions install into ${freeDiameter_EXTENSION_DIR} for boh their
# LIBRARY and RUNTIME DESTINATION:
# install (...
# LIBRARY DESTINATION ${freeDiameter_EXTENSION_DIR}
# RUNTIME DESTINATION ${freeDiameter_EXTENSION_DIR}
# )
#
macro (add_freeDiameter_extension EXTNAME)
add_library ("${EXTNAME}" MODULE ${ARGN})
set_target_properties ("${EXTNAME}" PROPERTIES PREFIX "" )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment