2012-03-05 20:07:26 -05:00
|
|
|
# - Find Irrlicht
|
|
|
|
# Find the Irrlicht includes and libraries
|
|
|
|
#
|
|
|
|
# Following variables are provided:
|
|
|
|
# IRRLICHT_FOUND
|
|
|
|
# True if Irrlicht has been found
|
|
|
|
# IRRLICHT_DIR
|
|
|
|
# Path to Irrlicht
|
|
|
|
# IRRLICHT_INCLUDE_DIRS
|
|
|
|
# The include directories of Irrlicht
|
|
|
|
# IRRLICHT_LIBRARIES
|
|
|
|
# Irrlicht library list
|
|
|
|
|
|
|
|
set(IRRLICHT_DIR "" CACHE PATH "Path to Irrlicht")
|
|
|
|
|
|
|
|
# Find include directory and library
|
|
|
|
find_path(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
|
2012-03-15 08:49:44 -04:00
|
|
|
PATHS ${IRRLICHT_DIR}
|
|
|
|
/Library/Frameworks/IrrFramework.framework/Versions/A/Headers/
|
|
|
|
${PROJECT_SOURCE_DIR}/dependencies/include/irrlicht
|
2012-03-06 16:18:32 -05:00
|
|
|
PATH_SUFFIXES include irrlicht)
|
2012-03-05 20:07:26 -05:00
|
|
|
|
|
|
|
if(APPLE)
|
2012-03-15 08:50:15 -04:00
|
|
|
find_library(IRRLICHT_LIBRARY NAMES IrrFramework PATHS /Library/Frameworks/IrrFramework.framework)
|
2012-03-05 20:07:26 -05:00
|
|
|
else()
|
2012-03-15 08:50:15 -04:00
|
|
|
find_library(IRRLICHT_LIBRARY NAMES Irrlicht libIrrlicht
|
|
|
|
PATHS ${IRRLICHT_DIR}/lib/Linux ${PROJECT_SOURCE_DIR}/dependencies/lib ${PROJECT_SOURCE_DIR})
|
2012-03-05 20:07:26 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Determine Irrlicht version
|
|
|
|
if(EXISTS ${IRRLICHT_INCLUDE_DIR}/IrrCompileConfig.h)
|
|
|
|
file(STRINGS ${IRRLICHT_INCLUDE_DIR}/IrrCompileConfig.h IRRLICHT_COMPILE_CONFIG REGEX IRRLICHT_VERSION)
|
|
|
|
string(REGEX MATCH "IRRLICHT_VERSION_MAJOR ([0-9]+)" _tmp ${IRRLICHT_COMPILE_CONFIG})
|
|
|
|
set(IRRLICHT_VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
string(REGEX MATCH "IRRLICHT_VERSION_MINOR ([0-9]+)" _tmp ${IRRLICHT_COMPILE_CONFIG})
|
|
|
|
set(IRRLICHT_VERSION_MINOR ${CMAKE_MATCH_1})
|
|
|
|
string(REGEX MATCH "IRRLICHT_VERSION_REVISION ([0-9]+)" _tmp ${IRRLICHT_COMPILE_CONFIG})
|
|
|
|
set(IRRLICHT_VERSION_REVISION ${CMAKE_MATCH_1})
|
|
|
|
set(IRRLICHT_VERSION "${IRRLICHT_VERSION_MAJOR}.${IRRLICHT_VERSION_MINOR}.${IRRLICHT_VERSION_REVISION}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(Irrlicht
|
|
|
|
REQUIRED_VARS IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR
|
|
|
|
VERSION_VAR IRRLICHT_VERSION)
|
|
|
|
|
2012-03-15 08:49:44 -04:00
|
|
|
# STK uses Irrlicht/OpenGL on all platforms
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
|
2012-03-05 20:07:26 -05:00
|
|
|
# Publish variables
|
2012-03-15 08:49:44 -04:00
|
|
|
set(IRRLICHT_INCLUDE_DIRS ${IRRLICHT_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
|
|
|
|
set(IRRLICHT_LIBRARIES ${IRRLICHT_LIBRARY} ${OPENGL_LIBRARIES})
|
2012-03-05 20:07:26 -05:00
|
|
|
mark_as_advanced(IRRLICHT_INCLUDE_DIR IRRLICHT_LIBRARY)
|
2012-03-15 08:49:44 -04:00
|
|
|
|
|
|
|
# Check if Xxf86vm is required when building for platforms using X11
|
|
|
|
if(UNIX AND NOT APPLE AND NOT CYGWIN)
|
|
|
|
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
|
|
|
|
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
|
|
|
|
|
|
|
|
set(IRRLICHT_SNIPPET "#include <irrlicht.h>
|
|
|
|
int main() { irr::createDevice(irr::video::EDT_NULL)\; return 0\; }")
|
|
|
|
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${IRRLICHT_INCLUDE_DIR})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${IRRLICHT_LIBRARIES})
|
|
|
|
check_cxx_source_compiles(${IRRLICHT_SNIPPET} IRRLICHT_WITHOUT_XF86VM)
|
|
|
|
|
2012-03-15 16:27:44 -04:00
|
|
|
# If it did not work without Xxf86vm library try with it again
|
2012-03-15 08:49:44 -04:00
|
|
|
if(NOT IRRLICHT_WITHOUT_XF86VM)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${IRRLICHT_LIBRARIES} ${IRRLICHT_XF86VM_LIBRARY})
|
|
|
|
check_cxx_source_compiles(${IRRLICHT_SNIPPET} IRRLICHT_WITH_XF86VM)
|
|
|
|
|
2012-03-15 16:27:44 -04:00
|
|
|
if(NOT IRRLICHT_WITH_XF86VM)
|
2012-03-15 08:49:44 -04:00
|
|
|
message(WARNING "Irrlicht does not compile with and without Xxf86vm")
|
|
|
|
endif()
|
2012-03-15 16:27:44 -04:00
|
|
|
|
|
|
|
# Add Xxf86vm nevertheless as tests might fail under strange circumstances
|
|
|
|
set(IRRLICHT_LIBRARIES ${IRRLICHT_LIBRARIES} ${IRRLICHT_XF86VM_LIBRARY})
|
2012-03-15 08:49:44 -04:00
|
|
|
endif()
|
|
|
|
endif()
|