I give up, can't sort this out for several days. I am building shared .so library (dayaswig ) on ubuntu, and want to include other external shared library (dayagame). CMakeLists.txt code is as follows:
cmake_minimum_required(VERSION 3.10.2)
project (dayaswig LANGUAGES CXX VERSION 0.1)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -pg -fsanitize=undefined")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
endif ()
set(CMAKE_BUILD_TYPE RELEASE)
set(BASE_DIR ./)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(dayagame REQUIRED)
get_filename_component(HEADERS src REALPATH)
include_directories(${HEADERS} ${DAYAGAME_INCLUDE_DIRS})
set(SOURCE_FILES helloworld.hpp helloworld.cpp helloworld_wrap.cxx)
add_library(dayaswig SHARED ${SOURCE_FILES})
add_library(dayagame SHARED IMPORTED)
target_include_directories (dayaswig PUBLIC ${BASE_DIR})
target_link_libraries(dayaswig LINK_PUBLIC ${DAYAGAME_LIBRARY})
install(TARGETS dayaswig DESTINATION /usr/lib)
and find module code is
find_path(DAYAGAME_INCLUDE_DIR dayaserver.hpp PATHS "/usr/local/include/dayagame/")
find_library(DAYAGAME_LIBRARY dayagame PATHS "/usr/local/lib")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DAYAGAME DEFAULT_MSG DAYAGAME_LIBRARY DAYAGAME_INCLUDE_DIR)
All builds fine, except that dayagame library is never linked with dayaswig. Any help is really appreciated.
If I print all variables, I can see, that they are resolved just fine:
-- DAYAGAME_FOUND=TRUE
-- DAYAGAME_INCLUDE_DIR=/usr/local/include/dayagame
-- DAYAGAME_LIBRARY=/usr/local/lib/libdayagame.so