CMakeLists.txt 2.79 KB
cmake_minimum_required(VERSION 3.12)
# ==============================================================================
# Check to see if we're a submodule or top-repo.
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
    message( STATUS "Looks like we're a single module" )
    LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
    message( STATUS "Looks like we're a submodule" )
    LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
else()
    message( FATAL_ERROR "No cmake directory found. Did you run the submodules script?" )
endif()

# ==============================================================================
# Check to see if there is versioning information available
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../versioning)
    LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../versioning/cmake)
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../versioning)
    LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../versioning/cmake)
else()
    message( FATAL_ERROR "No ${CURRENT_SOURCE_DIR}/osdev_versioning directory found. Did you run the submodules script?" )
endif()
# ==============================================================================
include(projectheader)

project_header(mqtt-cpp)

find_package( Boost REQUIRED COMPONENTS regex )

include(compiler)

include_directories(
    ${CMAKE_SOURCE_DIR}/include
)

set(SRC_LIST
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttpublisherbase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttsubscriberbase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/clientpaho.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commondefs.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/connectionstatus.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/credentials.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/errorcode.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/token.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/ihistogram.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/timemeasurement.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttidgenerator.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqtttypeconverter.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttutil.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttmessage.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttclient.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttfailure.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mqttsuccess.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imqttclientimpl.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/istatecallback.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/scopeguard.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/serverstate.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/sharedreaderlock.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/stringutils.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/uriparser.cpp
)

include(library)
add_libraries(
    PUBLIC
        Boost::boost
        Boost::regex
        paho-mqtt3a
)

include(installation)
install_component()