I'm creating a library called rest
which links another library oatpp
which is an actual webserver. The respective CMakeLists looks somewhat like this
file(GLOB_RECURSE SRCS
src/*.h
src/*.cpp
include/*.h)
find_package(oatpp)
add_definitions(-DOATPP_SWAGGER_RES_PATH="${OATPP_BASE_DIR}/bin/oatpp-swagger/res")
add_library(fid-rest ${SRCS})
target_link_libraries(fid-rest PUBLIC oatpp)
set_target_properties(fid-rest PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(fid-rest PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${oatpp_INCLUDE_DIRS})
Creating this library works. However I now want to create an executable rest-api
which uses this library. For this I have another CMakeLists which creates this executable like this:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
add_executable(rest-api rest-api.cpp)
target_link_libraries(rest-api fid-rest)
Unfortuntely this doesn't work now as make yields
/usr/bin/ld: cannot find -loatpp
Questions for me now is: Why is this? I would have thought that the dependency oatpp
is copied into my rest
lib and further on linking this to rest-api
would also copy oatpp
there. How could I get this done?
Full code is available here https://github.com/plazmakeks/fid
SOLVED:
you need to link the libraries link this
target_link_libraries(fid-rest PUBLIC oatpp::oatpp)