Patch 2793067: fix trunk with OGRE_THREAD_SUPPORT=1 on non-Windows platforms (don...
[ogre3d.git] / CMake / Dependencies.cmake
blob7fc100627d597447a3e8adaa79274facc98016b8
1 #######################################################################
2 # Find all necessary and optional OGRE dependencies
3 #######################################################################
5 # OGRE_DEPENDENCIES_DIR can be used to specify a single base
6 # folder where the required dependencies may be found.
7 set(OGRE_DEPENDENCIES_DIR "" CACHE PATH "Path to prebuilt OGRE dependencies")
8 include(FindPkgMacros)
9 getenv_path(OGRE_DEPENDENCIES_DIR)
10 set(OGRE_DEP_SEARCH_PATH 
11   ${OGRE_DEPENDENCIES_DIR}
12   ${ENV_OGRE_DEPENDENCIES_DIR}
13   "${OGRE_BINARY_DIR}/Dependencies"
14   "${OGRE_SOURCE_DIR}/Dependencies"
15   "${OGRE_BINARY_DIR}/../Dependencies"
16   "${OGRE_SOURCE_DIR}/../Dependencies"
19 # Set hardcoded path guesses for various platforms
20 if (UNIX)
21   set(OGRE_DEP_SEARCH_PATH ${OGRE_DEP_SEARCH_PATH} /usr/local)
22 endif ()
24 # give guesses as hints to the find_package calls
25 set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OGRE_DEP_SEARCH_PATH})
26 set(CMAKE_FRAMEWORK_PATH ${CMAKE_FRAMEWORK_PATH} ${OGRE_DEP_SEARCH_PATH})
28 # see if there is an install directive somewhere in the dependencies folders
29 find_file(OGRE_DEP_INSTALL_FILE OgreInstallDependencies.cmake 
30   HINTS ${OGRE_DEP_SEARCH_PATH} NO_DEFAULT_PATH)
31 mark_as_advanced(OGRE_DEP_INSTALL_FILE)
32 if (OGRE_DEP_INSTALL_FILE)
33   include(${OGRE_DEP_INSTALL_FILE})
34 endif ()
37 #######################################################################
38 # Core dependencies
39 #######################################################################
41 # Find zlib
42 find_package(ZLIB)
43 macro_log_feature(ZLIB_FOUND "zlib" "Simple data compression library" "http://www.zlib.net" TRUE "" "")
45 # Find zziplib
46 find_package(ZZip)
47 macro_log_feature(ZZip_FOUND "zziplib" "Extract data from zip archives" "http://zziplib.sourceforge.net" TRUE "" "")
49 # Find FreeImage
50 find_package(FreeImage)
51 macro_log_feature(FreeImage_FOUND "freeimage" "Support for commonly used graphics image formats" "http://freeimage.sourceforge.net" FALSE "" "")
53 # Find FreeType
54 find_package(Freetype)
55 macro_log_feature(FREETYPE_FOUND "freetype" "Portable font engine" "http://www.freetype.org" TRUE "" "")
57 # Find X11
58 if (UNIX)
59         find_package(X11)
60         macro_log_feature(X11_FOUND "X11" "X Window system" "http://www.x.org" TRUE "" "")
61         macro_log_feature(X11_Xt_FOUND "Xt" "X Toolkit" "http://www.x.org" TRUE "" "")
62         find_library(XAW_LIBRARY NAMES Xaw Xaw7 PATHS ${DEP_LIB_SEARCH_DIR} ${X11_LIB_SEARCH_PATH})
63         macro_log_feature(XAW_LIBRARY "Xaw" "X11 Athena widget set" "http://www.x.org" TRUE "" "")
64   mark_as_advanced(XAW_LIBRARY)
65 endif ()
68 #######################################################################
69 # RenderSystem dependencies
70 #######################################################################
72 # Find OpenGL
73 find_package(OpenGL)
74 macro_log_feature(OPENGL_FOUND "opengl" "Support for the OpenGL render system" "" FALSE "" "")
76 # Find OpenGLES
77 find_package(OpenGLES)
78 macro_log_feature(OPENGLES_FOUND "opengles" "Support for the OpenGL ES render system" "" FALSE "" "")
80 # Find DirectX
81 if(WIN32)
82         find_package(DirectX)
83         macro_log_feature(DirectX_FOUND "DirectX" "Support for the DirectX render system" "http://msdn.microsoft.com/en-us/directx/" FALSE "" "")
84 endif()
86 #######################################################################
87 # Additional features
88 #######################################################################
90 # Find Cg
91 find_package(Cg)
92 macro_log_feature(Cg_FOUND "cg" "C for graphics shader language" "http://developer.nvidia.com/object/cg_toolkit.html" FALSE "" "")
94 # Find Boost
95 # Prefer static linking in all cases
96 set(Boost_USE_STATIC_LIBS TRUE)
97 set(Boost_ADDITIONAL_VERSIONS "1.37.0" "1.37" "1.38.0" "1.38")
98 # Components that need linking (NB does not include heaader-only components like bind)
99 set(OGRE_BOOST_COMPONENTS thread date_time)
100 find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
101 if (!Boost_FOUND)
102         # Try dynamic
103   set(Boost_USE_STATIC_LIBS FALSE)
104         find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
105 endif()
106 # Optional Boost libs (Boost_${COMPONENT}_FOUND
107 macro_log_feature(Boost_FOUND "boost" "Boost (general)" "http://boost.org" FALSE "" "")
108 macro_log_feature(Boost_THREAD_FOUND "boost-thread" "Used for threading support" "http://boost.org" FALSE "" "")
109 macro_log_feature(Boost_DATE_TIME_FOUND "boost-date_time" "Used for threading support" "http://boost.org" FALSE "" "")
111 # POCO
112 find_package(POCO)
113 macro_log_feature(Poco_FOUND "POCO" "POCO framework" "http://pocoproject.org/" FALSE "" "")
117 #######################################################################
118 # Samples dependencies
119 #######################################################################
121 # Find CEGUI
122 find_package(CEGUI)
123 macro_log_feature(CEGUI_FOUND "CEGUI" "GUI system used for some of the samples" "http://www.cegui.org.uk" FALSE "" "")
125 # Find OIS
126 find_package(OIS)
127 macro_log_feature(OIS_FOUND "OIS" "Input library needed for the samples" "http://sourceforge.net/projects/wgois" FALSE "" "")
129 #######################################################################
130 # Tools
131 #######################################################################
133 find_package(Doxygen)
134 macro_log_feature(DOXYGEN_FOUND "Doxygen" "Tool for building API documentation" "http://doxygen.org" FALSE "" "")
136 #######################################################################
137 # Tests
138 #######################################################################
140 find_package(CppUnit)
141 macro_log_feature(CppUnit_FOUND "CppUnit" "Library for performing unit tests" "http://cppunit.sourceforge.net" FALSE "" "")
143 #######################################################################
144 # Apple-specific
145 #######################################################################
146 if (APPLE)
147   find_package(Carbon)
148   macro_log_feature(Carbon_FOUND "Carbon" "Carbon" "http://www.apple.com" TRUE "" "")
150   find_package(Cocoa)
151   macro_log_feature(Cocoa_FOUND "Cocoa" "Cocoa" "http://www.apple.com" TRUE "" "")
153   find_package(IOKit)
154   macro_log_feature(IOKit_FOUND "IOKit" "IOKit HID framework needed by the samples" "http://www.apple.com" FALSE "" "")
155 endif(APPLE)
157 # Display results, terminate if anything required is missing
158 MACRO_DISPLAY_FEATURE_LOG()
161 # Add library and include paths from the dependencies
162 include_directories(
163   ${ZLIB_INCLUDE_DIRS}
164   ${ZZip_INCLUDE_DIRS}
165   ${FreeImage_INCLUDE_DIRS}
166   ${FREETYPE_INCLUDE_DIRS}
167   ${OPENGL_INCLUDE_DIRS}
168   ${CEGUI_INCLUDE_DIRS}
169   ${OIS_INCLUDE_DIRS}
170   ${Cg_INCLUDE_DIRS}
171   ${BOOST_INCLUDE_DIRS}
172   ${X11_INCLUDE_DIR}
173   ${DirectX_INCLUDE_DIRS}
174   ${CppUnit_INCLUDE_DIRS}
175   ${Carbon_INCLUDE_DIRS}
176   ${Cocoa_INCLUDE_DIRS}
178 link_directories(
179   ${OPENGL_LIBRARY_DIRS}
180   ${Cg_LIBRARY_DIRS}
181   ${BOOST_LIBRARY_DIRS}
182   ${X11_LIBRARY_DIRS}
183   ${DirectX_LIBRARY_DIRS}
184   ${CppUnit_LIBRARY_DIRS}