diff --git a/.gitignore b/.gitignore index be467ea..4aa8d8f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ *.pdb *.user Debug/ -Release/ \ No newline at end of file +Release/ +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9cb62be --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,69 @@ +# Can only cross-compile on non-Windows for obvious reasons, so enforce. +if(CMAKE_HOST_UNIX) + set(CMAKE_SYSTEM_NAME "Windows") + set(CMAKE_SYSTEM_VERSION "10.0") + set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) + + # Use host binaries but target libraries and headers. + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +set(CMAKE_SYSTEM_PROCESSOR "x86") + +cmake_minimum_required(VERSION 3.22) +project(SCGL LANGUAGES C CXX) + +if(NOT CMAKE_HOST_WIN32 AND NOT CMAKE_CROSSCOMPILING) + message(FATAL_ERROR "SCGL targets SimCity 4, a 32-bit Windows application, and must be cross-compiled.") +endif() + +if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4) + message(FATAL_ERROR "You're using a compiler that generates 64-bit code. SCGL must be 32-bit.") +endif() + +add_library(SCGL SHARED + scgl/cGDriver.cpp + scgl/cGDriversCOMDirector.cpp + scgl/cGDriver_Info.cpp + scgl/cGDriver_Init.cpp + scgl/cGDriver_Textures.cpp + scgl/cGDriver_Unknown.cpp + scgl/cGDriver_Viewport.cpp + scgl/ext/cGDriver_BufferRegions.cpp + scgl/ext/cGDriver_Lighting.cpp + scgl/ext/cGDriver_Snapshot.cpp + scgl/ext/cGDriver_VertexBuffers.cpp + scgl/GLStateManager.cpp + scgl/GLSupport.cpp + scgl/GLTextureUnit.cpp + scgl/VertexFormatUtils.cpp + vendor/framework/src/cRZCOMDllDirector.cpp + vendor/framework/src/cRZRefCount.cpp +) + +set_target_properties(SCGL PROPERTIES PREFIX "") + +target_include_directories(SCGL PRIVATE "${CMAKE_SOURCE_DIR}/vendor/framework/include;${CMAKE_SOURCE_DIR}/scgl;${CMAKE_SOURCE_DIR}/scgl/ext") + +# Flags for debug builds. +target_compile_options(SCGL PRIVATE + $<$,$>:/W3 /utf-8 /MP> + $<$,$>,$>:-Wall -fpermissive> +) + +# For release +target_compile_options(SCGL PRIVATE + $<$,$>:/W3 /utf-8 /Gw /Zc:threadSafeInit- /O2> + $<$,$>,$>:-Wall -fpermissive -O3 -flto> +) + +# Definitions +target_compile_definitions(SCGL PRIVATE + $<$,$>,$>:__FUNCSIG__=__PRETTY_FUNCTION__> +) + +# Should come with MinGW +target_link_libraries(SCGL opengl32.lib) diff --git a/scgl/GLSupport.h b/scgl/GLSupport.h index 7c4a72d..b661b23 100644 --- a/scgl/GLSupport.h +++ b/scgl/GLSupport.h @@ -1,7 +1,7 @@ #pragma once #define WIN32_LEAN_AND_MEAN -#include -#include +#include +#include // ---------------------- Begin GLext subset ---------------------- #ifndef APIENTRY