File: FindLibraryForCPU.cmake

package info (click to toggle)
enblend-enfuse 4.2-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,756 kB
  • sloc: cpp: 24,275; sh: 4,319; perl: 1,124; makefile: 551; ansic: 505; lisp: 276
file content (44 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download | duplicates (5)
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
#
#  FIND_LIBRARY_WITH_CPU
#  -> enhanced FIND_LIBRARY to allow searching for platform
#     specific versions of libraries on Win32. This is common
#     for MSVC based builds that may output a file into a directory
#     particular for that CPU architecture (traditionally, 
#     "Win32" and "x64" for 32-bit and 64-bit builds)
#
#    
# Based in part on FIND_LIBRARY_WITH_DEBUG
# Copyright (c) 2009, Ryan Sleevi, <ryan@sleevi.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO(FIND_LIBRARY_FOR_CPU var_name)
	IF(NOT MSVC)
		FIND_LIBRARY(${var_name} ${ARGN})
	ELSE(NOT MSVC)
		SET(args ${ARGN})
		SET(names "")
		SET(newpaths "")
		SET(found_paths 0)
		IF(CMAKE_CL_64)
			SET(msvc_platform "x64")
		ELSE(CMAKE_CL_64)
			SET(msvc_platform "Win32")
		ENDIF(CMAKE_CL_64)
		
		FOREACH(val ${args})
			IF(found_paths)
				# Prefer the CPU-specific path over the generic/original path
				LIST(APPEND newpaths "${val}/${msvc_platform}")
				LIST(APPEND newpaths "${val}")
			ELSE(found_paths)
				IF(${val} STREQUAL "PATHS")
					SET(found_paths 1)
				ELSE()
					LIST(APPEND names "${val}")
				ENDIF()
			ENDIF(found_paths)
		ENDFOREACH(val)
		
		FIND_LIBRARY(${var_name} ${names} PATHS ${newpaths})
	ENDIF(NOT MSVC)
ENDMACRO(FIND_LIBRARY_FOR_CPU)