Skip to content

Commit

Permalink
Improved CMakeLists.txt and scripts for Windows
Browse files Browse the repository at this point in the history
Former-commit-id: bd6a13b
  • Loading branch information
mwydmuch committed Oct 22, 2017
1 parent 89e4b15 commit b8f3a45
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 18 deletions.
39 changes: 28 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ set_target_properties(libvizdoom_static libvizdoom_shared

set_target_properties(libvizdoom_static
PROPERTIES
PROJECT_LABEL "Static library")
PROJECT_LABEL "static library")

set_target_properties(libvizdoom_shared
PROPERTIES
PROJECT_LABEL "Shared library")
PROJECT_LABEL "shared library")

if (BUILD_ENGINE)
add_subdirectory(${VIZDOOM_SRC_DIR}/vizdoom)
Expand All @@ -170,7 +170,7 @@ endif ()
#-----------------------------------------------------------------------------------------------------------------------

if (BUILD_PYTHON OR BUILD_PYTHON3)

if (BUILD_PYTHON3)
find_package(PythonInterp 3 REQUIRED)
else ()
Expand Down Expand Up @@ -214,17 +214,27 @@ if (BUILD_PYTHON OR BUILD_PYTHON3)
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${VIZDOOM_PYTHON_OUTPUT_DIR}
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${VIZDOOM_PYTHON_OUTPUT_DIR}
OUTPUT_NAME vizdoom
PROJECT_LABEL "Python binding")
PROJECT_LABEL "python${_PYTHON_VERSION} binding")
add_dependencies(libvizdoom_python pybind11)

if (UNIX AND BUILD_ENGINE AND DOWNLOAD_FREEDOOM)
add_custom_target(python_pip_package ALL
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/assemble_pip_package.sh ${_PYTHON_VERSION}
COMMENT "Assembling pip package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/pip_package")

# vizdoom, vizdoom.pk3 and freedoom2.wad are needed to assemble the package
add_dependencies(python_pip_package libvizdoom_python vizdoom pk3 freedoom2)
endif ()

if (WIN32 AND DOWNLOAD_FREEDOOM)
add_custom_target(python_pip_package ALL
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/assemble_pip_package.bat ${_PYTHON_VERSION}
COMMENT "Assembling pip package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/pip_package")
endif ()

set_target_properties(python_pip_package
PROPERTIES
PROJECT_LABEL "pip package")

# vizdoom, vizdoom.pk3 and freedoom2.wad are needed to assemble the package
add_dependencies(python_pip_package libvizdoom_python vizdoom pk3 freedoom2)

endif ()

Expand Down Expand Up @@ -270,12 +280,13 @@ if (BUILD_LUA)
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${VIZDOOM_LUA_OUTPUT_DIR}
OUTPUT_NAME vizdoom
PROJECT_LABEL "Lua binding")
add_dependencies(libvizdoom_python luabind)
add_dependencies(libvizdoom_lua luabind)

if (UNIX AND BUILD_ENGINE AND DOWNLOAD_FREEDOOM)
add_custom_target(luarocks_package ALL
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/assemble_luarocks_package.sh
COMMENT "Assembling luarocks package in ${VIZDOOM_LUA_OUTPUT_DIR}/luarocks_package")
COMMENT "Assembling luarocks package in ${VIZDOOM_LUA_OUTPUT_DIR}/luarocks_package"
PROJECT_LABEL "Luarocks package")

# vizdoom, vizdoom.pk3 and freedoom2.wad are needed to assemble the package
add_dependencies(luarocks_package libvizdoom_lua vizdoom pk3 freedoom2)
Expand Down Expand Up @@ -351,7 +362,7 @@ if (BUILD_JAVA)
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${VIZDOOM_JAVA_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${VIZDOOM_JAVA_OUTPUT_DIR}
OUTPUT_NAME vizdoom
PROJECT_LABEL "Java binding")
PROJECT_LABEL "java binding")

add_jar(libvizdoom_java_classes
${VIZDOOM_JAVA_CLASSES_DIR}/enums/AutomapMode.java
Expand All @@ -372,7 +383,7 @@ if (BUILD_JAVA)
${VIZDOOM_JAVA_CLASSES_DIR}/DoomGame.java
OUTPUT_DIR ${VIZDOOM_JAVA_OUTPUT_DIR}
OUTPUT_NAME vizdoom
PROJECT_LABEL "ViZDoom Java classes")
PROJECT_LABEL "java classes")

endif ()

Expand All @@ -385,3 +396,9 @@ if (UNIX AND DOWNLOAD_FREEDOOM)
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/download_freedoom.sh
COMMENT "Downloading freedoom2.wad")
endif ()

if (WIN32 AND DOWNLOAD_FREEDOOM)
add_custom_target(freedoom2 ALL
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/download_freedoom.bat
COMMENT "Downloading freedoom2.wad")
endif ()
74 changes: 74 additions & 0 deletions cmake_all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@echo off
setlocal enabledelayedexpansion

:: %%% Set build config
set PYTHON=ON
set LUA=OFF
set JAVA=OFF
set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 Win64

:: %%% Set path to folder with libraries and clone/copy https://github.com/mwydmuch/ViZDoomWinDepBin to it.
set LIB_DIR=C:\libs

:: API dependencies
:: %%% Set path to Boost library
set BOOST_ROOT=%LIB_DIR%\boost
set BOOST_INCLUDEDIR=%BOOST_ROOT%
set BOOST_LIBRARYDIR=%BOOST_ROOT%\libs

:: Python
:: %%% Set Python version (27, 34, 35, 36) or change paths for other distribusions
set PYTHON_VERSION=36
set PYTHON_BIG_VERSION=%PYTHON_VERSION:~0,1%
set PYTHON_EXECUTABLE=C:\Python%PYTHON_VERSION%\python.exe
set PYTHON_INCLUDE_DIR=C:\Python%PYTHON_VERSION%\include
set PYTHON_LIBRARY=C:\Python%PYTHON_VERSION%\libs\python%PYTHON_VERSION%.lib
set NUMPY_INCLUDES=C:\Python%PYTHON_VERSION%\Lib\site-packages\numpy\core\include


:: Rest of the script
::--------------------------------------------------------------------------------------------------------------------

:: Lua
set LUA_INCLUDE_DIR=%LIB_DIR%\lua\include
set LUA_LIBRARY=%LIB_DIR%\lua\lua5.1.lib

:: ZDoom dependencies
set FMOD_INCLUDE_DIR=%LIB_DIR%\fmod\inc
set FMOD_LIBRARY=%LIB_DIR%\fmod\lib\fmodex64.lib
set MPG123_INCLUDE_DIR=%LIB_DIR%\libmpg123
set MPG123_LIBRARIES=%LIB_DIR%\libmpg123\libmpg123-0.lib
set SNDFILE_INCLUDE_DIR=%LIB_DIR%\libsndfile\include
set SNDFILE_LIBRARY=%LIB_DIR%\libsndfile\lib\libsndfile-1.lib
set OPENAL_INCLUDE_DIR=%LIB_DIR%\openal\include
set OPENAL_LIBRARY=%LIB_DIR%\openal\libs\openal32.lib
set YASM_PATH=%LIB_DIR%\yasm.exe

:: CMake command
set CMAKE_CMD=-G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=Release -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" -DBOOST_ROOT="%BOOST_ROOT%" -DFMOD_INCLUDE_DIR="%FMOD_INCLUDE_DIR%" -DFMOD_LIBRARY="%FMOD_LIBRARY%" -DMPG123_INCLUDE_DIR="%MPG123_INCLUDE_DIR%" -DMPG123_LIBRARIES="%MPG123_LIBRARIES%" -DSNDFILE_INCLUDE_DIR="%SNDFILE_INCLUDE_DIR%" -DSNDFILE_LIBRARY="%SNDFILE_LIBRARY%" -DOPENAL_INCLUDE_DIR="%OPENAL_INCLUDE_DIR%" -DOPENAL_LIBRARY="%OPENAL_LIBRARY%" -DNO_ASM=ON
:: -DYASM_PATH="%YASM_PATH%"

if "%LUA%"=="ON" (
set CMAKE_CMD=!CMAKE_CMD! -DBUILD_LUA=ON -DLUA_INCLUDE_DIR="%LUA_INCLUDE_DIR%" -DLUA_LIBRARY="%LUA_LIBRARY%"
)

if "%JAVA%"=="ON" (
set CMAKE_CMD=!CMAKE_CMD! -DBUILD_JAVA=ON
)

if "%PYTHON%"=="ON" (
if %PYTHON_BIG_VERSION% equ 2 (
set CMAKE_CMD=!CMAKE_CMD! -DBUILD_PYTHON=ON
)

if %PYTHON_BIG_VERSION% equ 3 (
set CMAKE_CMD=!CMAKE_CMD! -DBUILD_PYTHON3=ON
)

set CMAKE_CMD=!CMAKE_CMD! -DPYTHON_EXECUTABLE="%PYTHON_EXECUTABLE%" -DPYTHON_INCLUDE_DIR="%PYTHON_INCLUDE_DIR%" -DPYTHON_LIBRARY="%PYTHON_LIBRARY%" -DNUMPY_INCLUDES=%NUMPY_INCLUDES%
)

del CMakeCache.txt
echo cmake !CMAKE_CMD!
cmake !CMAKE_CMD!

10 changes: 10 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Changes in 1.1.5

#### Labels
- Added appending "Dead" prefix to label's name when actor is a corpse.

#### Windows specific
- Fixed problem with building on Windows 8.1 and 10.
- Added scripts for downloading freedoom2.wad and assembling Python packages.


## Changes in 1.1.4

#### Automap
Expand Down
54 changes: 54 additions & 0 deletions scripts/assemble_pip_package.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
:: @echo off
setlocal enabledelayedexpansion

set PYTHON_VERSION=%1

set BIN_PATH=.\bin
set PACKAGE_DEST_DIRECTORY=%BIN_PATH%\python%PYTHON_VERSION%
set PACKAGE_DEST_PATH=%PACKAGE_DEST_DIRECTORY%\pip_package
set PACKAGE_SOURCE=.\src\lib_python\src_python

set VIZDOOM_EXEC_PATH=%BIN_PATH%\vizdoom.exe
set VIZDOOM_PK3_PATH=%BIN_PATH%\vizdoom.pk3
dir dir .\bin\python3.6\vizdoom*.pyd /b /s > %PACKAGE_DEST_DIRECTORY%\tmp.txt
set /p PYTHON_BIN_PATH=<%PACKAGE_DEST_DIRECTORY%\tmp.txt
del %PACKAGE_DEST_DIRECTORY%\tmp.txt
set PYTHON_BIN_DEST_PATH=%PACKAGE_DEST_PATH%\vizdoom.pyd

set FREEDOOM_PATH=%BIN_PATH%\freedoom2.wad
set SCENARIOS_DEST_DIR=%PACKAGE_DEST_PATH%\scenarios
set SCENARIOS_PATH=.\scenarios
set EXAMPLES_DEST_DIR=%PACKAGE_DEST_PATH%\examples
set EXAMPLES_PATH=".\examples\python"

if not exist "%PYTHON_BIN_PATH%" (
echo "Library for specified Python version does not exist. Aborting."
exit /B 2
)

if not exist "%VIZDOOM_EXEC_PATH%" (
echo "Required ViZDoom's resources do not exist. Aborting."
exit /B 3
)

if not exist "%VIZDOOM_PK3_PATH%" (
echo "Required ViZDoom's resources do not exist. Aborting."
exit /B 3
)

del %PACKAGE_DEST_PATH%
md %PACKAGE_DEST_PATH%

copy "%PACKAGE_SOURCE%\*" "%PACKAGE_DEST_PATH%"
copy "%PYTHON_BIN_PATH%" "%PYTHON_BIN_DEST_PATH%"
copy "%VIZDOOM_EXEC_PATH%" "%PACKAGE_DEST_PATH%"
copy "%VIZDOOM_PK3_PATH%" "%PACKAGE_DEST_PATH%"
copy "%BIN_PATH%\*.dll" "%PACKAGE_DEST_PATH%"
copy "%FREEDOOM_PATH%" "%PACKAGE_DEST_PATH%"
copy "%FREEDOOM_PATH%" "%PACKAGE_DEST_PATH%"
md "%SCENARIOS_DEST_DIR%
copy "%SCENARIOS_PATH%\*.wad" "%SCENARIOS_DEST_DIR%"
copy "%SCENARIOS_PATH%\*.cfg" "%SCENARIOS_DEST_DIR%"
md "%EXAMPLES_DEST_DIR%
copy "%EXAMPLES_PATH%\*.py" "%EXAMPLES_DEST_DIR%"
move "%SCENARIOS_DEST_DIR%\bots.cfg" "%PACKAGE_DEST_PATH%"
24 changes: 24 additions & 0 deletions scripts/download_freedoom.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
setlocal enabledelayedexpansion

:: Checks if bin/freedoom2.wad is in place if not, the zip is downloaded (if not yet present) and freedoom2.wad is extracted to bin directory.

:: Older version of freedoom
::set FREEDOOM_LINK="https://github.com/freedoom/freedoom/releases/download/v0.10.1/freedoom-0.10.1.zip"
set FREEDOOM_LINK="https://github.com/freedoom/freedoom/releases/download/v0.11.3/freedoom-0.11.3.zip"
set FREEDOOM_ARCHIVE=%FREEDOOM_LINK:~0,-1%
for %%F in (%FREEDOOM_LINK%) do set FREEDOOM_ARCHIVE=%%~nxF

set FREEDOOM_OUTFILE=".\%FREEDOOM_ARCHIVE%"
set FREEDOOM_DESTINATION_PATH=".\bin"
set FREEDOOM_DESTINATION_FILE="%FREEDOOM_DESTINATION_PATH%\freedoom2.wad"

if not exist "%FREEDOOM_DESTINATION_FILE%" (
if not exist "%FREEDOOM_DESTINATION_PATH%" md "%FREEDOOM_DESTINATION_PATH%"
if not exist "%FREEDOOM_OUTFILE%" (
powershell -command "Invoke-WebRequest '%FREEDOOM_LINK%' -OutFile '%FREEDOOM_OUTFILE%'"
)
powershell -command "Expand-Archive '%FREEDOOM_OUTFILE%' -DestinationPath '%FREEDOOM_DESTINATION_PATH%'"
copy "%FREEDOOM_DESTINATION_PATH%\%FREEDOOM_ARCHIVE:~0,-4%\freedoom2.wad" "%FREEDOOM_DESTINATION_FILE%"
rd "%FREEDOOM_DESTINATION_PATH%\%FREEDOOM_ARCHIVE:~0,-4%" /S /Q
)
16 changes: 9 additions & 7 deletions scripts/download_freedoom.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/bin/sh

# Checks if bin/freedoom2.wad is in place if not, the zip is downloaded(if not yet present) and freedoom2.wad is extracted to bin directory.
# Checks if bin/freedoom2.wad is in place if not, the zip is downloaded (if not yet present) and freedoom2.wad is extracted to bin directory.

FREEDOOM_LINK="https://github.com/freedoom/freedoom/releases/download/v0.10.1/freedoom-0.10.1.zip"
# Older version of freedoom
#FREEDOOM_LINK="https://github.com/freedoom/freedoom/releases/download/v0.10.1/freedoom-0.10.1.zip"
FREEDOOM_LINK="https://github.com/freedoom/freedoom/releases/download/v0.11.3/freedoom-0.11.3.zip"
FREEDOOM_ARCHIVE=$(echo ${FREEDOOM_LINK} | cut -d '/' -f9)
FREEDOOM_ARCHIVE_BASENAME=$(basename ${FREEDOOM_ARCHIVE} .zip)

FREEDOOM_DOWNLOAD_PATH="."
FREEDOOM_DESTINATION_PATH="./bin"

if [ ! -e "${FREEDOOM_DESTINATION_PATH}/freedoom2.wad" ]
then
if [ ! -e "${FREEDOOM_DOWNLOAD_PATH}/freedoom-0.10.1.zip" ]
then
if [ ! -e "${FREEDOOM_DESTINATION_PATH}/freedoom2.wad" ]; then
if [ ! -e "${FREEDOOM_DOWNLOAD_PATH}/${FREEDOOM_ARCHIVE}" ]; then
wget --no-check-certificate ${FREEDOOM_LINK} -P ${FREEDOOM_DOWNLOAD_PATH}
fi
unzip -j -d ${FREEDOOM_DESTINATION_PATH} ${FREEDOOM_DOWNLOAD_PATH}/freedoom-0.10.1.zip freedoom-0.10.1/freedoom2.wad
unzip -j -d ${FREEDOOM_DESTINATION_PATH} ${FREEDOOM_DOWNLOAD_PATH}/${FREEDOOM_ARCHIVE} ${FREEDOOM_ARCHIVE_BASENAME}/freedoom2.wad
fi

0 comments on commit b8f3a45

Please sign in to comment.