Hi
I’m trying to create a Find module for an SDK we’re using. What I currently have is this (can’t upload a file as new forum member):
find_package(PkgConfig)
pkg_check_modules(PC_Cerence QUIET Cerence)
find_path(Cerence_INCLUDE_DIR
NAMES nds_common/ISystemManager.h
PATHS ${CMAKE_SOURCE_DIR}/lib/csdk/inc
)
message("Cerence_INCLUDE_DIR = ${Cerence_INCLUDE_DIR}")
set( Cerence_LibDir_Suggestion ${CMAKE_SOURCE_DIR}/lib/csdk/lib)
message( "Cerence_LibDir_Suggestion = ${Cerence_LibDir_Suggestion}")
find_library(Cerence_dd_common_LIBRARY
NAMES dd_common
PATHS ${Cerence_LibDir_Suggestion}
)
message("Cerence_dd_common_LIBRARY = ${Cerence_dd_common_LIBRARY}")
find_library(Cerence_dd_common_c_LIBRARY
NAMES dd_common_c
PATHS ${Cerence_LibDir_Suggestion}
)
message("Cerence_dd_common_c_LIBRARY = ${Cerence_dd_common_c_LIBRARY}")
set(Cerence_VERSION ${PC_Cerence_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cerence
FOUND_VAR Cerence_FOUND
REQUIRED_VARS
Cerence_dd_common_LIBRARY
Cerence_dd_common_c_LIBRARY
Cerence_INCLUDE_DIR
VERSION_VAR Cerence_VERSION
)
if(Cerence_FOUND)
set(Cerence_LIBRARIES
${Cerence_dd_common_LIBRARY}
${Cerence_dd_common_c_LIBRARY}
${Cerence_LibDir_Suggestion}/libnds_audio.so
${Cerence_LibDir_Suggestion}/libnds_audio_c.so
${Cerence_LibDir_Suggestion}/libnds_audio_io_simulator.so
${Cerence_LibDir_Suggestion}/libnds_audio_io_simulator_c.so
${Cerence_LibDir_Suggestion}/libnds_audio_io_simulator_c.so
${Cerence_LibDir_Suggestion}/libnds_audio_module_output.so
${Cerence_LibDir_Suggestion}/libnds_audio_module_output_c.so
${Cerence_LibDir_Suggestion}/libnds_audio_module_from_file.so
${Cerence_LibDir_Suggestion}/libnds_audio_module_from_file_c.so
#nds_cloudservices
#nds_cloudservices_c
${Cerence_LibDir_Suggestion}/libnds_prompter.so
${Cerence_LibDir_Suggestion}/libnds_prompter_c.so
${Cerence_LibDir_Suggestion}/libpal_core.so
${Cerence_LibDir_Suggestion}/libve.so
#vocon_curl
)
set(Cerence_INCLUDE_DIRS ${Cerence_INCLUDE_DIR}/nds_prompter
${Cerence_INCLUDE_DIR}/nds_audio
${Cerence_INCLUDE_DIR}/nds_audio_module_output
${Cerence_INCLUDE_DIR}/nds_audio_io_simulator
${Cerence_INCLUDE_DIR}/nds_common
${Cerence_INCLUDE_DIR}/nds_cloudservices
${Cerence_INCLUDE_DIR}/pal )
set(Cerence_DEFINITIONS ${PC_Cerence_CFLAGS_OTHER})
endif()
if(Cerence_FOUND AND NOT TARGET Cerence::Cerence)
add_library(Cerence::Cerence SHARED IMPORTED GLOBAL)
target_link_directories(Cerence::Cerence INTERFACE ${Cerence_LibDir_Suggestion})
target_link_libraries(Cerence::Cerence INTERFACE "${Cerence_LIBRARIES}")
set_target_properties(Cerence::Cerence PROPERTIES
IMPORTED_LOCATION ${Cerence_dd_common_LIBRARY}
IMPORTED_LOCATION ${Cerence_dd_common_c_LIBRARY}
INTERFACE_COMPILE_OPTIONS "${PC_Cerence_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Cerence_INCLUDE_DIRS}"
)
install( DIRECTORY ${Cerence_LibDir_Suggestion}/ DESTINATION lib
FILES_MATCHING PATTERN "*.so"
)
endif()
mark_as_advanced(
Cerence_INCLUDE_DIR
Cerence_LIBRARY
)
The project that uses this Find module compiles and links perfectly, but for some reason, one so-file is linked using the full path, while other so’s are linked with only the filename. When I run the executable, only the library with full path is loaded. Why is this happening, and what can I do to make them all link using a full path? Please note, what I have now is puzzled together from various sources online and I do not have a very deep understanding of CMake yet. Still reading up on the subject…
Thanks in advance for any help!
Merijn