File: FindWindres.cmake

package info (click to toggle)
spring 106.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 55,260 kB
  • sloc: cpp: 543,946; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (63 lines) | stat: -rw-r--r-- 1,527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# This file is part of the Spring engine (GPL v2 or later), see LICENSE.html

# - Find windres executable
# manipulate Windows resources
#
#  WINDRES_BIN    - will be set to the windres executable (eg. windres.exe)
#  WINDRES_FOUND  - TRUE if windres was found

if (MINGW)
	# Already in cache, be silent
	if (WINDRES_BIN)
		SET(Windres_FIND_QUIETLY TRUE)
	endif ()

	FIND_PROGRAM(WINDRES_BIN
		NAMES
			windres
			x86_64-w64-mingw32.static-windres
			i686-w64-mingw32.static.posix-windres
			i686-w64-mingw32-windres
			i586-mingw32msvc-windres
			i586-pc-mingw32-windres
			i686-pc-mingw32-windres
			i686-mingw32-windres
			${CMAKE_RC_COMPILER}
		DOC "path to mingw's windres executable"
		)

	INCLUDE(FindPackageHandleStandardArgs)

	# handle the QUIETLY and REQUIRED arguments and set WINDRES_FOUND to TRUE if
	# all listed variables are TRUE
	FIND_PACKAGE_HANDLE_STANDARD_ARGS(Windres DEFAULT_MSG WINDRES_BIN)

	MARK_AS_ADVANCED(WINDRES_BIN)


	macro (CreateResourceCompileCommand out_var dirIn fileIn fileOut)
		if (WINDRES_FOUND)
			ADD_CUSTOM_COMMAND(
				OUTPUT
					"${fileOut}"
				DEPENDS
					"${fileIn}"
				COMMAND
					"${WINDRES_BIN}"
						"-I${dirIn}"
						"-i${fileIn}"
						"-o" "${fileOut}"
						"-v"
				)
			SET_SOURCE_FILES_PROPERTIES(${fileOut} PROPERTIES
				GENERATED      TRUE
				OBJECT_DEPENDS ${fileIn}
				)
			SET(${out_var} "${fileOut}")
		else ()
			SET(${out_var} "")
			message (WARNING "Could not find windres, not compiling resource \"${fileIn}\".")
		endif ()
	endmacro ()
endif ()