Skip to content

Commit

Permalink
Replace assamble scripts with cmake target
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Dec 12, 2023
1 parent 5c7a203 commit b45c8cd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ endif()
#-----------------------------------------------------------------------------------------------------------------------

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(VIZDOOM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VIZDOOM_OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(VIZDOOM_SCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
set(VIZDOOM_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
Expand Down
38 changes: 26 additions & 12 deletions src/lib_python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,33 @@ set_target_properties(libvizdoom_python
OUTPUT_NAME vizdoom
PROJECT_LABEL "python${BUILD_PYTHON_VERSION} binding")

if(UNIX)
add_custom_target(python_pip_package ALL
COMMAND ${VIZDOOM_SCRIPTS_DIR}/assemble_pip_package.sh ${BUILD_PYTHON_VERSION} ${VIZDOOM_OUTPUT_DIR} ${CMAKE_SOURCE_DIR}
COMMENT "Assembling pip package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/pip_package")
elseif(WIN32)
add_custom_target(python_pip_package ALL
COMMAND ${VIZDOOM_SCRIPTS_DIR}/assemble_pip_package.bat ${BUILD_PYTHON_VERSION} ${VIZDOOM_OUTPUT_DIR} ${CMAKE_SOURCE_DIR}
COMMENT "Assembling pip package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/pip_package")
endif()
# if(UNIX)
# add_custom_target(python_pip_package ALL
# COMMAND ${VIZDOOM_SCRIPTS_DIR}/assemble_pip_package.sh ${BUILD_PYTHON_VERSION} ${VIZDOOM_OUTPUT_DIR} ${CMAKE_SOURCE_DIR}
# COMMENT "Assembling pip package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/pip_package")
# elseif(WIN32)
# add_custom_target(python_pip_package ALL
# COMMAND ${VIZDOOM_SCRIPTS_DIR}/assemble_pip_package.bat ${BUILD_PYTHON_VERSION} ${VIZDOOM_OUTPUT_DIR} ${CMAKE_SOURCE_DIR}
# COMMENT "Assembling pip package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/pip_package")
# endif()

add_custom_target(assemble_package ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libvizdoom_python> ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${VIZDOOM_PYTHON_SRC_DIR}/__init__.py ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vizdoom> ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${VIZDOOM_OUTPUT_DIR}/vizdoom.pk3 ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${VIZDOOM_SRC_DIR}/bots.cfg ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${VIZDOOM_SRC_DIR}/freedoom2.wad ${VIZDOOM_PYTHON_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${VIZDOOM_ROOT_DIR}/scenarios ${VIZDOOM_PYTHON_PACKAGE_DIR}/scenarios
COMMAND ${CMAKE_COMMAND} -E copy_directory ${VIZDOOM_ROOT_DIR}/gym_wrapper ${VIZDOOM_PYTHON_PACKAGE_DIR}/gym_wrapper
COMMAND ${CMAKE_COMMAND} -E copy_directory ${VIZDOOM_ROOT_DIR}/gymnasium_wrapper ${VIZDOOM_PYTHON_PACKAGE_DIR}/gymnasium_wrapper
COMMENT "Assembling Python package in ${VIZDOOM_PYTHON_OUTPUT_DIR}/vizdoom"
)

set_target_properties(python_pip_package
set_target_properties(assemble_package
PROPERTIES
PROJECT_LABEL "Python module")
PROJECT_LABEL "Python package")

# vizdoom, vizdoom.pk3 are needed to assemble the package
add_dependencies(python_pip_package libvizdoom_python vizdoom pk3)
add_dependencies(assemble_package libvizdoom_python vizdoom pk3)
10 changes: 4 additions & 6 deletions src/vizdoom/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,10 @@ else( WIN32 )
add_definitions( -DNO_GTK=1 )
endif( NO_GTK )

# Non-Windows version also needs SDL except native OS X backend
if( NOT WIN32 )
find_package( SDL2 REQUIRED )
include_directories( "${SDL2_INCLUDE_DIR}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SDL2_LIBRARY}" )
endif( NOT WIN32 )
# Non-Windows version needs SDL2
find_package( SDL2 REQUIRED )
include_directories( "${SDL2_INCLUDE_DIR}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SDL2_LIBRARY}" )
endif( WIN32 )


Expand Down

0 comments on commit b45c8cd

Please sign in to comment.