Skip to content

Commit

Permalink
Create Espeak IMPORTED target
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Aug 16, 2024
1 parent 0dc549d commit 583011a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
43 changes: 26 additions & 17 deletions cmake/find-modules/FindEspeak.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# - Try to find ESPEAK
# Once done this will define
# ESPEAK_FOUND - System has ESPEAK
# ESPEAK_INCLUDE_DIRS - The ESPEAK include directories
# ESPEAK_LIBRARIES - The libraries needed to use ESPEAK
# Find the Espeak libraries and headers.
#
# Sets the following variables:
#
# ESPEAK_FOUND - system has Espeak
# ESPEAK_INCLUDE_DIRS - Espeak include directories
# ESPEAK_LIBRARIES - Espeak libraries
#
# ...and the following imported targets (requires CMake 2.8.11+):
#
# Espeak::Espeak - Espeak library (old API)

#set(ESPEAK_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})

find_path(ESPEAK_INCLUDE_DIR speak_lib.h
$ENV{ESPEAK_DIR}
$ENV{FFMPEG_DIR}/espeak
/usr/local/include/espeak
/usr/include/espeak
)
find_path(ESPEAK_INCLUDE_DIR NAMES speak_lib.h
HINTS ENV ESPEAK_DIR
PATH_SUFFIXES espeak)

find_library(ESPEAK_LIBRARY NAMES espeak libespeak)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Espeak DEFAULT_MSG ESPEAK_INCLUDE_DIR ESPEAK_LIBRARY)

mark_as_advanced(ESPEAK_INCLUDE_DIR ESPEAK_LIBRARY)
if(Espeak_FOUND)
set(ESPEAK_INCLUDE_DIRS ${ESPEAK_INCLUDE_DIR})
set(ESPEAK_LIBRARIES ${ESPEAK_LIBRARY})

set(ESPEAK_INCLUDE_DIRS ${ESPEAK_INCLUDE_DIR})
set(ESPEAK_LIBRARIES ${ESPEAK_LIBRARY})
if(NOT TARGET Espeak::Espeak)
add_library(Espeak::Espeak UNKNOWN IMPORTED)

set_target_properties(Espeak::Espeak PROPERTIES IMPORTED_LOCATION "${ESPEAK_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ESPEAK_INCLUDE_DIR}")
endif()
endif()

mark_as_advanced(ESPEAK_INCLUDE_DIR ESPEAK_LIBRARY)
5 changes: 2 additions & 3 deletions libraries/Espeak/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ if(ENABLE_Espeak)

target_link_libraries(Espeak PUBLIC ROBOTICSLAB::SpeechIDL
PRIVATE YARP::YARP_os
${ESPEAK_LIBRARIES})
Espeak::Espeak)

target_include_directories(Espeak PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${ESPEAK_INCLUDE_DIRS})
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

install(TARGETS Espeak
EXPORT ROBOTICSLAB_SPEECH)
Expand Down

0 comments on commit 583011a

Please sign in to comment.