ufoaiorg / ufoai

UFO:Alien Invasion
http://ufoai.org
GNU General Public License v2.0
148 stars 51 forks source link

Minimal build instructions for macOS Sierra #40

Closed jiahao closed 1 month ago

jiahao commented 6 years ago

I thought I would share here some steps I had to go through to make master build on macOS Sierra and homebrew, since the build instructions on the wiki seem outdated.

  1. brew install gettext sdl2 sdl2_mixer sdl2_ttf libogg libvorbis libpng libjpeg

  2. Create build directory and run ccmake. Under t (advanced options), set:

    LIBINTL_INCLUDE_DIR              /usr/local/opt/gettext/include
    LIBINTL_LIBRARY                  /usr/local/opt/gettext/lib
  3. Make the following changes to the libcurl calls:

diff --git a/src/client/cl_http.cpp b/src/client/cl_http.cpp
index 342f74d..8e7b7bb 100644
--- a/src/client/cl_http.cpp
+++ b/src/client/cl_http.cpp
@@ -187,7 +187,7 @@ static void CL_StartHTTPDownload (dlqueue_t* entry, dlhandle_t* dl)
        curl_easy_setopt(dl->curl, CURLOPT_NOPROGRESS, 0);
        if (dl->file) {
                curl_easy_setopt(dl->curl, CURLOPT_WRITEDATA, dl->file);
-               curl_easy_setopt(dl->curl, CURLOPT_WRITEFUNCTION, nullptr);
+               curl_easy_setopt(dl->curl, CURLOPT_WRITEFUNCTION, NULL);
        } else {
                curl_easy_setopt(dl->curl, CURLOPT_WRITEDATA, dl);
                curl_easy_setopt(dl->curl, CURLOPT_WRITEFUNCTION, HTTP_Recv);
diff --git a/src/common/http.cpp b/src/common/http.cpp
index d2cdabb..023219c 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -177,7 +177,7 @@ static bool HTTP_GetURLInternal (dlhandle_t& dl, const char* url, FILE* file, co
        curl_easy_setopt(dl.curl, CURLOPT_FAILONERROR, 1);
        if (file) {
                curl_easy_setopt(dl.curl, CURLOPT_WRITEDATA, file);
-               curl_easy_setopt(dl.curl, CURLOPT_WRITEFUNCTION, nullptr);
+               curl_easy_setopt(dl.curl, CURLOPT_WRITEFUNCTION, NULL);
        } else {
                curl_easy_setopt(dl.curl, CURLOPT_WRITEDATA, &dl);
                curl_easy_setopt(dl.curl, CURLOPT_WRITEFUNCTION, HTTP_Recv);
  1. Run make and it should run until the final link step.

  2. Make the following changes to the link command in CMakeFiles/ufo.dir/link.txt:

    • Replace the -framework OpenGL -lGL -lrt link flags with just -framework OpenGL (sometimes -framework OpenGL is missing entirely)
    • Add in the missing linker flags for libintl: -L/usr/local/opt/gettext/lib -lintl (this can go at the end of the line)
  3. Run make again and the ufo binary should be made.

These instructions (with similar edits for step 5 for CMakeFiles/ufotestall.dir/link.txt) seem to work for all target other than UFORADIANT (which requires GTK and I didn't figure out how to get it to work yet). Hopefully, these instructions will be helpful to figure out how to get the CMake build process working on macOS.

DarkRainX commented 6 years ago

I don't have a mac, so I have to ask: why are the changes to the calls to libcurl needed?