From c6b4f7c3cb37915ac7ba1ab67dd73e0c05c1b359 Mon Sep 17 00:00:00 2001 From: Stephen G Tuggy Date: Fri, 3 May 2024 06:59:04 -0700 Subject: [PATCH] Peer feedback: Refactor the code so that it doesn't require the symbolic links to GL/ to be added by the bootstrap scripts. Also add 4 more configures preset to CMakePresets.json (MacPorts versions of the existing macOS presets). --- engine/CMakeLists.txt | 34 +++++- engine/CMakePresets.json | 119 ++++++++++++++++++++ engine/objconv/basemaker/base_maker.cpp | 8 +- engine/objconv/basemaker/sprite.h | 8 +- engine/src/cmd/ai/flykeyboard.h | 4 +- engine/src/gfx/screenshot.cpp | 4 +- engine/src/gfx/star.cpp | 6 +- engine/src/gldrv/gl_globals.h | 10 +- engine/src/gldrv/gl_include.h | 4 +- engine/src/gldrv/gl_init.cpp | 10 +- engine/src/gldrv/gl_init.h | 12 +- engine/src/gldrv/winsys.cpp | 6 +- engine/src/gldrv/winsys.h | 4 +- engine/src/gui/button.h | 8 +- engine/src/gui/text_area.h | 8 +- engine/src/vegastrike.h | 12 +- script/bootstrap-on-macOS-using-MacPorts.sh | 3 - script/bootstrap-on-macos.sh | 10 +- 18 files changed, 207 insertions(+), 63 deletions(-) diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 8661ce927e..80314aa5d4 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -127,7 +127,7 @@ IF (UNIX) ${Vega_Strike_SOURCE_DIR}/src/resource ${Vega_Strike_BINARY_DIR} ${Vega_Strike_BINARY_DIR}/src - /usr/include/harfbuzz/ + ${CMAKE_PREFIX_PATH}/harfbuzz/ ) ELSE () INCLUDE_DIRECTORIES( @@ -401,9 +401,18 @@ IF (NOT DISABLE_CLIENT) ########## SET(CMAKE_FIND_FRAMEWORK "FIRST") FIND_PACKAGE(OpenGL REQUIRED) IF (OPENGL_FOUND AND OPENGL_GLU_FOUND) - SET(TST_INCLUDES ${TST_INCLUDES} ${OPENGL_INCLUDE_DIR}) - # SET(TST_LIBS ${TST_LIBS} "${OpenGL::GL}" "${OpenGL::GLU}") MESSAGE("++ OpenGL found") + SET(CMAKE_FIND_FRAMEWORK "LAST") + FIND_FILE(VEGA_GLEXT_H_PATH glext.h PATH_SUFFIXES GL/ OpenGL/) + get_filename_component(VEGA_GLEXT_H_DIRECTORY ${VEGA_GLEXT_H_PATH} DIRECTORY) + MESSAGE(STATUS "Path to glext.h: ${VEGA_GLEXT_H_PATH}") + FIND_FILE(VEGA_GL_H_PATH gl.h PATH_SUFFIXES GL/ OpenGL/) + get_filename_component(VEGA_GL_H_DIRECTORY ${VEGA_GL_H_PATH} DIRECTORY) + MESSAGE(STATUS "Path to gl.h: ${VEGA_GL_H_PATH}") + FIND_FILE(VEGA_GLU_H_PATH glu.h PATH_SUFFIXES GL/ OpenGL/) + get_filename_component(VEGA_GLU_H_DIRECTORY ${VEGA_GLU_H_PATH} DIRECTORY) + MESSAGE(STATUS "Path to glu.h: ${VEGA_GLU_H_PATH}") + SET(TST_INCLUDES ${TST_INCLUDES} ${VEGA_GLEXT_H_DIRECTORY} ${VEGA_GL_H_DIRECTORY} ${VEGA_GLU_H_DIRECTORY}) ELSE (OPENGL_FOUND AND OPENGL_GLU_FOUND) MESSAGE("!! Why you no have GL?") ENDIF (OPENGL_FOUND AND OPENGL_GLU_FOUND) @@ -426,11 +435,16 @@ IF (NOT DISABLE_CLIENT) ########## SET(OPENGL_LIBRARY_DIR "${OPENGL_INCLUDE_DIR}/GLUT") #Find GLUT + SET(CMAKE_FIND_FRAMEWORK "FIRST") FIND_PACKAGE(GLUT REQUIRED) IF (GLUT_FOUND) - SET(TST_INCLUDES ${TST_INCLUDES} ${GLUT_INCLUDE_DIR}) - SET(TST_LIBS ${TST_LIBS} ${GLUT_LIBRARIES}) MESSAGE("++ GLUT found : ${GLUT_LIBRARIES}") + SET(CMAKE_FIND_FRAMEWORK "LAST") + FIND_FILE(VEGA_GLUT_H_PATH glut.h PATH_SUFFIXES GL/ GLUT/) + get_filename_component(VEGA_GLUT_H_DIRECTORY ${VEGA_GLUT_H_PATH} DIRECTORY) + MESSAGE(STATUS "Path to glut.h: ${VEGA_GLUT_H_PATH}") + SET(TST_INCLUDES ${TST_INCLUDES} ${VEGA_GLUT_H_PATH} ${GLUT_INCLUDE_DIR}) + SET(TST_LIBS ${TST_LIBS} ${GLUT_LIBRARIES}) ELSE (GLUT_FOUND) MESSAGE("!! I can't build this, missing GLUT") ENDIF (GLUT_FOUND) @@ -1058,6 +1072,10 @@ SET(LIBAUDIO_SOURCES ADD_LIBRARY(vegastrike-engine_com + ${VEGA_GL_H_PATH} + ${VEGA_GLU_H_PATH} + ${VEGA_GLEXT_H_PATH} + ${VEGA_GLUT_H_PATH} ${LIBVS_LOGGING} ${LIBCONFIG} ${LIBDAMAGE} @@ -1085,6 +1103,10 @@ IF (WIN32) ENDIF() SET(VEGASTRIKE_SOURCES + ${VEGA_GL_H_PATH} + ${VEGA_GLU_H_PATH} + ${VEGA_GLEXT_H_PATH} + ${VEGA_GLUT_H_PATH} ${LIBGUI_SOURCES} ${LIBNETCLIENT_SOURCES} ${LIBROOTCLIENT_SOURCES} @@ -1184,7 +1206,7 @@ ENDIF (NOT DISABLE_CLIENT) # Vssetup Sub build file ADD_SUBDIRECTORY(setup) -# Add other utilies here +# Add other utilities here ADD_SUBDIRECTORY(objconv) ## show debug output diff --git a/engine/CMakePresets.json b/engine/CMakePresets.json index 27eb917d3c..8459003bc5 100644 --- a/engine/CMakePresets.json +++ b/engine/CMakePresets.json @@ -213,6 +213,7 @@ "VERBOSE": "ON" }, "cacheVariables": { + "CMAKE_PREFIX_PATH": "/usr/local", "CMAKE_FIND_FRAMEWORK": "LAST" } }, @@ -272,6 +273,80 @@ "rhs": "Darwin" } }, + { + "name": "macOS-MacPorts-default", + "hidden": true, + "inherits": "default", + "displayName": "macOS (MacPorts) Default", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + }, + "environment": { + "VERBOSE": "ON" + }, + "cacheVariables": { + "CMAKE_PREFIX_PATH": "/opt/local", + "Boost_INCLUDE_DIR": "/opt/local/libexec/boost/1.81/include" + } + }, + { + "name": "macOS-MacPorts-pie-enabled-debug", + "inherits": [ + "macOS-MacPorts-default", + "pie-enabled", + "debug" + ], + "displayName": "macOS (MacPorts), PIE Enabled, Debug", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "macOS-MacPorts-pie-enabled-release", + "inherits": [ + "macOS-MacPorts-default", + "pie-enabled", + "release" + ], + "displayName": "macOS (MacPorts), PIE Enabled, Release", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "macOS-MacPorts-pie-disabled-debug", + "inherits": [ + "macOS-MacPorts-default", + "pie-disabled", + "debug" + ], + "displayName": "macOS (MacPorts), PIE Disabled, Debug", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "macOS-MacPorts-pie-disabled-release", + "inherits": [ + "macOS-MacPorts-default", + "pie-disabled", + "release" + ], + "displayName": "macOS (MacPorts), Pie Disabled, Release", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, { "name": "windows-base", "hidden": true, @@ -640,6 +715,50 @@ "rhs": "Darwin" } }, + { + "name": "build-macOS-MacPorts-pie-enabled-debug", + "configurePreset": "macOS-MacPorts-pie-enabled-debug", + "displayName": "macOS (MacPorts), PIE Enabled, Debug", + "configuration": "Debug", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "build-macOS-MacPorts-pie-enabled-release", + "configurePreset": "macOS-MacPorts-pie-enabled-release", + "displayName": "macOS (MacPorts), PIE Enabled, Release", + "configuration": "Release", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "build-macOS-MacPorts-pie-disabled-debug", + "configurePreset": "macOS-MacPorts-pie-disabled-debug", + "displayName": "macOS (MacPorts), PIE Disabled, Debug", + "configuration": "Debug", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "build-macOS-MacPorts-pie-disabled-release", + "configurePreset": "macOS-MacPorts-pie-disabled-release", + "displayName": "macOS (MacPorts), PIE Disabled, Release", + "configuration": "Release", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, { "name": "build-windows-ninja-pie-enabled-debug", "configurePreset": "windows-ninja-pie-enabled-debug", diff --git a/engine/objconv/basemaker/base_maker.cpp b/engine/objconv/basemaker/base_maker.cpp index c2b91a73e6..efd998a0a7 100644 --- a/engine/objconv/basemaker/base_maker.cpp +++ b/engine/objconv/basemaker/base_maker.cpp @@ -49,11 +49,11 @@ #include #if defined(__APPLE__) && defined(__MACH__) -# include -# include +# include +# include #else -# include -# include +# include +# include #endif /* diff --git a/engine/objconv/basemaker/sprite.h b/engine/objconv/basemaker/sprite.h index 21aebd78ec..ad4f1c4d0b 100644 --- a/engine/objconv/basemaker/sprite.h +++ b/engine/objconv/basemaker/sprite.h @@ -31,11 +31,11 @@ #include "vs_globals.h" #if defined(__APPLE__) && defined(__MACH__) -# include -# include +# include +# include #else -# include -# include +# include +# include #endif #include diff --git a/engine/src/cmd/ai/flykeyboard.h b/engine/src/cmd/ai/flykeyboard.h index 7778325c27..aa5f93bb59 100644 --- a/engine/src/cmd/ai/flykeyboard.h +++ b/engine/src/cmd/ai/flykeyboard.h @@ -26,9 +26,9 @@ #include "in.h" #if defined(__APPLE__) && defined(__MACH__) -#include +#include #else -#include +#include #endif #include "flybywire.h" diff --git a/engine/src/gfx/screenshot.cpp b/engine/src/gfx/screenshot.cpp index b98b544ca3..a7808efa9b 100644 --- a/engine/src/gfx/screenshot.cpp +++ b/engine/src/gfx/screenshot.cpp @@ -30,9 +30,9 @@ #include "xml_support.h" #include "vsimage.h" #ifndef __APPLE__ -#include +#include #else -#include +#include #endif using namespace VSFileSystem; diff --git a/engine/src/gfx/star.cpp b/engine/src/gfx/star.cpp index 3dd68ad07f..e0f3fb571e 100644 --- a/engine/src/gfx/star.cpp +++ b/engine/src/gfx/star.cpp @@ -37,15 +37,15 @@ #include "vs_logging.h" #if defined(__APPLE__) && defined(__MACH__) -# include +# include #elif defined (_WIN32) || defined (__CYGWIN__) # ifndef NOMINMAX # define NOMINMAX # endif //tells VCC not to generate min/max macros # include -# include +# include #else -# include +# include #endif #define SINX 1 diff --git a/engine/src/gldrv/gl_globals.h b/engine/src/gldrv/gl_globals.h index 01387213e8..1e6fc5644d 100644 --- a/engine/src/gldrv/gl_globals.h +++ b/engine/src/gldrv/gl_globals.h @@ -100,11 +100,11 @@ struct GFXStats #define NOMINMAX #endif //tells VCC not to generate min/max macros #include -#include +#include #endif #if defined(__APPLE__) && defined(__MACH__) -#include +#include //#if defined( GL_INIT_CPP) || defined( GL_MISC_CPP) || defined( GL_STATE_CPP) #if defined (GL_ARB_vertex_program) && defined (GL_ARB_fragment_program) #define OSX_AT_LEAST_10_4 @@ -113,14 +113,14 @@ struct GFXStats #endif #define GL_GLEXT_PROTOTYPES //#endif -#include +#include #else #define __glext_h_ -#include +#include #include "gl_undefined_extensions.h" #undef __glext_h_ -#include +#include #endif #ifdef _WIN32 diff --git a/engine/src/gldrv/gl_include.h b/engine/src/gldrv/gl_include.h index 81dc20f80b..f4ab9a4740 100644 --- a/engine/src/gldrv/gl_include.h +++ b/engine/src/gldrv/gl_include.h @@ -26,9 +26,9 @@ #define VEGA_STRIKE_ENGINE_GLDRV_GL_INCLUDE_H #if defined(__APPLE__) && defined(__MACH__) -# include +# include #else -# include +# include #endif #endif //VEGA_STRIKE_ENGINE_GLDRV_GL_INCLUDE_H diff --git a/engine/src/gldrv/gl_init.cpp b/engine/src/gldrv/gl_init.cpp index aef7f43ec0..daeb3d0c73 100644 --- a/engine/src/gldrv/gl_init.cpp +++ b/engine/src/gldrv/gl_init.cpp @@ -55,12 +55,12 @@ #endif #define GL_GLEXT_PROTOTYPES 1 #if defined(__APPLE__) && defined(__MACH__) -# include -# include +# include +# include # include #else -# include -# include +# include +# include #endif #ifdef GL_EXT_compiled_vertex_array # ifndef PFNGLLOCKARRAYSEXTPROC @@ -75,7 +75,7 @@ # define GLX_GLXEXT_PROTOTYPES 1 # define GLX_GLXEXT_LEGACY 1 # include - # include + # include #endif #endif diff --git a/engine/src/gldrv/gl_init.h b/engine/src/gldrv/gl_init.h index 0256745288..74c8cd28b6 100644 --- a/engine/src/gldrv/gl_init.h +++ b/engine/src/gldrv/gl_init.h @@ -55,18 +55,18 @@ extern "C" * count on that... */ #if defined (IRIX) -#include -#include +#include +#include typedef void (*PFNGLLOCKARRAYSEXTPROC)( GLint first, GLsizei count ); typedef void (*PFNGLUNLOCKARRAYSEXTPROC)( void ); #elif !defined (_WIN32) #if defined(__APPLE__) && defined(__MACH__) -# include -# include +# include +# include #else -# include -# include +# include +# include #endif #if !defined (GL_GLEXT_VERSION) || GL_GLEXT_VERSION < 6 diff --git a/engine/src/gldrv/winsys.cpp b/engine/src/gldrv/winsys.cpp index 34a9eae6c1..939d6afff8 100644 --- a/engine/src/gldrv/winsys.cpp +++ b/engine/src/gldrv/winsys.cpp @@ -26,15 +26,15 @@ #include #if defined(__APPLE__) && defined(__MACH__) -# include +# include #elif defined (_WIN32) || defined (__CYGWIN__) # ifndef NOMINMAX # define NOMINMAX # endif //tells VCC not to generate min/max macros # include -# include +# include #else -# include +# include #endif #include diff --git a/engine/src/gldrv/winsys.h b/engine/src/gldrv/winsys.h index ac030ee003..ce116658c3 100644 --- a/engine/src/gldrv/winsys.h +++ b/engine/src/gldrv/winsys.h @@ -36,9 +36,9 @@ # include "SDL2/SDL.h" #elif defined( HAVE_GLUT ) #if defined(__APPLE__) && defined(__MACH__) - #include + #include #else - #include + #include #endif #else # error "Neither SDL nor GLUT are present." diff --git a/engine/src/gui/button.h b/engine/src/gui/button.h index 17a3632030..0db20a63d5 100644 --- a/engine/src/gui/button.h +++ b/engine/src/gui/button.h @@ -31,8 +31,8 @@ */ #if defined(__APPLE__) && defined(__MACH__) - #include - #include + #include + #include #else #ifdef _WIN32 #ifndef NOMINMAX @@ -40,9 +40,9 @@ #endif //tells VCC not to generate min/max macros #include #else - #include + #include #endif - #include + #include #endif #include "glut_support.h" diff --git a/engine/src/gui/text_area.h b/engine/src/gui/text_area.h index 8d8937ae11..f755c4647a 100644 --- a/engine/src/gui/text_area.h +++ b/engine/src/gui/text_area.h @@ -38,8 +38,8 @@ #define NO_WARNINGS #if defined(__APPLE__) && defined(__MACH__) - #include - #include + #include + #include #else #ifdef _WIN32 #ifndef NOMINMAX @@ -47,8 +47,8 @@ #endif //tells VCC not to generate min/max macros #include #endif - #include - #include + #include + #include #endif #include "glut_support.h" diff --git a/engine/src/vegastrike.h b/engine/src/vegastrike.h index c82f524a36..cc79c4d2c4 100644 --- a/engine/src/vegastrike.h +++ b/engine/src/vegastrike.h @@ -70,14 +70,14 @@ extern float AUDIO_ATOM; #ifndef NO_GFX # if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include +# include +# include +# include # else //defined(__APPLE__) && defined(__MACH__) # define __glext_h_ -# include -# include -# include +# include +# include +# include # undef __glext_h_ # endif //defined(__APPLE__) && defined(__MACH__) #endif //NO_GFX diff --git a/script/bootstrap-on-macOS-using-MacPorts.sh b/script/bootstrap-on-macOS-using-MacPorts.sh index 720dda966c..ab60e68c8e 100755 --- a/script/bootstrap-on-macOS-using-MacPorts.sh +++ b/script/bootstrap-on-macOS-using-MacPorts.sh @@ -30,7 +30,4 @@ port install python312 boost181@1.81.0_10+cmake_scripts+no_single+no_static+pyth export CMAKE_PREFIX_PATH="/opt/local/" -ln -s /opt/local/include/GL /opt/local/include/OpenGL -ln -s /opt/local/include/GL /opt/local/include/GLUT - echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" diff --git a/script/bootstrap-on-macos.sh b/script/bootstrap-on-macos.sh index 70c2dfb953..05e0e1722d 100644 --- a/script/bootstrap-on-macos.sh +++ b/script/bootstrap-on-macos.sh @@ -5,6 +5,14 @@ # Copyright (C) 2023-2024 Stephen G. Tuggy and other # Vega Strike contributors # +# This script may not need root privileges. You should be able to run +# it as follows: +# +# ./script/bootstrap-on-macos.sh +# +# Note that this is the Homebrew version of the bootstrap script. The +# MacPorts version is called bootstrap-on-macOS-using-MacPorts.sh +# # This file is part of Vega Strike. # # Vega Strike is free software: you can redistribute it and/or modify @@ -45,8 +53,6 @@ do export CMAKE_PREFIX_PATH="$PACKAGE_INSTALLED_PREFIX:$CMAKE_PREFIX_PATH" done -ln -s /usr/local/include/GL /usr/local/include/OpenGL -ln -s /usr/local/include/GL /usr/local/include/GLUT OPENALDIR="$(brew --prefix openal-soft)" export OPENALDIR