Question

I've got a makefile (a file called 'Makefile' which is run by cmake in Linux, but works in Windows via nmake I believe and needs to be run in VS command prompt.)

And most of the 'sample' ones I can see are just one line (and the rest appear to be stuff I don't 'yet' understand and then this same one line.

include $(shell rospack find mk)/cmake.mk

(in the terminal rospack find [package] returns the path to said package, and cmake.mk is obviously the file it wants to include)

My problem is, that this appears (to me at least) to be written for use in a Linux system (which basically the entirety of ros, the program I'm working with, was) and in Windows this appears to just try to be

include /cmake.mk

(which unsurprisingly doesn't work)

Basically I need to know how to do the same thing in windows, generally in a 'dynamic' way, as it will only cause more problems down the line if I get this working by hard-coding the directory path and then it breaks because its not set properly some time in the future)

So I guess if this isn't possible or is particularly hard, a way of hard coding it would be a stopgap.

I tried:

include C:\[directory]\cmake.mk

but it seems to have issues with the ':'

I'm trying to work with Windows, because later in my project I'll be needing to use another program (for i90 robot) for which we only have Windows support.

OK, so apparently it acts differently if the file is actually in the folder. as in

include C:\[directory]\cmake.mk

Errors with

C:\[directory]\cmake.mk not found

if the file isn't there, and

fatal error U1034: syntax error : separator missing

if it is

While this doesn't really seem to impact on the original problem, I guess it indicates I'm trying to do something funky windows doesn't like.

Was it helpful?

Solution

The short answer is, you'll never get a single makefile that does much of anything complicated that will work both with standard UNIX-style make (such as GNU make from GNU/Linux) and also work with nmake. Nmake is a completely different beast.

As an aside, it's confusing that your makefiles here are called "cmake", because cmake is an actual program, distinct from make (and nmake). I'm assuming, though, from the context that the use of the term "cmake" here doesn't refer to the actual cmake utility. Which is too bad, because if it did use cmake things would be simpler for you. Maybe.

It's not clear exactly what your requirement to use nmake is, though. If you laid out your real requirements, it would be a lot easier for us to advise you. For example, you say you need to use a "another program" which runs only on Windows. What does this program do, exactly, and how will you need to use it? Does it provide libraries that need to be linked with the "ros" code?

Basically, your simplest way forward is to obtain a UNIX-like environment, including tools like GNU make, for your Windows system. There are two main choices: Cygwin, which provides a completely POSIX infrastructure including shell, compiler, etc. which are ports of the GNU environment to Windows but require a POSIX layer, and MinGW, which has various GNU tools that run more or less natively on Windows.

However, if you MUST use Visual Studio as your compiler, for example, then these will be much more difficult to integrate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top