forked from orocos-toolchain/rtt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSelectOneLibrary.cmake
51 lines (38 loc) · 1.5 KB
/
SelectOneLibrary.cmake
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
# As some libraries are actually a list of libraries (e.g. "debug;xxx-d.lib;optimized;xxx.lib")
# and we can't deal with that in pkgconfig, we take
# 1) the library for this build type, or
# 2) the library if only one is listed, or
# 3) the release version if available and the build type is one of the release types, or
# 4) we error out.
#
# EXPECTED USAGE
#
# SELECT_ONE_LIBRARY("Boost_THREAD_LIBRARY" BOOST_THREAD_LIB)
# LIST(APPEND OROCOS-RTT_USER_LINK_LIBS ${BOOST_THREAD_LIB})
#
macro( SELECT_ONE_LIBRARY NAME RETURN)
set(${RETURN} "")
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
SET(NAME_U "${NAME}_${CMAKE_BUILD_TYPE_UPPER}")
if (DEFINED ${NAME_U})
set(${RETURN} ${${NAME_U}})
else (DEFINED ${NAME_U})
LIST(LENGTH ${NAME} COUNT)
if (1 EQUAL COUNT)
set(${RETURN} ${${NAME}})
else (1 EQUAL COUNT)
# found nothing particular to this build type, but
# for all release-related types, use release (if available)
# these two if's have to be done separately for some reason ... :-(
if (CMAKE_BUILD_TYPE_UPPER MATCHES "RELWITHDEBINFO|RELEASE|MINSIZEREL")
if (DEFINED ${NAME}_RELEASE)
MESSAGE(STATUS "Defaulting to release library for ${CMAKE_BUILD_TYPE_UPPER}")
set(${RETURN} ${${NAME}_RELEASE})
endif ()
endif ()
endif (1 EQUAL COUNT)
endif (DEFINED ${NAME_U})
if ("" STREQUAL ${RETURN})
MESSAGE(FATAL_ERROR "Found multiple ${NAME} libraries, but not one specific to, or related to, the current build type '${CMAKE_BUILD_TYPE_UPPER}'.")
endif()
endmacro()