Commit d0f0d0ec authored by Georg Vinogradov's avatar Georg Vinogradov

Add generation of FindMQTT.cmake

parent 89b91f30
Pipeline #165544 passed with stages
in 1 minute and 29 seconds
......@@ -57,6 +57,7 @@ public class GeneratorMqtt
}
files.add(generateCMake(component));
files.add(generateFindMqtt(component));
return files;
}
......@@ -87,6 +88,35 @@ public class GeneratorMqtt
}
}
return file;
}
File generateFindMqtt(EMAComponentInstanceSymbol component)
{
// Create and fill model
MqttAdapterModel model = new MqttAdapterModel(component.getFullName());
//Generate files and write to project
String content = MqttTemplates.generateMqttFindMqtt(model);
File file = new File("./target/generated-sources/FindMQTT.cmake");
FileWriter fr = null;
try {
fr = new FileWriter(file);
fr.write(content);
} catch (IOException e) {
e.printStackTrace();
}finally{
//Close resources
try {
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return file;
}
......
......@@ -16,6 +16,7 @@ public class MqttTemplates {
private static final Template MQTT_PRETTYPRINT;
private static final Template MQTT_CMAKELISTS;
private static final Template MQTT_FINDMQTT;
private static final Template MQTT_ADAPTER_H;
private static final Template MQTT_ADAPTER_CPP;
private static final Template MQTT_CALLBACK_H;
......@@ -31,6 +32,7 @@ public class MqttTemplates {
try {
MQTT_PRETTYPRINT = conf.getTemplate("PrettyPrint.ftl");
MQTT_CMAKELISTS = conf.getTemplate("CMakeLists.ftl");
MQTT_FINDMQTT = conf.getTemplate("FindMqtt.ftl");
MQTT_ADAPTER_H = conf.getTemplate("Adapter.h.ftl");
MQTT_ADAPTER_CPP = conf.getTemplate("Adapter.cpp.ftl");
MQTT_CALLBACK_H = conf.getTemplate("Callback.hpp.ftl");
......@@ -72,6 +74,12 @@ public class MqttTemplates {
return generate(MQTT_CMAKELISTS, data);
}
public static String generateMqttFindMqtt(MqttAdapterModel model) {
HashMap<String, Object> data = new HashMap<>();
data.put("model", model);
return generate(MQTT_FINDMQTT, data);
}
public static String generatePrettyPrint(MqttAdapterModel model) {
HashMap<String, Object> data = new HashMap<>();
data.put("model", model);
......
......@@ -34,6 +34,9 @@ MqttAdapter_${model.getEscapedCompName()}.h
${model.getEscapedCompName()}.h
)
list(APPEND LIBRARIES ${model.getCompName()})
list(APPEND LIBRARIES IAdapter_${model.getCompName()})
# Checking if everything was found
if(SEARCH_MQTT)
if (NOT MQTT_C_LIB OR NOT MQTT_A_LIB OR NOT MQTT_PP_LIB)
......
<#--@formatter:off-->
# Created by Georg Vinogradov on 28.05.19
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 <#noparse>${MQTT_A_LIB} ${MQTT_C_LIB} ${MQTT_PP_LIB}</#noparse>)
endif()
......@@ -33,6 +33,9 @@ MqttAdapter_tests_a_compA.h
tests_a_compA.h
)
list(APPEND LIBRARIES tests.a.compA)
list(APPEND LIBRARIES IAdapter_tests.a.compA)
# Checking if everything was found
if(SEARCH_MQTT)
if (NOT MQTT_C_LIB OR NOT MQTT_A_LIB OR NOT MQTT_PP_LIB)
......
# Created by Georg Vinogradov on 28.05.19
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()
......@@ -33,6 +33,9 @@ MqttAdapter_tests_a_compA.h
tests_a_compA.h
)
list(APPEND LIBRARIES tests.a.compA)
list(APPEND LIBRARIES IAdapter_tests.a.compA)
# Checking if everything was found
if(SEARCH_MQTT)
if (NOT MQTT_C_LIB OR NOT MQTT_A_LIB OR NOT MQTT_PP_LIB)
......
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