Adds Windows compilation instructions

This commit is contained in:
Andriy Svyryd 2019-04-20 23:24:47 -07:00 committed by Linus Probert
parent c0a4a4eb93
commit 86e6f66b58
5 changed files with 54 additions and 5 deletions

15
.gitignore vendored
View File

@ -15,3 +15,18 @@
/steam_appid.txt /steam_appid.txt
/*.so /*.so
/breakhack*.run /breakhack*.run
/config.h
/CMakeCache.txt
/CPackSourceConfig.cmake
/CPackConfig.cmake
cmake_install.cmake
/install_manifest_*
*.stamp*
*.vcxproj*
*.sln*
CMakeFiles/
Release/
Debug/
/Win32/
/breakhack.dir/
/package/

View File

@ -270,11 +270,11 @@ if (STEAM)
endif () endif ()
if (MSVC) if (MSVC)
set_target_properties(breakhack PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") set_target_properties(breakhack PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE /NODEFAULTLIB:MSVCRTD")
set_target_properties(breakhack PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE") set_target_properties(breakhack PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
set_target_properties(breakhack PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE") set_target_properties(breakhack PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(breakhack PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE") set_target_properties(breakhack PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
set_target_properties(breakhack PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") set_target_properties(breakhack PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /NODEFAULTLIB:MSVCRTD")
set_target_properties(breakhack PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") set_target_properties(breakhack PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif (MSVC) endif (MSVC)

View File

@ -57,6 +57,24 @@ cmake -DCMAKE_BUILD_TYPE=Debug .. # Build type flag is optional
make make
``` ```
Compile on Windows
------------------
1. Install [Visual Studio Community 2019](https://visualstudio.microsoft.com/vs/community/) with the "Desktop development with C++" workload
2. Install [CMake](https://cmake.org/download/)
3. Install [NSIS](https://nsis.sourceforge.io/Download)
4. Download and unzip [SDL2-devel-2.x.x-VC.zip](https://www.libsdl.org/download-2.0.php), [SDL2_image-devel-2.x.x-VC.zip](https://www.libsdl.org/projects/SDL_image/), [SDL2_mixer-devel-2.x.x-VC.zip](https://www.libsdl.org/projects/SDL_mixer/), [SDL2_ttf-devel-2.x.x-VC.zip](https://www.libsdl.org/projects/SDL_ttf/)
5. Open Developer Command Prompt for VS 2019 and run the following, substituting paths as appropriate:
```batch
cd C:\repos\breakhack
SET SDL2DIR=C:/SDL2/SDL2-2.0.9
SET SDL2MIXERDIR=C:/SDL2/SDL2_mixer-2.0.4
SET SDL2_IMAGE=C:/SDL2/SDL2_image-2.0.4
SET SDLTTFDIR=C:/SDL2/SDL2_ttf-2.0.15
cmake .
cmake --build . --target package --config Release
```
Contribute Contribute
---------- ----------
Have an idea and able to implement it? Fork and send me a pull request and Have an idea and able to implement it? Fork and send me a pull request and

View File

@ -64,6 +64,14 @@
# (To distribute this file outside of CMake, substitute the full # (To distribute this file outside of CMake, substitute the full
# License text for the above reference.) # License text for the above reference.)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(SDL2_ARCH_64 TRUE)
set(SDL2_PROCESSOR_ARCH "x64")
else()
set(SDL2_ARCH_64 FALSE)
set(SDL2_PROCESSOR_ARCH "x86")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(SDL2_SEARCH_PATHS SET(SDL2_SEARCH_PATHS
~/Library/Frameworks ~/Library/Frameworks
/Library/Frameworks /Library/Frameworks
@ -87,7 +95,7 @@ FIND_LIBRARY(SDL2_LIBRARY_TEMP
NAMES SDL2 NAMES SDL2
HINTS HINTS
$ENV{SDL2DIR} $ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib PATH_SUFFIXES lib64 lib lib/${SDL2_PROCESSOR_ARCH}
PATHS ${SDL2_SEARCH_PATHS} ${SDL2_INCLUDE_DIR}/../.. PATHS ${SDL2_SEARCH_PATHS} ${SDL2_INCLUDE_DIR}/../..
) )
@ -101,7 +109,7 @@ IF(NOT SDL2_BUILDING_LIBRARY)
NAMES SDL2main NAMES SDL2main
HINTS HINTS
$ENV{SDL2DIR} $ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib PATH_SUFFIXES lib64 lib lib/${SDL2_PROCESSOR_ARCH}
PATHS ${SDL2_SEARCH_PATHS} PATHS ${SDL2_SEARCH_PATHS}
) )
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")

View File

@ -28,6 +28,14 @@
# See the License for more information. # See the License for more information.
#============================================================================= #=============================================================================
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(SDL2_ARCH_64 TRUE)
set(SDL2_PROCESSOR_ARCH "x64")
else()
set(SDL2_ARCH_64 FALSE)
set(SDL2_PROCESSOR_ARCH "x86")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR) if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
entry initialized from old variable name") entry initialized from old variable name")
@ -48,7 +56,7 @@ find_library(SDL2_TTF_LIBRARY
HINTS HINTS
ENV SDLTTFDIR ENV SDLTTFDIR
ENV SDLDIR ENV SDLDIR
PATH_SUFFIXES lib PATH_SUFFIXES lib lib/${SDL2_PROCESSOR_ARCH}
) )
if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h") if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")