1#-------------------------------------------------------------------
2# This file is part of the CMake build system for OGRE
3#     (Object-oriented Graphics Rendering Engine)
4# For the latest info, see http://www.ogre3d.org/
5#
6# The contents of this file are placed in the public domain. Feel
7# free to make use of it in any way you like.
8#-------------------------------------------------------------------
9
10#####################################################
11# Install dependencies
12#####################################################
13if (NOT APPLE AND NOT WIN32)
14  return()
15endif()
16
17# TODO - most of this file assumes a common dependencies root folder
18# This is not robust, we should instead source dependencies from their individual locations
19get_filename_component(OGRE_DEP_DIR ${OIS_INCLUDE_DIR}/../../ ABSOLUTE)
20
21option(OGRE_INSTALL_DEPENDENCIES "Install dependency libs needed for samples" TRUE)
22option(OGRE_COPY_DEPENDENCIES "Copy dependency libs to the build directory" TRUE)
23
24macro(install_debug INPUT)
25  if (EXISTS ${OGRE_DEP_DIR}/bin/debug/${INPUT})
26    if (IS_DIRECTORY ${OGRE_DEP_DIR}/bin/debug/${INPUT})
27      install(DIRECTORY ${OGRE_DEP_DIR}/bin/debug/${INPUT} DESTINATION bin/debug CONFIGURATIONS Debug)
28    else ()
29      install(FILES ${OGRE_DEP_DIR}/bin/debug/${INPUT} DESTINATION bin/debug CONFIGURATIONS Debug)
30    endif ()
31  else()
32    message(send_error "${OGRE_DEP_DIR}/bin/debug/${INPUT} did not exist, can't install!")
33  endif ()
34endmacro()
35
36macro(install_release INPUT)
37  if (EXISTS ${OGRE_DEP_DIR}/bin/release/${INPUT})
38    if (IS_DIRECTORY ${OGRE_DEP_DIR}/bin/release/${INPUT})
39      install(DIRECTORY ${OGRE_DEP_DIR}/bin/release/${INPUT} DESTINATION bin/release CONFIGURATIONS Release None "")
40      install(DIRECTORY ${OGRE_DEP_DIR}/bin/release/${INPUT} DESTINATION bin/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
41      install(DIRECTORY ${OGRE_DEP_DIR}/bin/release/${INPUT} DESTINATION bin/minsizerel CONFIGURATIONS MinSizeRel)
42    else ()
43      install(FILES ${OGRE_DEP_DIR}/bin/release/${INPUT} DESTINATION bin/release CONFIGURATIONS Release None "")
44      install(FILES ${OGRE_DEP_DIR}/bin/release/${INPUT} DESTINATION bin/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
45      install(FILES ${OGRE_DEP_DIR}/bin/release/${INPUT} DESTINATION bin/minsizerel CONFIGURATIONS MinSizeRel)
46    endif ()
47  else()
48    message(send_error "${OGRE_DEP_DIR}/bin/release/${INPUT} did not exist, can't install!")
49  endif ()
50endmacro()
51
52macro(copy_debug INPUT)
53  if (EXISTS ${OGRE_DEP_DIR}/lib/debug/${INPUT})
54    if (MINGW OR NMAKE)
55      configure_file(${OGRE_DEP_DIR}/lib/debug/${INPUT} ${OGRE_BINARY_DIR}/lib/${INPUT} COPYONLY)
56	else ()
57      if (IS_DIRECTORY ${OGRE_DEP_DIR}/lib/debug/${INPUT})
58        install(DIRECTORY ${OGRE_DEP_DIR}/lib/debug/${INPUT} DESTINATION lib/debug)
59      else ()
60        configure_file(${OGRE_DEP_DIR}/lib/debug/${INPUT} ${OGRE_BINARY_DIR}/lib/debug/${INPUT} COPYONLY)
61      endif ()
62	endif ()
63  endif ()
64endmacro()
65
66macro(copy_release INPUT)
67  if (EXISTS ${OGRE_DEP_DIR}/lib/release/${INPUT})
68    if (MINGW OR NMAKE)
69      configure_file(${OGRE_DEP_DIR}/lib/release/${INPUT} ${OGRE_BINARY_DIR}/lib/${INPUT} COPYONLY)
70	else ()
71      if (IS_DIRECTORY ${OGRE_DEP_DIR}/lib/release/${INPUT})
72        install(DIRECTORY ${OGRE_DEP_DIR}/lib/release/${INPUT} DESTINATION lib/release CONFIGURATIONS Release None "")
73        install(DIRECTORY ${OGRE_DEP_DIR}/lib/release/${INPUT} DESTINATION lib/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
74        install(DIRECTORY ${OGRE_DEP_DIR}/lib/release/${INPUT} DESTINATION lib/minsizerel CONFIGURATIONS MinSizeRel)
75      else ()
76        configure_file(${OGRE_DEP_DIR}/lib/release/${INPUT} ${OGRE_BINARY_DIR}/lib/release/${INPUT} COPYONLY)
77        configure_file(${OGRE_DEP_DIR}/lib/release/${INPUT} ${OGRE_BINARY_DIR}/lib/relwithdebinfo/${INPUT} COPYONLY)
78        configure_file(${OGRE_DEP_DIR}/lib/release/${INPUT} ${OGRE_BINARY_DIR}/lib/minsizerel/${INPUT} COPYONLY)
79      endif ()
80	endif ()
81  endif ()
82endmacro ()
83
84if (OGRE_INSTALL_DEPENDENCIES)
85  if (OGRE_STATIC)
86    # for static builds, projects must link against all Ogre dependencies themselves, so copy full include and lib dir
87    if (EXISTS ${OGRE_DEP_DIR}/include/)
88      install(DIRECTORY ${OGRE_DEP_DIR}/include/ DESTINATION include)
89    endif ()
90
91    if (EXISTS ${OGRE_DEP_DIR}/lib/)
92        install(DIRECTORY ${OGRE_DEP_DIR}/lib/ DESTINATION lib)
93    endif ()
94  else ()
95	    # for non-static builds, we only need OIS for the samples
96	if (EXISTS ${OGRE_DEP_DIR}/include/OIS/)
97    install(DIRECTORY ${OGRE_DEP_DIR}/include/OIS   DESTINATION include)
98	endif () # OGRE_STATIC
99
100	if(WIN32)
101	  if (EXISTS ${OGRE_DEP_DIR}/lib/debug/OIS_d.lib)
102      install(FILES
103        ${OGRE_DEP_DIR}/lib/debug/OIS_d.lib
104        DESTINATION lib/debug CONFIGURATIONS Debug
105      )
106	  endif ()
107
108	  if (EXISTS ${OGRE_DEP_DIR}/lib/release/OIS.lib)
109      install(FILES
110        ${OGRE_DEP_DIR}/lib/release/OIS.lib
111        DESTINATION lib/release CONFIGURATIONS Release RelWithDebInfo MinSizeRel None ""
112      )
113	  endif ()
114
115	  if (MINGW)
116      install(FILES ${OIS_LIBRARY_DBG} DESTINATION lib/debug CONFIGURATIONS Debug)
117      install(FILES ${OIS_LIBRARY_REL} DESTINATION lib/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
118      install(FILES ${OIS_LIBRARY_REL} DESTINATION lib/release CONFIGURATIONS Release)
119      install(FILES ${OIS_LIBRARY_REL} DESTINATION lib/minsizerel CONFIGURATIONS MinSizeRel)
120	  endif () # MINGW
121	endif () # WIN32
122endif () # OGRE_INSTALL_DEPENDENCIES
123
124  if(WIN32)
125    # copy the dependency DLLs to the right places
126    if(NOT OGRE_BUILD_PLATFORM_WINRT)
127      install_debug(OIS_d.dll)
128      install_release(OIS.dll)
129    endif ()
130
131    if (OGRE_BUILD_PLUGIN_CG)
132      # if MinGW or NMake, the release/debug cg.dll's would conflict, so just pick one
133      if (MINGW OR (CMAKE_GENERATOR STREQUAL "NMake Makefiles"))
134        if (CMAKE_BUILD_TYPE STREQUAL "Debug")
135          install_debug(cg.dll)
136        else ()
137          install_release(cg.dll)
138        endif ()
139      else ()
140        install_debug(cg.dll)
141        install_release(cg.dll)
142      endif ()
143    endif () # OGRE_BUILD_PLUGIN_CG
144
145    # install GLES dlls
146    if (OGRE_BUILD_RENDERSYSTEM_GLES)
147      install_debug(libgles_cm.dll)
148      install_release(libgles_cm.dll)
149    endif ()
150
151    # install GLES2 dlls
152    if (OGRE_BUILD_RENDERSYSTEM_GLES2)
153      install_debug(libGLESv2.dll)
154      install_release(libEGL.dll)
155    endif ()
156  endif () # WIN32
157
158  # If we're installing the sample source for an SDK, also install Boost headers & libraries
159  if (OGRE_INSTALL_SAMPLES_SOURCE AND Boost_FOUND)
160    # headers (try to exclude things we don't need)
161    install(DIRECTORY "${Boost_INCLUDE_DIR}/boost" DESTINATION "boost"
162      PATTERN "accumulators" EXCLUDE
163      PATTERN "archive" EXCLUDE
164      PATTERN "asio" EXCLUDE
165      PATTERN "assign" EXCLUDE
166      PATTERN "bimap" EXCLUDE
167      PATTERN "circular_buffer" EXCLUDE
168      PATTERN "compatibility" EXCLUDE
169      PATTERN "concept_check" EXCLUDE
170      PATTERN "container" EXCLUDE
171      PATTERN "dynamic_bitset" EXCLUDE
172      PATTERN "filesystem" EXCLUDE
173      PATTERN "flyweight" EXCLUDE
174      PATTERN "format" EXCLUDE
175      PATTERN "fusion" EXCLUDE
176      PATTERN "geometry" EXCLUDE
177      PATTERN "gil" EXCLUDE
178      PATTERN "graph" EXCLUDE
179      PATTERN "interprocess" EXCLUDE
180      PATTERN "intrusive" EXCLUDE
181      PATTERN "iostreams" EXCLUDE
182      PATTERN "lambda" EXCLUDE
183      PATTERN "logic" EXCLUDE
184      PATTERN "mpi" EXCLUDE
185      PATTERN "multi_array" EXCLUDE
186      PATTERN "multi_index" EXCLUDE
187      PATTERN "numeric" EXCLUDE
188      PATTERN "parameter" EXCLUDE
189      PATTERN "pending" EXCLUDE
190      PATTERN "phoenix" EXCLUDE
191      PATTERN "pool" EXCLUDE
192      PATTERN "program_options" EXCLUDE
193      PATTERN "property_map" EXCLUDE
194      PATTERN "property_tree" EXCLUDE
195      PATTERN "proto" EXCLUDE
196      PATTERN "ptr_container" EXCLUDE
197      PATTERN "python" EXCLUDE
198      PATTERN "random" EXCLUDE
199      PATTERN "regex" EXCLUDE
200      PATTERN "serialization" EXCLUDE
201      PATTERN "signals" EXCLUDE
202      PATTERN "signals2" EXCLUDE
203      PATTERN "spirit" EXCLUDE
204      PATTERN "statechart" EXCLUDE
205      PATTERN "test" EXCLUDE
206      PATTERN "timer" EXCLUDE
207      PATTERN "tr1" EXCLUDE
208      PATTERN "units" EXCLUDE
209      PATTERN "uuid" EXCLUDE
210      PATTERN "variant" EXCLUDE
211      PATTERN "wave" EXCLUDE
212      PATTERN "xpressive" EXCLUDE
213    )
214    # License
215    if (EXISTS "${Boost_INCLUDE_DIR}/boost/LICENSE_1_0.txt")
216        install(FILES "${Boost_INCLUDE_DIR}/boost/LICENSE_1_0.txt" DESTINATION "boost")
217    elseif (EXISTS "${Boost_INCLUDE_DIR}/LICENSE_1_0.txt")
218        install(FILES "${Boost_INCLUDE_DIR}/LICENSE_1_0.txt" DESTINATION "boost")
219    endif ()
220    # libraries
221    if (Boost_THREAD_FOUND)
222      install(FILES ${Boost_THREAD_LIBRARY_DEBUG} DESTINATION "boost/lib" CONFIGURATIONS Debug)
223      install(FILES ${Boost_THREAD_LIBRARY_RELEASE} DESTINATION "boost/lib" CONFIGURATIONS Release)
224    endif()
225    if (Boost_DATE_TIME_FOUND)
226      install(FILES ${Boost_DATE_TIME_LIBRARY_DEBUG} DESTINATION "boost/lib" CONFIGURATIONS Debug)
227      install(FILES ${Boost_DATE_TIME_LIBRARY_RELEASE} DESTINATION "boost/lib" CONFIGURATIONS Release)
228    endif()
229    if (Boost_SYSTEM_FOUND)
230      install(FILES ${Boost_SYSTEM_LIBRARY_DEBUG} DESTINATION "boost/lib" CONFIGURATIONS Debug)
231      install(FILES ${Boost_SYSTEM_LIBRARY_RELEASE} DESTINATION "boost/lib" CONFIGURATIONS Release)
232    endif()
233    if (Boost_CHRONO_FOUND)
234      install(FILES ${Boost_CHRONO_LIBRARY_DEBUG} DESTINATION "boost/lib" CONFIGURATIONS Debug)
235      install(FILES ${Boost_CHRONO_LIBRARY_RELEASE} DESTINATION "boost/lib" CONFIGURATIONS Release)
236    endif()
237  endif()
238endif ()
239
240if (OGRE_COPY_DEPENDENCIES)
241
242  if (WIN32)
243    # copy the required DLLs to the build directory (configure_file is the only copy-like op I found in CMake)
244    if(NOT OGRE_BUILD_PLATFORM_WINRT)
245      install(FILES ${OIS_BINARY_DBG} DESTINATION lib/debug CONFIGURATIONS Debug None "")
246    	install(FILES ${OIS_BINARY_REL} DESTINATION lib/release CONFIGURATIONS Release None "")
247    	install(FILES ${OIS_BINARY_REL} DESTINATION lib/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
248    	install(FILES ${OIS_BINARY_REL} DESTINATION lib/minsizerel CONFIGURATIONS MinSizeRel)
249    endif ()
250
251    if (OGRE_BUILD_PLUGIN_CG)
252      # if MinGW or NMake, the release/debug cg.dll's would conflict, so just pick one
253      if (MINGW OR (CMAKE_GENERATOR STREQUAL "NMake Makefiles"))
254        if (CMAKE_BUILD_TYPE STREQUAL "Debug")
255          install(FILES ${Cg_BINARY_DBG} DESTINATION bin/debug CONFIGURATIONS Debug None "")
256        else ()
257          install(FILES ${Cg_BINARY_REL} DESTINATION bin/release CONFIGURATIONS Release None "")
258    			install(FILES ${Cg_BINARY_REL} DESTINATION bin/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
259    			install(FILES ${Cg_BINARY_REL} DESTINATION bin/minsizerel CONFIGURATIONS MinSizeRel)
260        endif ()
261      else ()
262        install(FILES ${Cg_BINARY_DBG} DESTINATION bin/debug CONFIGURATIONS Debug None "")
263    		install(FILES ${Cg_BINARY_REL} DESTINATION bin/release CONFIGURATIONS Release None "")
264    		install(FILES ${Cg_BINARY_REL} DESTINATION bin/relwithdebinfo CONFIGURATIONS RelWithDebInfo)
265    		install(FILES ${Cg_BINARY_REL} DESTINATION bin/minsizerel CONFIGURATIONS MinSizeRel)
266      endif ()
267    endif()
268
269    if (OGRE_BUILD_RENDERSYSTEM_GLES)
270      copy_debug(libgles_cm.dll)
271      copy_release(libgles_cm.dll)
272    endif ()
273
274    if (OGRE_BUILD_RENDERSYSTEM_GLES2)
275      copy_debug(libEGL.dll)
276      copy_debug(libGLESv2.dll)
277      copy_release(libEGL.dll)
278      copy_release(libGLESv2.dll)
279    endif ()
280  endif ()
281
282endif ()
283