Source

pygamekit / CMakeLists.txt

Full commit
# ---------------------------------------------------------
cmake_minimum_required(VERSION 2.6)

set(TargetName pygamekit)

# if (APPLE)
# 	include_directories(${OGRELITE_SOURCE_DIR}/OgreMain/include/OSX)
# 	SET(EXETYPE MACOSX_BUNDLE)
# 	SET_SOURCE_FILES_PROPERTIES( MainMenu.nib  PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
# 	SET_SOURCE_FILES_PROPERTIES(${CONTENT} PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
# 	SET (NibFile MainMenu.nib)
# endif()
# 
# set(CPP_MAIN_HDR
# 	gkApplication.h
# 	gkCollisionCameraConstraint.h
# 	gkGamePlayer.h
# 	gkGameLevel.h
# 	# gkGameNPC.h
# )
# 
# if(WIN32)
# 
# 	source_group(Main\\Source FILES ${CPP_MAIN_SRC})
# 	source_group(Main\\Header FILES ${CPP_MAIN_HDR})
# 
# 	source_group(Controllers\\Source FILES ${CPP_CONT_SRC})
# 	source_group(Controllers\\Header FILES ${CPP_CONT_HDR})
# 
# 	source_group(Datafiles FILES ${CONTENT})
# endif()


include_directories(
	${OGREKIT_INCLUDE}
)

link_libraries(
	${OGREKIT_LIB}
)


# if (APPLE)
# 
# 	add_executable(
# 		${TargetName} 
# 		MACOSX_BUNDLE
# 		MainMenu.nib
# 		${SRC} 
# 	)
# 
# else ()
# 
# 	add_executable(${TargetName} ${SRC})
# 	
# 	
# 	IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
# 		ADD_CUSTOM_COMMAND(
# 			TARGET ${TargetName} 
# 			POST_BUILD
# 			COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Maps.blend ${CMAKE_CURRENT_BINARY_DIR}/Maps.blend
# 			COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Momo.blend ${CMAKE_CURRENT_BINARY_DIR}/Momo.blend
# 			COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Rat.blend ${CMAKE_CURRENT_BINARY_DIR}/Rat.blend
# 		)
# 	ENDIF ()
# 
# endif()

######################################################################################
# Python extension builder
######################################################################################

set(PYGAMEKIT_SRC
    blendfile.pxi
    engine.pxi
    event.pxi
    gamekit.pyx
    gameobject.pxd
    gameobject.pxi
    gkmath.pxd
    input.pxd
    input.pxi
    mathutils.pxd
    mathutils.pyx
    prerequisites.pxd
    prerequisites.pxi
    scene.pxi
    transformstate.pxd
    variable.pxd
)

include(FindPythonInterp)
#include(FindPythonLibs)

if (OGREKIT_BUILD_ANDROID)
set(PYTHON_INCLUDE_PATH /home/dithi/proyectos/python-for-android/python-modules/python-lib/include/python2.6)
set(PYTHON_LIBRARIES -L/home/dithi/proyectos/python-for-android/python-modules/python-lib/lib -lpython2.6)
else()
    include(FindPythonLibs)
    if(PYTHON_LIBRARIES)
    else()
        set(PYTHON_INCLUDE_PATH /home/julio/.wine/drive_c/Python27/include)
        set(PYTHON_LIBRARIES /home/julio/.wine/drive_c/Python27/libs)
    endif()
endif()

find_program(CYTHON_EXECUTABLE cython)

# Figure out installation path
execute_process(COMMAND
  ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
  OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)

# How to Cython the .pyx file
add_custom_command(
  DEPENDS ${PYGAMEKIT_SRC}
  OUTPUT gamekit.cpp mathutils.cpp
  COMMAND ${CYTHON_EXECUTABLE} --cplus --fast-fail -o gamekit.cpp
         "${CMAKE_CURRENT_SOURCE_DIR}/gamekit.pyx"
  COMMAND ${CYTHON_EXECUTABLE} --cplus --fast-fail -o mathutils.cpp
         "${CMAKE_CURRENT_SOURCE_DIR}/mathutils.pyx"

)
list(APPEND ADDITIONAL_MAKE_CLEAN_FILES gamekit.cpp)

set(PYGAMEKIT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})

#add_custom_target(gamekit.cpp DEPENDS gamekit.pyx)
#add_dependencies(gamekit.cpp gamekit.pyx)

# Compile the extension
if (PYOGREKIT_AS_MODULE)
add_library(cython_gamekit MODULE gamekit.cpp mathutils.cpp ${PYGAMEKIT_SRC})
else()
add_executable(cython_gamekit gamekit.cpp mathutils.cpp ${PYGAMEKIT_SRC} standalone.cpp)
endif()

set_target_properties(cython_gamekit PROPERTIES
  PREFIX ""
  OUTPUT_NAME "gamekit"
  LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  COMPILE_FLAGS "-fno-permissive" )
target_link_libraries(cython_gamekit ${OGREKIT_LIB} ${PYTHON_LIBRARIES})
if (OGREKIT_BUILD_ANDROID)
  target_link_libraries(cython_gamekit log)
endif()
include_directories(${PYTHON_INCLUDE_PATH} ${OGREKIT_INCLUDE} .)

IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
  SET_TARGET_PROPERTIES(cython_gamekit PROPERTIES COMPILE_FLAGS "-fPIC")
ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )

# Install the extension
install(TARGETS cython_gamekit
  DESTINATION ${PYTHON_SITE_PACKAGES})