summaryrefslogtreecommitdiffstats
path: root/cmake/SisoLibDir.cmake
blob: 594b2f979ec725a8e83014177f374c571dbb8193 (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# This makro sets up additional library directories depending on the compiler.
# The reason behind this are the binary incompatible libraries generated by
# different compilers on Windows (e.g. Microsoft Visual Studio vs. Borland).
#
# Although newer versions of MSVC can operate with older libraries there may
# be libs compiled for a more recent version as MSVC6. Scan through all the
# possible directories for the matching lib.
#
# This makro expects the /lib directory (usually $ENV{SISODIRsomething}) as
# argument BASEDIR and will append a list of all valid library paths to
# variable LIB_DIRS. This may or may not include BASE_DIR depending on the
# platform. If BASEDIR is empty or is just "/lib" nothing will happen to
# LIB_DIRS.
#
# An optional variable name may be passed as third argument. If that argument
# is given the best matching suffix will be stored in that variable (e.g.
# "visualc2008" if you are using MSVC9). This will even work if LIB_DIRS would
# not be touched.

MACRO (SISO_LIB_DIR BASE_DIR LIB_DIRS)
	IF (WIN32)
		IF (CMAKE_GENERATOR STREQUAL "Borland Makefiles")
			IF ("${BASE_DIR}" AND NOT "${BASE_DIR}" STREQUAL "/lib")
				LIST(APPEND ${LIB_DIRS} "borland")
			ENDIF ("${BASE_DIR}" AND NOT "${BASE_DIR}" STREQUAL "/lib")
			IF (${ARGC} EQUAL 3)
				set(${ARGV2} "borland")
			ENDIF (${ARGC} EQUAL 3)
		ELSE (CMAKE_GENERATOR STREQUAL "Borland Makefiles")
			# assume MSVC
			SET(TMP_MSVC 0)
			SET(TMP_MSVC_64 0)

			IF (CMAKE_GENERATOR STREQUAL "Visual Studio 6")
				SET(TMP_MSVC 6)
				SET(TMP_MSVC_64 0)
			ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005")
				SET(TMP_MSVC 8)
				SET(TMP_MSVC_64 0)
			ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005 Win64")
				SET(TMP_MSVC 8)
				SET(TMP_MSVC_64 1)
			ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
				SET(TMP_MSVC 9)
				SET(TMP_MSVC_64 0)
			ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008 Win64")
				SET(TMP_MSVC 9)
				SET(TMP_MSVC_64 1)
			ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 10")
				SET(TMP_MSVC 10)
				SET(TMP_MSVC_64 0)
			ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 10 Win64")
				SET(TMP_MSVC 10)
				SET(TMP_MSVC_64 1)
			ELSEIF (CMAKE_GENERATOR STREQUAL "NMake Makefiles" OR CMAKE_GENERATOR STREQUAL "MinGW Makefiles"
					OR CMAKE_GENERATOR STREQUAL "NMake Makefiles JOM")
				SET(TMP_MSVC_64 ${CMAKE_CL_64})
				IF (MSVC_VERSION EQUAL 1400)
					SET(TMP_MSVC 8)
				ELSEIF (MSVC_VERSION GREATER 1599)
					SET(TMP_MSVC 10)
				ELSEIF (MSVC_VERSION GREATER 1499)
					SET(TMP_MSVC 9)
				ELSEIF (CMAKE_COMPILER_2005)
					SET(TMP_MSVC 8)
				ELSE (MSVC_VERSION EQUAL 1400)
					SET(TMP_MSVC 6)
				ENDIF (MSVC_VERSION EQUAL 1400)
			ELSE (CMAKE_GENERATOR STREQUAL "Visual Studio 6")
				MESSAGE(FATAL_ERROR "Compiler not detected in SisoLibDir.cmake")
			ENDIF (CMAKE_GENERATOR STREQUAL "Visual Studio 6")

			SET(TMP_DIRS "")

			IF (TMP_MSVC GREATER 7)
				LIST(APPEND TMP_DIRS "visualc")
			ENDIF (TMP_MSVC GREATER 7)
			IF (TMP_MSVC GREATER 5 AND NOT TMP_MSVC_64)
				LIST(APPEND TMP_DIRS "visualc")
			ENDIF (TMP_MSVC GREATER 5 AND NOT TMP_MSVC_64)

			IF (${ARGC} EQUAL 3)
				LIST(GET TMP_DIRS 0 TMPSTR)
				IF (TMP_MSVC_64)
					SET(TMPSTR "${TMPSTR}")
				ENDIF (TMP_MSVC_64)
				set(${ARGV2} ${TMPSTR})
			ENDIF (${ARGC} EQUAL 3)

			IF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
				FOREACH (TMP_ITEM ${TMP_DIRS})
					IF (TMP_MSVC_64)
						LIST(APPEND ${LIB_DIRS} "${BASE_DIR}/${TMP_ITEM}")
					ELSE (TMP_MSVC_64)
						LIST(APPEND ${LIB_DIRS} "${BASE_DIR}/${TMP_ITEM}")
					ENDIF (TMP_MSVC_64)
				ENDFOREACH (TMP_ITEM ${TMP_DIRS})
			ENDIF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
		ENDIF (CMAKE_GENERATOR STREQUAL "Borland Makefiles")
	ELSE (WIN32)
		IF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
			LIST(APPEND ${LIB_DIRS} ${BASE_DIR})
		ENDIF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
		IF (${ARGC} EQUAL 3)
			set(${ARGV2} "interface")
		ENDIF (${ARGC} EQUAL 3)
	ENDIF (WIN32)
	IF (${LIB_DIRS})
		LIST(REMOVE_ITEM ${LIB_DIRS} "/lib")
	ENDIF (${LIB_DIRS})
ENDMACRO (SISO_LIB_DIR BASE_DIR LIB_DIRS)