Skip to content

Commit

Permalink
Merge pull request #537 from Daft-Freak/patch-2
Browse files Browse the repository at this point in the history
VS docs + VS cross-build
  • Loading branch information
Gadgetoid committed Jan 8, 2021
2 parents 48c960c + d35a5dc commit 916922e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
18 changes: 11 additions & 7 deletions 32blit.toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ set(STDLIB_PATH ${CMAKE_CURRENT_LIST_DIR}/stdlib)
set(STDLIB_URL https://github.com/32blit/stdlibs/releases/download/newlib-3.3.0-gcc-9.2.0/stdlibs.zip)
set(STDLIB_HASH "${STDLIB_HASHTYPE}=0431fa7b3fe5e463424078546560b06490890abf4967745ac85b8b6b430d1941")

find_program(UNZIP NAMES unzip)
if(NOT UNZIP)
message(FATAL_ERROR "Failed to find required program: \"unzip\"\n(maybe you need to \"apt install unzip\")\n")
if(${CMAKE_VERSION} VERSION_LESS "3.18")
find_program(UNZIP NAMES unzip)
if(NOT UNZIP)
message(FATAL_ERROR "Failed to find required program: \"unzip\"\n(maybe you need to \"apt install unzip\")\n")
endif()
endif()

# file() is great, but it doesn't tell the user what it's downloading
Expand All @@ -77,10 +79,12 @@ endif()
if(NOT EXISTS ${STDLIB_PATH}/pic)
message("Extracting stdlibs...")

# CMake 3.18
#file(ARCHIVE_EXTRACT INPUT ${STDLIB_PATH}/stdlibs.zip DESTINATION ${STDLIB_PATH})

execute_process(COMMAND ${UNZIP} -u ${STDLIB_PATH}/stdlibs.zip -d ${STDLIB_PATH} RESULT_VARIABLE UNZIP_STATUS)
if(${CMAKE_VERSION} VERSION_LESS "3.18")
execute_process(COMMAND ${UNZIP} -u ${STDLIB_PATH}/stdlibs.zip -d ${STDLIB_PATH} RESULT_VARIABLE UNZIP_STATUS)
else()
file(ARCHIVE_EXTRACT INPUT ${STDLIB_PATH}/stdlibs.zip DESTINATION ${STDLIB_PATH})
set(UNZIP_STATUS 0)
endif()

if(NOT ${UNZIP_STATUS} EQUAL 0)
message(FATAL_ERROR "Failed to extract stdlibs: ${UNZIP_STATUS}\n")
Expand Down
25 changes: 22 additions & 3 deletions docs/Windows-VisualStudio.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ See [Building & Running On 32Blit](32blit.md) if you want to compile examples/pr
- [Option 1: Use the solution file](#option-1-use-the-solution-file)
- [Get started with your own game](#get-started-with-your-own-game)
- [Option 2: Use Visual Studio's built-in CMake support](#option-2-use-visual-studios-built-in-cmake-support)
- [Building your own game](#building-with-your-own-game)
- [Building your own game](#building-your-own-game)
- [Building for 32Blit](#building-for-32blit)
- [Troubleshooting](#troubleshooting)

## Requirements
Expand Down Expand Up @@ -62,12 +63,30 @@ To find the built files use `Project` > `CMake Cache` > `Open in Explorer`.

6. Browse to the folder containing the 32blit repo.

7. Save. It should configure successfully.
7. To add a release configuration, press "Add a new configuration..." (the plus button under "Configurations"), select "x64-Release" and repeat steps 4-6 on the new configuration.

8. Build!
8. Save. It should configure successfully.

9. Build!

[More info about using CMake with Visual Studio](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019)

### Building for 32Blit

1. Make sure the "Embedded and IoT development tools" component is installed.

2. Open the CMake Settings (see above).

3. Press "Add a new configuration..." and select "IoT-Release".

4. Scroll down to "CMake toolchain file" and browse to `32blit.toolchain`

5. (Optional) Change configuration name to something like "32Blit-Release"

6. Save.

7. Select the new config and build!

## Troubleshooting

If you see errors such as `Cannot open include file: 'SDL.h': No such file or directory` and `cannot open file 'SDL2.lib'` you've probably extracted the SDL development libraries wrong. Inside your sdl folder you should have the folders docs, include and lib not SDL2-2.0.10.

0 comments on commit 916922e

Please sign in to comment.