all repos — mgba @ f5312fef786ec0dcad9646fe272bbefd52daa5ff

mGBA Game Boy Advance Emulator

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

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