Skip to content

Instantly share code, notes, and snippets.

@alanjfs
Last active July 9, 2020 15:26
Show Gist options
  • Save alanjfs/77282b740a6e7852046a4870ecc0b3d6 to your computer and use it in GitHub Desktop.
Save alanjfs/77282b740a6e7852046a4870ecc0b3d6 to your computer and use it in GitHub Desktop.
Magnum with ImGUI

Magnum ImGUI Quickstart - Windows Edition

Prerequisites

  • Windows
  • CMake 3.4+
  • git
  • Visual Studio 2017-2019
git clone https://github.com/mosra/magnum-bootstrap.git --branch base --single-branch
cd magnum-bootstrap
git clone https://github.com/mosra/corrade.git
git clone https://github.com/mosra/magnum.git
git clone https://github.com/mosra/magnum-integration.git integration
git clone https://github.com/ocornut/imgui.git
remove-item CMakeLists.txt
invoke-webrequest -outfile CMakeLists.txt https://gist.github.com/alanjfs/77282b740a6e7852046a4870ecc0b3d6/raw/c1a1b02f4dbdb4a6c48b36e4a551ec34732a10e6/CMakeLists.txt
invoke-webrequest -outfile sdl.zip https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip
expand-archive .\sdl.zip -destinationpath .
mkdir build
cd build
cmake .. -DWITH_IMGUI=ON
cmake --build . --config Release
.\Release\bin\MyApplication.exe

Troubleshooting

'invoke-webrequest' is not recognized as an internal or external command

This is a PowerShell command, try running powershell.exe from your command-line, before running the above commands.

cmake_minimum_required(VERSION 3.4)
project(MyApplication)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/SDL2-2.0.10" ${CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/imgui" ${CMAKE_PREFIX_PATH})
set(WITH_SDL2APPLICATION ON CACHE BOOL "" FORCE)
add_subdirectory(corrade EXCLUDE_FROM_ALL)
add_subdirectory(magnum EXCLUDE_FROM_ALL)
add_subdirectory(integration)
add_subdirectory(src)
find_package(Magnum
REQUIRED
GL
Sdl2Application
)
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
add_executable(MyApplication MyApplication.cpp)
target_link_libraries(
MyApplication
PRIVATE
Magnum::Application
Magnum::GL
Magnum::Magnum
)
# Make the executable a default target to build & run in Visual Studio
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT MyApplication)
if(CORRADE_TARGET_WINDOWS)
# Copy any outputs from this target to ./install dir
install(TARGETS MyApplication DESTINATION install)
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment