find_package(PkgConfig REQUIRED)

# uwsgi.h required if #ifdef UWSGI_UUID
pkg_check_modules(UUID REQUIRED uuid)

find_package(CAP REQUIRED)

set(uswgi_engine_SRC
    bodyuwsgi.cpp
    engineuwsgi.cpp
    plugin.cpp
)

execute_process(COMMAND ${UWSGI_EXEC_PATH} --dot-h
                OUTPUT_FILE uwsgi.h)

execute_process(COMMAND ${UWSGI_EXEC_PATH} --cflags
                OUTPUT_VARIABLE UWSGI_CFLAGS
                OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions(${UWSGI_CFLAGS})

add_library(cutelyst SHARED ${uswgi_engine_SRC})
target_link_libraries(cutelyst
    PRIVATE CutelystQt5::Core
    PRIVATE Qt5::Core
    PRIVATE Qt5::Network
)

if (LINUX)
target_link_libraries(cutelyst
    PRIVATE CutelystQt5::EventLoopEPoll
)
endif (LINUX)

SET_TARGET_PROPERTIES(cutelyst
    PROPERTIES
    SUFFIX "_plugin.so"
    PREFIX ""
)

install(TARGETS cutelyst
    DESTINATION ${UWSGI_PLUGINS_DIR}
)

find_package(PkgConfig QUIET)

if (NOT PkgConfig_FOUND)
    message(WARNING "pkg-config not found, not building uWSGI plugin")
    return()
endif ()

# uwsgi.h required if #ifdef UWSGI_UUID
pkg_check_modules(UUID REQUIRED uuid)

find_package(CAP REQUIRED)

set(uswgi_engine_SRC
    bodyuwsgi.cpp
    engineuwsgi.cpp
    plugin.cpp
)

execute_process(COMMAND ${UWSGI_EXEC_PATH} --dot-h
                OUTPUT_FILE uwsgi.h)

execute_process(COMMAND ${UWSGI_EXEC_PATH} --cflags
                OUTPUT_VARIABLE UWSGI_CFLAGS
                OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions(${UWSGI_CFLAGS})

add_library(cutelyst SHARED ${uswgi_engine_SRC})
target_link_libraries(cutelyst
    PRIVATE CutelystQt5::Core
    PRIVATE Qt5::Core
    PRIVATE Qt5::Network
)

if (LINUX)
target_link_libraries(cutelyst
    PRIVATE CutelystQt5::EventLoopEPoll
)
endif (LINUX)

SET_TARGET_PROPERTIES(cutelyst
    PROPERTIES
    SUFFIX "_plugin.so"
    PREFIX ""
)

install(TARGETS cutelyst
    DESTINATION ${UWSGI_PLUGINS_DIR}
)

Allow to build Cutelyst if uwsgi is available but pkg-config isn't
uwsgi: Allow to build Cutelyst if uwsgi is available but pkg-config isn't
