Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 0131a345 authored by Mike Grüne's avatar Mike Grüne
Browse files

Add MqttCMakeModel and Edit CMakeLists

parent 5e36b182
Pipeline #158083 passed with stages
in 2 minutes and 23 seconds
package de.monticore.lang.monticar.generator.mqtt.template;
public class MqttCMakeModel {
private String name;
public String getName() {
return name;
}
}
#Setting cmake version
# Setting cmake version
cmake_minimum_required(VERSION 3.1...3.14)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
#Using C++ version 11 with threads for compiling
# Using C++ version 11 with threads for compiling
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
# Find Pthread package
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
#Setting Project name
project (${model.name})
#Find MQTT packages
message("Searching for installed MQTT on your system...")
# Searching for include directory
if (NOT MQTT_INCLUDE_DIR)
find_path(MQTT_INCLUDE_DIR MQTTAsync.h HINTS "/usr/include/" "/usr/local/include/")
endif()
# Searching for libraries (without SSL support)
if (NOT MQTT_LIBS)
find_library(
MQTT_C_LIB
NAMES paho-mqtt3c)
find_library(
MQTT_A_LIB
NAMES paho-mqtt3a)
find_library(
MQTT_PP_LIB
NAMES paho-mqttpp3)
set(MQTT_LIBS ${MQTT_A_LIB} ${MQTT_C_LIB} ${MQTT_PP_LIB})
endif()
add_library(${model.name} ${model.name}.cpp)
# Setting project name and description
project(${model.name})
set(SEARCH_MQTT FALSE)
# Check is environment variable was set
IF(DEFINED ENV{MQTT_INCLUDE_DIR} AND DEFINED ENV{MQTT_LIBS})
message("...MQTT environment variables are set" )
ELSE()
message("MQTT environment variables are not defined.")
# Find mqtt packages using modules
find_package(MQTT REQUIRED)
SET(SEARCH_MQTT TRUE)
ENDIF()
# Adding library as a target
add_library(MqttAdapter_tests_a_${model.name}
Callback.cpp
MqttAdapter_tests_a_${model.name}.cpp
tests_a_${model.name}.cpp
Callback.hpp
MqttAdapter_tests_a_${model.name}.h
tests_a_${model.name}.h
)
# Checking if everything was found
if (NOT MQTT_C_LIB OR NOT MQTT_A_LIB OR NOT MQTT_PP_LIB)
message(FATAL_ERROR "MQTT libraries not found!")
elseif (NOT MQTT_INCLUDE_DIR)
message(FATAL_ERROR "MQTT includes not found!")
else()
message("MQTT includes found in "${MQTT_INCLUDE_DIR})
message("MQTT libraries found in "${MQTT_LIBS})
if(SEARCH_MQTT)
if (NOT MQTT_C_LIB OR NOT MQTT_A_LIB OR NOT MQTT_PP_LIB)
message(FATAL_ERROR "MQTT libraries not found!")
elseif (NOT MQTT_INCLUDE_DIR)
message(FATAL_ERROR "MQTT includes not found!")
else()
message("MQTT includes found in " ${MQTT_INCLUDE_DIR})
message("MQTT libraries found in " ${MQTT_LIBS})
endif()
endif()
# Adding include directory to a target
target_include_directories(mqtt_demo PUBLIC ${MQTT_INCLUDE_DIR})
target_include_directories(MqttAdapter_tests_a_${model.name} PUBLIC ${MQTT_INCLUDE_DIR})
# Linking libraries to target
target_link_libraries(mqtt_demo PUBLIC ${MQTT_LIBS})
list(APPEND LIBRARIES ${model.compName})
list(APPEND LIBRARIES IAdapter_${model.compName})
<#list model.getPackages() as lib>
list(APPEND LIBRARIES ${lib}_LIBRARIES})
</#list>
target_link_libraries(${model.name} <#noparse>${LIBRARIES}</#noparse>)
list(APPEND INCLUDE_DIRS <#noparse>${CMAKE_CURRENT_SOURCE_DIR}</#noparse>)
<#list model.getPackages() as incl>
list(APPEND INCLUDE_DIRS ${incl}_INCLUDE_DIRS})
</#list>
target_include_directories(${model.name} PUBLIC <#noparse>${INCLUDE_DIRS}</#noparse>)
target_link_libraries(MqttAdapter_tests_a_${model.name} PUBLIC ${MQTT_LIBS})
export(TARGETS ${model.name} FILE ${model.name}.cmake)
# Export target to a cmake module file for outside usage
export(TARGETS MqttAdapter_tests_a_${model.name} FILE MqttAdapter_tests_a_${model.name}.cmake)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment