2015-11-17 19:31:26 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								message(STATUS "processing dlllist.cmake")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# figure out which command to use for objdump
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								execute_process(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									COMMAND ${CMAKE_C_COMPILER} -dumpmachine
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_VARIABLE OBJDUMP
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_STRIP_TRAILING_WHITESPACE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# figure out where we should search for libraries
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								execute_process(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									COMMAND ${CMAKE_C_COMPILER} -print-search-dirs
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-17 15:50:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									COMMAND sed -nE "/^libraries: =/{s///;s,/lib/?\(:|\$\$\),/bin\\1,g;p;q;}"
							 | 
						
					
						
							
								
									
										
										
										
											2015-11-17 19:31:26 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_VARIABLE ADDPATH
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_STRIP_TRAILING_WHITESPACE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-17 15:50:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								message(STATUS "addpath is ${ADDPATH}")
							 | 
						
					
						
							
								
									
										
										
										
											2015-11-17 19:31:26 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# since cmake doesn't appear to give us a variable with
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# all libraries we link against, grab the link.txt script
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# instead and drop the command name from it (before the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# first space) -- this will fail if the full path for the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# linker used contains a space...
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								execute_process(
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-25 22:34:36 +07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									COMMAND tail -1 CMakeFiles/${SUBSURFACE_TARGET}.dir/link.txt
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-17 15:50:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									COMMAND cut -d\  -f 2-
							 | 
						
					
						
							
								
									
										
										
										
											2015-11-17 19:31:26 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_VARIABLE LINKER_LINE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_STRIP_TRAILING_WHITESPACE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# finally run our win-ldd.pl script against that to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# collect all the required dlls
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								execute_process(
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-17 15:50:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									COMMAND sh -c "OBJDUMP=${OBJDUMP}-objdump PATH=$ENV{PATH}:${ADDPATH} perl ${SUBSURFACE_SOURCE}/scripts/win-ldd.pl ${SUBSURFACE_TARGET}.exe ${LINKER_LINE}"
							 | 
						
					
						
							
								
									
										
										
										
											2015-11-17 19:31:26 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_VARIABLE DLLS
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OUTPUT_STRIP_TRAILING_WHITESPACE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# replace newlines with semicolons so this is a cmake list
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-17 15:50:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								string(REPLACE "\n" ";" DLLLIST ${DLLS})
							 | 
						
					
						
							
								
									
										
										
										
											2015-11-17 19:31:26 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# executing 'install' as a command seems hacky, but you
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# can't use the install() cmake function in a script
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								foreach(DLL ${DLLLIST})
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									execute_process(COMMAND install ${DLL} ${STAGING})
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								endforeach()
							 |