all repos — mgba @ 33295b129779e8e5e6d8b15829b5fdc0b07e421f

mGBA Game Boy Advance Emulator

src/platform/python/CMakeLists.txt (view raw)

 1find_program(PYTHON python)
 2
 3set(PY_INCLUDE_DIRS -I${CMAKE_SOURCE_DIR}/src)
 4get_property(INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
 5get_property(COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
 6foreach(INCLUDE_DIR IN LISTS INCLUDE_DIRECTORIES)
 7	list(APPEND PY_INCLUDE_DIRS -I${INCLUDE_DIR})
 8endforeach()
 9foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS FEATURE_DEFINES)
10	list(APPEND PY_COMPILE_DEFS -D${COMPILE_DEF})
11endforeach()
12
13configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
14
15add_custom_command(OUTPUT _builder.h
16                   COMMAND ${CMAKE_C_COMPILER} ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} -fno-inline -E -P -c ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h -o _builder.h
17                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h)
18add_custom_target(_builder.h ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h)
19
20add_custom_target(${BINARY_NAME}-pylib COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS}
21                  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py
22                  DEPENDS _builder.h)
23
24add_custom_command(OUTPUT ${BINARY_NAME}/__init__.py
25                   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}
26                   COMMAND ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build
27                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py
28                   DEPENDS ${BINARY_NAME}-pylib)
29
30add_custom_target(${BINARY_NAME}-py ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/__init__.py)