From b45c8cd17693f81ccfa3ac062ea50205bb8ea20f Mon Sep 17 00:00:00 2001 From: Marek Wydmuch Date: Tue, 12 Dec 2023 01:19:15 +0100 Subject: [PATCH] Replace assamble scripts with cmake target --- CMakeLists.txt | 1 + src/lib_python/CMakeLists.txt | 38 +++++++++++++++++++++++----------- src/vizdoom/src/CMakeLists.txt | 10 ++++----- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18f8f55b2..f7a8a5584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/lib_python/CMakeLists.txt b/src/lib_python/CMakeLists.txt index 2ad84d8f3..0ef3f2d84 100644 --- a/src/lib_python/CMakeLists.txt +++ b/src/lib_python/CMakeLists.txt @@ -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 $ ${VIZDOOM_PYTHON_PACKAGE_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${VIZDOOM_PYTHON_SRC_DIR}/__init__.py ${VIZDOOM_PYTHON_PACKAGE_DIR} + COMMAND ${CMAKE_COMMAND} -E copy $ ${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) diff --git a/src/vizdoom/src/CMakeLists.txt b/src/vizdoom/src/CMakeLists.txt index bb7042cb9..4603b5592 100644 --- a/src/vizdoom/src/CMakeLists.txt +++ b/src/vizdoom/src/CMakeLists.txt @@ -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 )