Saxum/extern/acgl/cmake/FindBOX2D.cmake
2014-10-20 17:31:26 +02:00

60 lines
1.8 KiB
CMake

# Find the native box2d headers
#
# BOX2D_INCLUDE_DIR - where to find box2denc.h, etc.
# BOX2D_LIBRARIES - box2d library
# BOX2D_FOUND - True if box2d found.
IF(BOX2D_FOUND)
# Already in cache, be silent
SET(BOX2D_FIND_QUIETLY TRUE)
ENDIF()
IF(BUILD_BOX2D OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
UNSET(BOX2D_INCLUDE_DIR CACHE)
UNSET(BOX2D_LIBRARIES CACHE)
ENDIF()
IF(BUILD_BOX2D)
SET(BOX2D_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/box2d")
SET(BOX2D_LIBRARIES Box2D${COMPILE_POSTFIX})
ELSE()
# Look for the header file.
IF(ACGL_GLOBAL_EXTERN_DIR)
FIND_PATH(BOX2D_INCLUDE_DIR NAMES Box2D/Box2D.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/box2d" NO_DEFAULT_PATH)
ENDIF()
IF(NOT BOX2D_INCLUDE_DIR)
FIND_PATH(BOX2D_INCLUDE_DIR NAMES Box2D/Box2D.h)
ENDIF()
# Look for the library file.
IF(ACGL_GLOBAL_EXTERN_DIR)
FIND_LIBRARY(BOX2D_LIBRARIES NAMES Box2D${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/box2d/lib" NO_DEFAULT_PATH)
ENDIF()
IF(NOT BOX2D_LIBRARIES)
FIND_LIBRARY(BOX2D_LIBRARIES NAMES Box2D${COMPILE_POSTFIX})
ENDIF()
ENDIF()
# Copy the results to the output variables.
IF(BOX2D_INCLUDE_DIR AND BOX2D_LIBRARIES)
SET(BOX2D_FOUND TRUE CACHE INTERNAL "")
ELSE()
SET(BOX2D_FOUND FALSE CACHE INTERNAL "")
ENDIF()
# Report the results.
IF(NOT BOX2D_FOUND)
SET(BOX2D_MESSAGE "box2d was not found. Make sure BOX2D_INCLUDE_DIR AND BOX2D_LIBRARIES are set correctly.")
IF(BOX2D_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${BOX2D_MESSAGE}")
ELSEIF(NOT BOX2D_FIND_QUIETLY)
MESSAGE(STATUS "${BOX2D_MESSAGE}")
ENDIF()
ELSEIF(NOT BOX2D_FIND_QUIETLY)
MESSAGE(STATUS "Looking for box2d - found")
ENDIF()
MESSAGE(STATUS "BOX2D_INCLUDE_DIR:${BOX2D_INCLUDE_DIR}")
MESSAGE(STATUS "BOX2D_LIBRARIES:${BOX2D_LIBRARIES}")