INCLUDE(PolycodeIncludes)

FIND_PACKAGE(Lua51 REQUIRED)
FIND_PACKAGE(Bullet REQUIRED)

INCLUDE_DIRECTORIES(
    ${LUA_INCLUDE_DIR}
    ${BULLET_INCLUDE_DIR}
    ${Polycode_SOURCE_DIR}/Modules/Contents/3DPhysics/Include
    Include
    ../../Contents/3DPhysics/Include
)

SET(polycode3DPhysics_SRCS
    ${CMAKE_CURRENT_SOURCE_DIR}/Source/Physics3DLUA.cpp
)

SET(polycode3DPhysics_HDRS
    ${CMAKE_CURRENT_SOURCE_DIR}/Include/Physics3DLUA.h
    ${CMAKE_CURRENT_SOURCE_DIR}/Include/Physics3DLUAWrappers.h
)

SET(CMAKE_DEBUG_POSTFIX "_d")

ADD_LIBRARY(Physics3DLua  ${polycode3DPhysics_SRCS} ${polycode3DPhysics_HDRS})

SET_SOURCE_FILES_PROPERTIES(Source/Physics3DLUA.cpp PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(Include/Physics3DLUAWrappers.h PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(Include/Physics3DLUA.h PROPERTIES GENERATED 1)
ADD_DEPENDENCIES(Physics3DLua PolycodeLuaGenerate)

SET_TARGET_PROPERTIES(Physics3DLua PROPERTIES PREFIX "")


IF(POLYCODE_INSTALL_FRAMEWORK)
    
    # install headers
    INSTALL(FILES ${polycode3DPhysics_HDRS} 
        DESTINATION Bindings/Lua/Modules/3DPhysics/include)
IF(NOT APPLE)
    INSTALL(FILES API/Physics3D.pak DESTINATION Player)
ENDIF(NOT APPLE)

    INSTALL(DIRECTORY API DESTINATION Bindings/Lua/Modules/3DPhysics)
    INSTALL(TARGETS Physics3DLua DESTINATION Bindings/Lua/Modules/3DPhysics/lib)
    
ENDIF(POLYCODE_INSTALL_FRAMEWORK)
