Skip to content

Commit

Permalink
Fixed building on Linux and CMake's policy warning
Browse files Browse the repository at this point in the history
Former-commit-id: a80a37a
  • Loading branch information
mwydmuch committed Sep 27, 2017
1 parent af8f83a commit ca599e6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ImportExecutables.cmake
**/CMakeScripts
**/cmake_install.cmake
**/install_manifest.txt
*.cbp

# MSVC
*.sln
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ option(BUILD_JAVA "Build ViZDoom Java binding." OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden")
if (COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0023 NEW)
endif (COMMAND cmake_policy)

# Add cmake_modules to module
Expand Down Expand Up @@ -191,7 +192,7 @@ if (BUILD_PYTHON OR BUILD_PYTHON3)
${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomPythonModule.cpp)

pybind11_add_module(libvizdoom_python ${VIZDOOM_PYTHON_SOURCES})
target_link_libraries(libvizdoom_python ${VIZDOOM_PYTHON_LIBS} libvizdoom_static)
target_link_libraries(libvizdoom_python PRIVATE ${VIZDOOM_PYTHON_LIBS} libvizdoom_static)
set_target_properties(libvizdoom_python
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${VIZDOOM_PYTHON_OUTPUT_DIR}
Expand All @@ -206,7 +207,7 @@ if (BUILD_PYTHON OR BUILD_PYTHON3)
if (UNIX)
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_PYTHON2_OUTPUT_DIR}/pip_package")
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)
Expand Down Expand Up @@ -250,7 +251,7 @@ if (BUILD_LUA)
${VIZDOOM_LUA_SRC_DIR}/ViZDoomLuaModule.cpp)

add_library(libvizdoom_lua SHARED ${VIZDOOM_LUA_SOURCES})
target_link_libraries(libvizdoom_lua ${VIZDOOM_LUA_LIBS} libvizdoom_static)
target_link_libraries(libvizdoom_lua PRIVATE ${VIZDOOM_LUA_LIBS} libvizdoom_static)
set_target_properties(libvizdoom_lua
PROPERTIES
PREFIX ""
Expand Down Expand Up @@ -320,7 +321,7 @@ if (BUILD_JAVA)
${VIZDOOM_JAVA_SRC_DIR}/ViZDoomGameJava.cpp)

add_library(libvizdoom_java SHARED ${VIZDOOM_JAVA_SOURCES})
target_link_libraries(libvizdoom_java ${VIZDOOM_JAVA_LIBS} libvizdoom_static)
target_link_libraries(libvizdoom_java PRIVATE ${VIZDOOM_JAVA_LIBS} libvizdoom_static)

set_target_properties(libvizdoom_java
PROPERTIES
Expand Down
9 changes: 5 additions & 4 deletions scripts/assemble_luarocks_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ fi

rm -rf ${PACKAGE_DEST_PATH}
rm -rf ${SHARED_PACKAGE_DEST_PATH}
mkdir ${PACKAGE_DEST_PATH}
mkdir ${SHARED_PACKAGE_DEST_PATH}
mkdir -p ${PACKAGE_DEST_PATH}
mkdir -p ${SHARED_PACKAGE_DEST_PATH}

cp -r ${PACKAGE_SOURCE}/* ${SHARED_PACKAGE_DEST_PATH}
cp -r ${PACKAGE_SOURCE}/* ${PACKAGE_DEST_PATH}
cp ${VIZDOOM_EXEC_PATH} ${PACKAGE_DEST_PATH}
cp ${LUA_BIN_PATH} ${PACKAGE_DEST_PATH}
cp ${FREEDOOM_PATH} ${PACKAGE_DEST_PATH}
cp ${VIZDOOM_EXEC_PATH} ${PACKAGE_DEST_PATH}
cp ${VIZDOOM_PK3_PATH} ${PACKAGE_DEST_PATH}
cp ${FREEDOOM_PATH} ${PACKAGE_DEST_PATH}
mkdir -p ${SCENARIOS_DEST_DIR}
cp ${SCENARIOS_PATH}/*.wad ${SCENARIOS_DEST_DIR}
cp ${SCENARIOS_PATH}/*.cfg ${SCENARIOS_DEST_DIR}
Expand Down
13 changes: 8 additions & 5 deletions scripts/assemble_pip_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ else
fi

VIZDOOM_PK3_PATH="./bin/vizdoom.pk3"
PYTHON_BIN_PATH="$(ls ${PACKAGE_DEST_DIRECTORY}/vizdoom*.so)"
PYTHON_BIN_PATH="$(ls ${PACKAGE_DEST_DIRECTORY}/vizdoom*)"
PYTHON_BIN_EXT="${PYTHON_BIN_PATH##*.}"

FREEDOOM_PATH="./bin/freedoom2.wad"
SCENARIOS_DEST_DIR="${PACKAGE_DEST_PATH}/scenarios"
Expand All @@ -34,12 +35,14 @@ if [ ! -e ${VIZDOOM_EXEC_PATH} ] || [ ! -e ${VIZDOOM_PK3_PATH} ]; then
fi

rm -rf ${PACKAGE_DEST_PATH}
cp -r ${PACKAGE_SOURCE} ${PACKAGE_DEST_PATH}
cp ${VIZDOOM_EXEC_PATH} ${PACKAGE_DEST_PATH}
mkdir -p ${PACKAGE_DEST_PATH}

cp -r ${PACKAGE_SOURCE}/* ${PACKAGE_DEST_PATH}
cp ${PYTHON_BIN_PATH} ${PACKAGE_DEST_PATH}
mv ${PYTHON_BIN_PATH} "${PACKAGE_DEST_PATH}/vizdoom.so"
cp ${FREEDOOM_PATH} ${PACKAGE_DEST_PATH}
mv "$(ls ${PACKAGE_DEST_PATH}/vizdoom*)" "${PACKAGE_DEST_PATH}/vizdoom.${PYTHON_BIN_EXT}"
cp ${VIZDOOM_EXEC_PATH} ${PACKAGE_DEST_PATH}
cp ${VIZDOOM_PK3_PATH} ${PACKAGE_DEST_PATH}
cp ${FREEDOOM_PATH} ${PACKAGE_DEST_PATH}
mkdir -p ${SCENARIOS_DEST_DIR}
cp ${SCENARIOS_PATH}/*.wad ${SCENARIOS_DEST_DIR}
cp ${SCENARIOS_PATH}/*.cfg ${SCENARIOS_DEST_DIR}
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def run(self):
cmake_arg_list.append("-DCMAKE_BUILD_TYPE=Release")
cmake_arg_list.append("-DBUILD_PYTHON=ON")
cmake_arg_list.append("-DPYTHON_EXECUTABLE={}".format(python_executable))
cmake_arg_list.append("-DPYTHON_LIBRARY={}".format(python_library))
cmake_arg_list.append("-DPYTHON_INCLUDE_DIR={}".format(python_include_dir))
cmake_arg_list.append("-DNUMPY_INCLUDES={}".format(numpy_include_dir))
#cmake_arg_list.append("-DPYTHON_LIBRARY={}".format(python_library))
#cmake_arg_list.append("-DPYTHON_INCLUDE_DIR={}".format(python_include_dir))
#cmake_arg_list.append("-DNUMPY_INCLUDES={}".format(numpy_include_dir))
if python_version == "3":
cmake_arg_list.append("-DBUILD_PYTHON3=ON")
else:
Expand Down
2 changes: 0 additions & 2 deletions src/lib_python/ViZDoomPythonModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <pybind11/pybind11.h>
#include <vector>

namespace pyb = pybind11;

using namespace vizdoom;

/* C++ code to expose DoomGame library via Python */
Expand Down

0 comments on commit ca599e6

Please sign in to comment.