#
# Build PhysXCooking
#

SET(PHYSX_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../../)

SET(LL_SOURCE_DIR ${PHYSX_SOURCE_DIR}/PhysXCooking/src)

IF(DEFINED PX_STATIC_LIBRARIES)
	SET(PHYSXCOOKING_LIBTYPE STATIC)
ELSE()
	SET(PHYSXCOOKING_LIBTYPE SHARED)	
ENDIF()

SET(PHYSXCOOKING_COMPILE_DEFS
	# Common to all configurations
	${PHYSX_LINUX_COMPILE_DEFS};PX_COOKING;
)

IF(DEFINED PX_STATIC_LIBRARIES)
	LIST(APPEND PHYSXCOOKING_COMPILE_DEFS
		PX_PHYSX_STATIC_LIB;
	)
ELSE()
	LIST(APPEND PHYSXCOOKING_COMPILE_DEFS
		PX_PHYSX_LOADER_EXPORTS;PX_PHYSX_COOKING_EXPORTS;PX_PHYSX_CORE_EXPORTS;
	)
ENDIF()

if(${CMAKE_BUILD_TYPE_LOWERCASE} STREQUAL "debug")
	LIST(APPEND PHYSXCOOKING_COMPILE_DEFS
		${PHYSX_LINUX_DEBUG_COMPILE_DEFS};
	)
elseif(${CMAKE_BUILD_TYPE_LOWERCASE} STREQUAL "checked")
	LIST(APPEND PHYSXCOOKING_COMPILE_DEFS
		${PHYSX_LINUX_CHECKED_COMPILE_DEFS};
	)
elseif(${CMAKE_BUILD_TYPE_LOWERCASE} STREQUAL "profile")
	LIST(APPEND PHYSXCOOKING_COMPILE_DEFS
		${PHYSX_LINUX_PROFILE_COMPILE_DEFS};
	)
elseif(${CMAKE_BUILD_TYPE_LOWERCASE} STREQUAL "release")
	LIST(APPEND PHYSXCOOKING_COMPILE_DEFS
		${PHYSX_LINUX_RELEASE_COMPILE_DEFS}
	)
else(${CMAKE_BUILD_TYPE_LOWERCASE} STREQUAL "debug")
	MESSAGE(FATAL_ERROR "Unknown configuration ${CMAKE_BUILD_TYPE}")
endif(${CMAKE_BUILD_TYPE_LOWERCASE} STREQUAL "debug")


SET(PHYSXCOOKING_PLATFORM_SRC_FILES 
)

# include common PhysXCooking settings
INCLUDE(../common/PhysXCooking.cmake)

SET_TARGET_PROPERTIES(PhysXCooking PROPERTIES 
	LINK_FLAGS_DEBUG ""
	LINK_FLAGS_CHECKED ""
	LINK_FLAGS_PROFILE ""
	LINK_FLAGS_RELEASE ""
)

# enable -fPIC so we can link static libs with the editor
SET_TARGET_PROPERTIES(PhysXCooking PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

IF(DEFINED PX_STATIC_LIBRARIES)
	TARGET_LINK_LIBRARIES(PhysXCooking PUBLIC PhysXCommon PhysXExtensions PxFoundation)
ELSE()
	TARGET_LINK_LIBRARIES(PhysXCooking PUBLIC PhysXCommon PhysXExtensions PxFoundation rt)
ENDIF()
