Skip to content

Commit

Permalink
Peer feedback: Refactor the code so that it doesn't require the symbo…
Browse files Browse the repository at this point in the history
…lic 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).
  • Loading branch information
stephengtuggy committed May 3, 2024
1 parent 2af4b78 commit c6b4f7c
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 63 deletions.
34 changes: 28 additions & 6 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
119 changes: 119 additions & 0 deletions engine/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"VERBOSE": "ON"
},
"cacheVariables": {
"CMAKE_PREFIX_PATH": "/usr/local",
"CMAKE_FIND_FRAMEWORK": "LAST"
}
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions engine/objconv/basemaker/base_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
#include <sys/types.h>

#if defined(__APPLE__) && defined(__MACH__)
# include <GLUT/glut.h>
# include <OpenGL/glext.h>
# include <glut.h>
# include <glext.h>
#else
# include <GL/glut.h>
# include <GL/glext.h>
# include <glut.h>
# include <glext.h>
#endif

/*
Expand Down
8 changes: 4 additions & 4 deletions engine/objconv/basemaker/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include "vs_globals.h"

#if defined(__APPLE__) && defined(__MACH__)
# include <GLUT/glut.h>
# include <OpenGL/glext.h>
# include <glut.h>
# include <glext.h>
#else
# include <GL/glut.h>
# include <GL/glext.h>
# include <glut.h>
# include <glext.h>
#endif

#include <iostream>
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cmd/ai/flykeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

#include "in.h"
#if defined(__APPLE__) && defined(__MACH__)
#include <GLUT/glut.h>
#include <glut.h>
#else
#include <GL/glut.h>
#include <glut.h>
#endif
#include "flybywire.h"

Expand Down
4 changes: 2 additions & 2 deletions engine/src/gfx/screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include "xml_support.h"
#include "vsimage.h"
#ifndef __APPLE__
#include <GL/glut.h>
#include <glut.h>
#else
#include <GLUT/glut.h>
#include <glut.h>
#endif

using namespace VSFileSystem;
Expand Down
6 changes: 3 additions & 3 deletions engine/src/gfx/star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
#include "vs_logging.h"

#if defined(__APPLE__) && defined(__MACH__)
# include <OpenGL/gl.h>
# include <gl.h>
#elif defined (_WIN32) || defined (__CYGWIN__)
# ifndef NOMINMAX
# define NOMINMAX
# endif //tells VCC not to generate min/max macros
# include <windows.h>
# include <GL/gl.h>
# include <gl.h>
#else
# include <GL/gl.h>
# include <gl.h>
#endif

#define SINX 1
Expand Down
10 changes: 5 additions & 5 deletions engine/src/gldrv/gl_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ struct GFXStats
#define NOMINMAX
#endif //tells VCC not to generate min/max macros
#include <windows.h>
#include <GL/gl.h>
#include <gl.h>
#endif

#if defined(__APPLE__) && defined(__MACH__)
#include <GLUT/glut.h>
#include <glut.h>
//#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
Expand All @@ -113,14 +113,14 @@ struct GFXStats
#endif
#define GL_GLEXT_PROTOTYPES
//#endif
#include <OpenGL/glext.h>
#include <glext.h>
#else
#define __glext_h_
#include <GL/glut.h>
#include <glut.h>
#include "gl_undefined_extensions.h"
#undef __glext_h_

#include <GL/glext.h>
#include <glext.h>
#endif

#ifdef _WIN32
Expand Down
4 changes: 2 additions & 2 deletions engine/src/gldrv/gl_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#define VEGA_STRIKE_ENGINE_GLDRV_GL_INCLUDE_H

#if defined(__APPLE__) && defined(__MACH__)
# include <GLUT/glut.h>
# include <glut.h>
#else
# include <GL/glut.h>
# include <glut.h>
#endif

#endif //VEGA_STRIKE_ENGINE_GLDRV_GL_INCLUDE_H
10 changes: 5 additions & 5 deletions engine/src/gldrv/gl_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
#endif
#define GL_GLEXT_PROTOTYPES 1
#if defined(__APPLE__) && defined(__MACH__)
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# include <gl.h>
# include <glext.h>
# include <dlfcn.h>
#else
# include <GL/gl.h>
# include <GL/glext.h>
# include <gl.h>
# include <glext.h>
#endif
#ifdef GL_EXT_compiled_vertex_array
# ifndef PFNGLLOCKARRAYSEXTPROC
Expand All @@ -75,7 +75,7 @@
# define GLX_GLXEXT_PROTOTYPES 1
# define GLX_GLXEXT_LEGACY 1
# include <GL/glx.h>
# include <GL/glext.h>
# include <glext.h>
#endif
#endif

Expand Down
12 changes: 6 additions & 6 deletions engine/src/gldrv/gl_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ extern "C"
* count on that... */

#if defined (IRIX)
#include <GL/gl.h>
#include <GL/glut.h>
#include <gl.h>
#include <glut.h>
typedef void (*PFNGLLOCKARRAYSEXTPROC)( GLint first, GLsizei count );
typedef void (*PFNGLUNLOCKARRAYSEXTPROC)( void );

#elif !defined (_WIN32)
#if defined(__APPLE__) && defined(__MACH__)
# include <GLUT/glut.h>
# include <OpenGL/glext.h>
# include <glut.h>
# include <glext.h>
#else
# include <GL/glut.h>
# include <GL/glext.h>
# include <glut.h>
# include <glext.h>
#endif

#if !defined (GL_GLEXT_VERSION) || GL_GLEXT_VERSION < 6
Expand Down
Loading

0 comments on commit c6b4f7c

Please sign in to comment.