How can I add makefile funcionality to my CMakeLists.txt
Hello, I have got two pieces of software. One part is a simulation-software (CarMaker 6.0.4) written in C and I make it with a makefile, whereas I make the other part of the software (ROS kinetic) with a CMakeLists.txt file. I want to take a part of CarMaker-Code and include it in a ROS-node, so I can publish data on this ROS node which I get from the simulation.
The whole thing is running on Linux Ubuntu 16.04 on a Macbook pro.
gcc version: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0
My ROS Node looks like this:
#include <sstream>
#include "ros/ros.h"
#include "std_msgs/String.h"
#ifdef __cplusplus
extern "C"
{
#endif
//Header Einbindung CarMaker
#ifdef _WIN32
# include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifdef _MSC_VER
# define strcasecmp(a, b) _stricmp(a,b)
#endif
#include "/home/roboracemac3/catkin_ws/src/BachelorThesisTest/src/APO/ApoClnt.h"
#include "/home/roboracemac3/catkin_ws/src/BachelorThesisTest/src/APO/GuiCmd.h"
#include "/home/roboracemac3/catkin_ws/src/BachelorThesisTest/src/APODVA.h"
#ifdef __cplusplus
}
#endif
//*********************************** ApoClntDemo.c Code Anfang *******************************************//
static void
error_and_exit (const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
/** Basic APO client infrastructure *******************************************/
/* Connection parameters. */
enum { CmdChannel = 2 }; /* CarMaker command channel. */
enum { ChannelMask = 1<<CmdChannel };
static const char *AppClass = "CarMaker";
static const char *AppHost = "*";
static const char *AppUser = "*";
/* Connection handle to the application (CarMaker in this case). */
static tApoSid Srv;
/* Time to wait between calls to ApoClnt_PollAndSleep().
The duration must be fine-tuned to the actual subscription parameters used.
If too short you may hog the CPU, if too long you may loose quantity data. */
static int SleepDelta_ms = 20;
static int
connection_ok (void)
{
return (ApocGetStatus(Srv, NULL) & ApoConnUp) != 0;
}
/*
* ApoClnt_PollAndSleep()
*
* This function has to be provided by the client application.
* It will be called from within the ApoClnt code whenever the
* application needs to wait for something without blocking the
* rest of the client.
*
* You may adapt the function's code to your needs, provided that
* the basic APO communication structure is kept as is.
*
* Don't assume this function being called with a fixed timing.
*/
void
ApoClnt_PollAndSleep (void)
{
if (ApocWaitIO(SleepDelta_ms) == 1) {
ApocPoll(); /* _Always_ poll, even if connection is down. */
if (connection_ok()) {
unsigned long vecid;
int msglen, msgch;
char msgbuf[APO_ADMMAX];
while ((vecid = ApocGetData(Srv)) > 0) {
if (ApoClnt_UpdateQuantVars(vecid))
return;
/* Put your own quantity data handling code here. */
/* ... */
}
if (ApocDictChanged(Srv))
ApoClnt_Resubscribe(Srv);
while (ApocGetAppMsg(Srv, &msgch, msgbuf, &msglen) > 0) {
if (GuiCmd_HandleMsgs(msgch, msgbuf, msglen))
continue;
if (DVA_HandleMsgs(msgch, msgbuf, msglen))
continue;
/* Put your own message handling code here. */
/* ... */
}
}
}
/* Put your code handling other regular tasks here. */
/* ... */
}
static void
pause (int milliseconds)
{
double tstart = ApoGetTime_ms();
do {
ApoClnt_PollAndSleep();
} while (ApoGetTime_ms()-tstart < milliseconds);
}
static void
setup_client (void)
{
if (ApocInit() != ApoErrOk)
error_and_exit("Fail to initialize APO library\n");
Srv = ApoClnt_Connect(AppClass, AppHost, AppUser, ChannelMask);
if (Srv == NULL)
error_and_exit("Could not connect\n");
if (!GuiCmd_IsReady(Srv))
error_and_exit("GUI not ready\n");
}
static void
teardown_client (void)
{
ApocCloseServer(Srv);
}
/******************************************************************************/
static ...