-
Notifications
You must be signed in to change notification settings - Fork 1
Build Setup
MicroEngine source is configured to support a handful of environments, allowing users freedom in their development tools of choice. (If you are an advanced C++/CMake programmer, you can set it up for any custom environment too.) Only x64 (64-bit) builds are supported; a 32-bit build may work but may exhibit undefined behaviour. For more information on CMake and C++, visit this page.
Global Requirements:
- x64 (64-bit) CPU and OS
- C++17 compiler & tools (linker and runtime)
- CMake 3.13+
- Collaborators/Contributors:
-
Editor Config support in your editor / IDE
- VS Code (Also available through "Extensions" within the editor)
- Notepad++
- Code::Blocks
-
clang-format (standalone executable linked at the bottom of the page; rename as
clang-format.exe
and place inTools
)- Visual Studio 2019: Formatting > General > Enable ClangFormat
- VS Code
-
Editor Config support in your editor / IDE
- Download and install CMake 3.13+ for your OS (
cmake-gui
is the GUI wrapper on Linux) - Clone the repository:
git clone https://github.com/<repo-url>
to a location on your local storage- Collaborators:
git checkout dev
(dev
is your effectivemaster
)
- Collaborators:
- (Optional) Manually initialise git submodules:
git submodule update --init --recursive
(CMake scripts will do this even if you don't)
Note: Downloading an archive of the repo - instead of cloning - will not work without manual submodule updation!
- Visual Studio Solution
- Visual Studio CMake
- Visual Studio Code / Code::Blocks (or any text editor) with MinGW
- Linux
- Adding Sources
There are several options, listed in order of increasing complexity (of pre-build configuration).
- Visual Studio 2017+
- Windows SDK
- (Optional) LLVM compiler toolchain and LLVM Visual Studio plugin
- Open CMake and configure it:
- Click "Browse Source" and select
{repo_path}
- Put
{repo_path}/out
(or a subdirectory) as "Where to build the binaries:" - Click Configure and select your generator:
- If using VS 2019: "Visual Studio 16 2019"
- If using VS 2017: "Visual Studio 15 2017"
- If using VS 2017, enter "x64" as the "platform" (Win32 is not supported!)
- (Optional): If using Clang/LLVM, set "LLVM" as the "platform toolset"
- Click Finish (first-time configuration will take some time, successive ones will be much faster)
- After configuring is complete, ensure
UPDATE_SUBMODULES
is checked and click "Generate" - Click Open Project
- Click "Browse Source" and select
- In the IDE:
- (Optional) Choose your build configuration:
Debug
/RelWithDebInfo
are relevant on Windows (the latter will build optimised - and hard-to-debug - binaries) - Build
ALL_BUILD
: this will also auto-rerun CMake when it is out-of-date - Select
MicroEngine
as the "Startup Project" in solution explorer - Debug/Run the built executable (located in
{repo_path}/Build
)
- (Optional) Choose your build configuration:
Note: The generated solution file can be found in the path you chose as "Where to build the binaries" in CMake: it should be called
{project_name}.sln
. Do not manually edit/delete any files in there.
- Visual Studio 2019+
- C++ CMake tools for Windows
- Windows SDK
- (Optional) LLVM compiler toolchain and Clang Compiler for Windows
- Open Visual Studio, select "Open Folder", and pick
{repo_dir}
- (Optional) Right-click
CMakeLists.txt
and select "CMake Settings for {project_name}":- Set the toolset to
clang_cl_x64
(if using LLVM/CLang) - Add another build configuration for
RelWithDebInfo
- Set the toolset to
- Click Project -> Generate Cache
- Click Build -> Build All
- To Debug: Click the arrow next to "Select Startup Item" (the green play button) and pick the name of the executable; click the button / press F5
-
MinGW x64 (with
mingw32-make 4+
andg++ 7+
)- Note: make sure to select
x86_64
as the "Architecture", and to add/path/to/mingw/bin
to your environment'sPATH
(for CMake to find the compiler)!
- Note: make sure to select
- (VSCode):
- (Optional) Microsoft C/C++ extension
Note:
mingw
(32-bit, installs viamingw-get
/ MinGW Installation Manager etc) is not supported! You must usemingw64
to successfully compile and linkMicroEngine
.
- Open CMake and configure it:
- Click "Browse Source" and select
{repo_path}
- Put
{repo_path}/out/Debug
(or a subdirectory) as "Where to build the binaries:" - Click Configure and select the "MinGW MakeFiles" generator (or "CodeBlocks MinGW MakeFiles" if using CB)
- Click Finish (first-time configuration will take some time, successive ones will be much faster)
- After configuring is complete, ensure
UPDATE_SUBMODULES
is checked and click "Generate" - (Optional) Create another CMake build directory
{repo_path}/out/RelWithDebInfo
and repeat, but withCMAKE_BUILD_TYPE
set toRelWithDebInfo
- Click "Browse Source" and select
- Build and debug/run
MicroEngine
:- Via the terminal: navigate to the CMake build directory, then:
- Type
mingw32-make
and press enter (pass-jN
to useN
threads) - Navigate to
MircoEngine
's build directory ({repo_path}/Build
) - To Run: type
./{exe-filename}
and press Enter - To Debug: type
gdb ./{exe-filename}
and press Enter, at the gdb console typerun
and press Enter
- Type
- If using Code::Blocks:
- Open the generated project
- Build
ALL_BUILD
- Select
MicroEngine
as the debugging target - Set
path/to/gdb.exe
as the debugger - Debug/Run the target
- If using VSCode with the C/C++ plugin:
- Click Terminal and "Configure Default Build Task" and "Configure Task" to automate building and debugging without having to enter the terminal
- Via the terminal: navigate to the CMake build directory, then:
- All SFML dependencies/libraries installed to standard paths
-
g++ 7+
,make
- (Optional)
clang
,llvm
,ninja
,codeblocks
- Open CMake and configure it:
- Click "Browse Source" and select
{repo_path}
- Put
{repo_path}/out
(or a subdirectory) as "Where to build the binaries:" - Click Configure and select the generator:
-
make
: Select "Unix Makefiles" -
ninja
: Select "Ninja" -
codeblocks
: Select "CodeBlocks Unix Makefiles" / "CodeBlocks Ninja" - (Optional): Select "Specify Native Compilers" and provide paths to
clang
if using it - Click Finish (first-time configuration will take some time, successive ones will be much faster)
- After configuring is complete, ensure
UPDATE_SUBMODULES
is checked and click "Generate" - (Optional) Create another CMake build directory
{repo_path}/out/RelWithDebInfo
and repeat, but withCMAKE_BUILD_TYPE
set toRelWithDebInfo
-
- Click "Browse Source" and select
- Build and debug/run the executable:
- Via the terminal: navigate to the CMake build directory, then:
- Type
ninja
/make -j{threads}
and press enter - Navigate to
MircoEngine
's build directory ({repo_path}/Build
) - To Run: type
./{exe-filename}
and press Enter - To Debug: type
gdb ./{exe-filename}
and press Enter, at the gdb console typerun
and press Enter
- Type
- If using Code::Blocks:
- Open the generated project
- Build
ALL_BUILD
- Select
MicroEngine
as the debugging target - Debug/Run the target
- Via the terminal: navigate to the CMake build directory, then:
Note: Ensure to delete everything in
Build
exceptResources
, if and when changing build environments on the same{repo_path}
.
- Do not add files to a project/solution, they will be removed when the next CMake generation gets triggered!
-
Do add the file paths to
Source/Source.cmake
and buildZERO_CHECK
from the IDE to regenerate CMake - To manually regenerate CMake:
- Open CMake
- Click "Browse Build" and select the output directory previously chosen; CMake will detect and auto-load everything else
- Click Generate
- Run
clang-format
on all changes/new files
- To start from scratch, delete
{repo_path}/{out}
and everything in{repo_path}/Build
exceptResources
- Restore mistakenly deleted
Resources
via (running from{repo_path}
):git reset -- Build/Resources
git checkout Build/Resources
- To reset your changes to a remote branch:
git reset --hard origin/{branch}
- To amend the
HEAD
commit:git commit --amend
- In VS Code open a terminal and navigate to the directory where CMake built the project:
cd {build path}
- Build the project using:
mingw32-make -j{threads}
- Or, use
Tools/build.sh
(instructions in the script)
- This creates
{executable}.exe
in theBuild
directory - Navigate to the
Build
directory withcd; cd {repo path}/Build;
- Execute:
./{executable}.exe
to run the game