Skip to content

Commit

Permalink
Clean up of CMakeLists.txt and building system (#579)
Browse files Browse the repository at this point in the history
Replace the package assemble scripts with a cmake target
  • Loading branch information
mwydmuch authored Feb 12, 2024
1 parent 0b8e75c commit 67e2a7f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 139 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ endif()
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")

if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE INTERNAL "" FORCE)
message(STATUS "Apple Silicon detected, building for arm64")
else()
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE)
message(STATUS "Intel CPU detected, building for x86_64")
endif()
endif(APPLE)


Expand All @@ -93,6 +101,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
61 changes: 0 additions & 61 deletions scripts/assemble_pip_package.bat

This file was deleted.

60 changes: 0 additions & 60 deletions scripts/assemble_pip_package.sh

This file was deleted.

29 changes: 17 additions & 12 deletions src/lib_python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if(WIN32)
endif()

set(VIZDOOM_PYTHON_OUTPUT_DIR ${VIZDOOM_OUTPUT_DIR}/python${BUILD_PYTHON_VERSION})
set(VIZDOOM_PYTHON_PACKAGE_DIR ${VIZDOOM_PYTHON_OUTPUT_DIR}/vizdoom)
set(VIZDOOM_PYTHON_SRC_DIR ${VIZDOOM_SRC_DIR}/lib_python)
set(VIZDOOM_PYTHON_INCLUDE_DIR ${VIZDOOM_INCLUDE_DIR} ${VIZDOOM_PYTHON_SRC_DIR})

Expand Down Expand Up @@ -70,19 +71,23 @@ 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}/vizdoom")
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}/vizdoom")
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 67e2a7f

Please sign in to comment.