include(ProcessorCount)
ProcessorCount(N)
if(N EQUAL 0)
  set(PARALLEL_LEVEL "")
else()
  set(PARALLEL_LEVEL "-j${N}")
endif()

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release")
endif()

if(Qt5_VERSION)
  set(QT_VERSION ${Qt5_VERSION})
else()
  set(QT_VERSION ${Qt6_VERSION})
endif()

message(STATUS " ")
message(STATUS "Versions:")
message(STATUS "  NetTcp            : ${NETTCP_VERSION} ${NETTCP_TAG}")
message(STATUS "  QOlm              : ${QOLM_VERSION} ${QOLM_TAG}")
message(STATUS "  Qt                : ${QT_VERSION}")

message(STATUS " ")
message(STATUS "Targets:")
message(STATUS "  NetTcp            : cmake --build . --target ${NETTCP_TARGET} --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")

if(NETTCP_ENABLE_EXAMPLES)
message(STATUS " ")
message(STATUS "Examples:")
message(STATUS "  EchoClient        : cmake --build . --target NetTcp_EchoClient --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS "  EchoServer        : cmake --build . --target NetTcp_EchoServer --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS "  EchoClientServer  : cmake --build . --target NetTcp_EchoClientServer --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS "  FuzzDisconnectionClientServer : cmake --build . --target NetTcp_FuzzDisconnectionClientServer --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS "  FuzzDisconnectionServerClient : cmake --build . --target NetTcp_FuzzDisconnectionServerClient --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
endif()

if(TARGET "${NETTCP_TARGET}Tests")
message(STATUS " ")
message(STATUS "Tests:")
message(STATUS "  NetTcpTests   : cmake --build . --target ${NETTCP_TARGET}Tests --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS "  Run Tests     : ctest -C ${CMAKE_BUILD_TYPE} . --verbose --progress")
endif()
