oatpp / oatpp-swagger

OpenApi 3.0.0 docs + Swagger UI for oatpp services
https://oatpp.io/
Apache License 2.0
90 stars 51 forks source link

Problem with cmake FetchContent_* both oatpp-swagger and oatpp #87

Open zhongwm opened 7 months ago

zhongwm commented 7 months ago

Problem with cmake FetchContent_* both oatpp-swagger and oatpp.

If I use FetchContent_* to install oatpp solely, it works. Then if I add another FetchContent for oatpp-swagger, it fails.

include(FetchContent)
FetchContent_Declare(
    oatpp-swagger
    GIT_REPOSITORY https://github.com/oatpp/oatpp-swagger
    GIT_TAG 1.3.0
    OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(
    oatpp-swagger
)

message(STATUS "oatpp-swagger_DIR ${oatpp-swagger_DIR}")
find_package(oatpp-swagger 1.3.0 REQUIRED)

The one for importing oatpp:

include(FetchContent)
FetchContent_Declare(
    oatpp
    GIT_REPOSITORY https://github.com/oatpp/oatpp
    GIT_TAG 1.3.0
    OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(
    oatpp
)

message(STATUS "oatpp_DIR ${oatpp_DIR}")
find_package(oatpp 1.3.0 REQUIRED)

The line I use oatpp is target_link_libraries(myproject oatpp) (this line works), but fail if changed to target_link_libraries(myproject oatpp oatpp-swagger) , and the cause is when configuring the oatpp-swagger.

Error while configuring:

[cmake] Finding oatpp in location=INSTALLED
[cmake] CMake Error at build/_deps/oatpp-swagger-src/CMakeLists.txt:42 (get_target_property):
[cmake]   get_target_property() called with non-existent target "oatpp::oatpp".
[cmake]