Clarify MSVC-only bundled SDL support
This commit is contained in:
19
BUILDING.md
19
BUILDING.md
@@ -12,6 +12,7 @@ Requirements:
|
|||||||
- CMake 3.21+
|
- CMake 3.21+
|
||||||
|
|
||||||
The repository already contains the required prebuilt Windows SDL packages in `Libraries/`.
|
The repository already contains the required prebuilt Windows SDL packages in `Libraries/`.
|
||||||
|
Those bundled packages are intended for **MSVC / Visual Studio**, not MinGW.
|
||||||
|
|
||||||
Configure and build:
|
Configure and build:
|
||||||
|
|
||||||
@@ -38,6 +39,14 @@ cmake --build build
|
|||||||
### 3. Legacy Visual Studio solution
|
### 3. Legacy Visual Studio solution
|
||||||
The existing `.sln` and `.vcxproj` files are still in the repo and can still be opened directly in Visual Studio.
|
The existing `.sln` and `.vcxproj` files are still in the repo and can still be opened directly in Visual Studio.
|
||||||
|
|
||||||
|
### CLion with MinGW on Windows
|
||||||
|
This is a different toolchain from MSVC. The bundled SDL packages in `Libraries/` are the Visual C++ SDL package, so they should not be used with MinGW.
|
||||||
|
|
||||||
|
Use one of these options instead:
|
||||||
|
|
||||||
|
- switch CLion to a Visual Studio toolchain
|
||||||
|
- or install MinGW-compatible SDL packages and configure CMake with `-DMOTHERLOAD_USE_BUNDLED_WINDOWS_SDL=OFF`
|
||||||
|
|
||||||
## Build output
|
## Build output
|
||||||
|
|
||||||
The CMake build writes the executable to:
|
The CMake build writes the executable to:
|
||||||
@@ -55,6 +64,8 @@ CMake uses the bundled SDL package config files from:
|
|||||||
- `Libraries/SDLMixer/.../cmake`
|
- `Libraries/SDLMixer/.../cmake`
|
||||||
- `Libraries/SDLTtf/.../cmake`
|
- `Libraries/SDLTtf/.../cmake`
|
||||||
|
|
||||||
|
These are only used for **MSVC** builds.
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
CMake falls back to `pkg-config` and expects these packages to be installed:
|
CMake falls back to `pkg-config` and expects these packages to be installed:
|
||||||
- `sdl2`
|
- `sdl2`
|
||||||
@@ -76,6 +87,14 @@ sudo apt install libgl1-mesa-dev
|
|||||||
### CMake cannot find SDL packages on Linux
|
### CMake cannot find SDL packages on Linux
|
||||||
Install the SDL development packages listed above.
|
Install the SDL development packages listed above.
|
||||||
|
|
||||||
|
### CLion / MinGW on Windows fails while linking SDL2main
|
||||||
|
That usually means the Visual Studio SDL package from `Libraries/` is being used with MinGW.
|
||||||
|
|
||||||
|
Use one of these fixes:
|
||||||
|
|
||||||
|
- use a Visual Studio toolchain in CLion
|
||||||
|
- or configure CMake with `-DMOTHERLOAD_USE_BUNDLED_WINDOWS_SDL=OFF` and provide MinGW-compatible SDL libraries
|
||||||
|
|
||||||
### The game starts but cannot find assets
|
### The game starts but cannot find assets
|
||||||
Run the executable from the build output directory, not from the source directory root. The post-build step copies `Resources/` next to the executable.
|
Run the executable from the build output directory, not from the source directory root. The post-build step copies `Resources/` next to the executable.
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|
||||||
option(MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL "Use the bundled prebuilt SDL packages on Windows" ON)
|
option(MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL "Use the bundled prebuilt SDL packages for MSVC builds on Windows" ON)
|
||||||
option(MOTHERLOAD_ENABLE_WARNINGS "Enable compiler warnings" ON)
|
option(MOTHERLOAD_ENABLE_WARNINGS "Enable compiler warnings" ON)
|
||||||
|
|
||||||
if(WIN32 AND MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL)
|
if(WIN32 AND MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL AND NOT MSVC)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL=ON only supports MSVC/Visual Studio builds. "
|
||||||
|
"The bundled SDL package in Libraries/ is the SDL2 Visual C++ build, not a MinGW build. "
|
||||||
|
"For CLion/MinGW, disable MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL and use MinGW-compatible SDL packages instead."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC AND MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL)
|
||||||
list(PREPEND CMAKE_PREFIX_PATH
|
list(PREPEND CMAKE_PREFIX_PATH
|
||||||
"${CMAKE_SOURCE_DIR}/Libraries/SDLMain/SDL2-2.26.3/cmake"
|
"${CMAKE_SOURCE_DIR}/Libraries/SDLMain/SDL2-2.26.3/cmake"
|
||||||
"${CMAKE_SOURCE_DIR}/Libraries/SDLImage/SDL2_image-2.6.3/cmake"
|
"${CMAKE_SOURCE_DIR}/Libraries/SDLImage/SDL2_image-2.6.3/cmake"
|
||||||
@@ -134,6 +142,11 @@ target_include_directories(Motherload
|
|||||||
"${CMAKE_SOURCE_DIR}/Game"
|
"${CMAKE_SOURCE_DIR}/Game"
|
||||||
"${CMAKE_SOURCE_DIR}/Engine"
|
"${CMAKE_SOURCE_DIR}/Engine"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(TARGET SDL2::SDL2main)
|
||||||
|
target_link_libraries(Motherload PRIVATE SDL2::SDL2main)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(Motherload
|
target_link_libraries(Motherload
|
||||||
PRIVATE
|
PRIVATE
|
||||||
Engine
|
Engine
|
||||||
@@ -143,10 +156,6 @@ target_link_libraries(Motherload
|
|||||||
SDL2_mixer::SDL2_mixer
|
SDL2_mixer::SDL2_mixer
|
||||||
SDL2_ttf::SDL2_ttf
|
SDL2_ttf::SDL2_ttf
|
||||||
)
|
)
|
||||||
|
|
||||||
if(TARGET SDL2::SDL2main)
|
|
||||||
target_link_libraries(Motherload PRIVATE SDL2::SDL2main)
|
|
||||||
endif()
|
|
||||||
motherload_enable_warnings(Motherload)
|
motherload_enable_warnings(Motherload)
|
||||||
|
|
||||||
source_group(TREE "${CMAKE_SOURCE_DIR}" FILES ${ENGINE_SOURCES} ${GAME_SOURCES})
|
source_group(TREE "${CMAKE_SOURCE_DIR}" FILES ${ENGINE_SOURCES} ${GAME_SOURCES})
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ For the longer version, troubleshooting, and platform notes, see [`BUILDING.md`]
|
|||||||
* Visual Studio 2022 with the Desktop development with C++ workload
|
* Visual Studio 2022 with the Desktop development with C++ workload
|
||||||
* CMake 3.21 or newer
|
* CMake 3.21 or newer
|
||||||
|
|
||||||
The repository already contains prebuilt SDL2 / SDL2_image / SDL2_mixer / SDL2_ttf Windows packages in `Libraries/`, and the CMake build will use those by default.
|
The repository already contains prebuilt SDL2 / SDL2_image / SDL2_mixer / SDL2_ttf Windows packages in `Libraries/`, and the CMake build will use those by default for **MSVC / Visual Studio** builds.
|
||||||
|
|
||||||
|
If you use **CLion with MinGW**, do **not** use the bundled SDL package. It is the Visual C++ SDL build and is not a proper MinGW dependency set.
|
||||||
|
|
||||||
#### Linux
|
#### Linux
|
||||||
Install the development packages first.
|
Install the development packages first.
|
||||||
@@ -125,6 +127,7 @@ After building, run the generated executable from the build output directory so
|
|||||||
* The original `.sln` and `.vcxproj` files are still present and can still be used in Visual Studio.
|
* The original `.sln` and `.vcxproj` files are still present and can still be used in Visual Studio.
|
||||||
* The CMake build creates the same two logical targets as the solution: `Engine` and `Motherload`.
|
* The CMake build creates the same two logical targets as the solution: `Engine` and `Motherload`.
|
||||||
* On non-Windows platforms, SDL dependencies are expected to come from the system package manager.
|
* On non-Windows platforms, SDL dependencies are expected to come from the system package manager.
|
||||||
|
* On Windows, the bundled SDL dependencies are intended for **MSVC**, not MinGW.
|
||||||
|
|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user