[CMake] Cygwin drive paths are killing me

Eric Wing ewmailing at gmail.com
Fri Jun 13 18:52:22 EDT 2014


I finally got it working. Here's a summary of my findings in case
anybody finds this useful. (I think this will ultimately be useful
info in trying to build a proper Android generator for CMake.)

- I ditched Cygwin. (But I learned that CMake later on for Unix
Makefiles complains about Cygwin sh.exe being in my path, and
uninstalling Cygwin is kind of hard.)

- I got MSYS to work in the base case of simply getting through generation.

    - But MSYS turned out to be a problem for me because the way I
integrate it with Android Studio/Gradle, I need to execute a command
line task to invoke CMake. Since Android Studio/Gradle don't know
anything about the MSYS environment, it fails because the standard
CMD.exe process doesn't understand MSYS Makefiles. And I could not
figure out a way to get Gradle/Groovy to start an MSYS process and
also run a script. (At best I could launch an MSYS shell, but it just
sits there waiting for input.)

- So I moved to pure Windows (no Unix stuff). It turns out you *must*
have something Unix-y to generate the standalone toolchain. I suspect
this and some other tools in Android are still Unix only and that's
why Google says Cygwin is required. However, once I generated the
standalone toolchain, I did not need Unix again.

- For the native generation, I needed to generate "Unix Makefiles".

- For this to work, I needed to download a prebuilt, standalone GNU
Make.exe which I pass the path to explicitly when I generate.
(Additionally my Groovy callbacks  need to find this path information
to invoke Make when you build from Studio/Gradle.)

- I moved CMake to the first step in the build process since I make
CMake also responsible for managing assets. CMake copies the assets to
a place Studio/Gradle expect

- I let Android Studio/Gradle deal with the Java and creating the apk
(with assets). So install and packaging targets are bypassed in my
CMake scripts.

- I still struggled with the backslash vs forward slash path issues in
a few places. Generally speaking, I found it better to convert all
backslashes to forward slashes because backslashes kept triggering
escape sequences in CMake. However, this technique broke in some
places, like where I need to invoke a task in Groovy, but I was
reading values passed (and converted) from CMake. So I had to convert
back to backslashes in some cases.

This whole thing took more time to set up than Mac + iOS + Linux +
Windows combined. But it works so I'm relieved.

Thanks,
Eric


More information about the CMake mailing list