1
2# (the blank line is here so CMake doesn't generate documentation from it)
3
4#
5#   This file is part of Corrade.
6#
7#   Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
8#               2017, 2018, 2019, 2020 Vladimír Vondruš <mosra@centrum.cz>
9#
10#   Permission is hereby granted, free of charge, to any person obtaining a
11#   copy of this software and associated documentation files (the "Software"),
12#   to deal in the Software without restriction, including without limitation
13#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
14#   and/or sell copies of the Software, and to permit persons to whom the
15#   Software is furnished to do so, subject to the following conditions:
16#
17#   The above copyright notice and this permission notice shall be included
18#   in all copies or substantial portions of the Software.
19#
20#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26#   DEALINGS IN THE SOFTWARE.
27#
28
29if(NOT DEFINED LIB_SUFFIX)
30    message(STATUS "LIB_SUFFIX variable is not defined. It will be autodetected now.")
31    message(STATUS "You can set it manually with -DLIB_SUFFIX=<value> (64 for example)")
32
33    # All 32bit systems and OSX have empty lib suffix, decide based on
34    # FIND_LIBRARY_USE_LIB64_PATHS on other 64bit systems
35    if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT APPLE)
36        # CMake might be right most of the time, but if /usr/lib64 is symlink
37        # to somewhere else, it means that we should *really* not install there
38        # (that's the case with ArchLinux)
39        get_property(LIB_SUFFIX GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
40        if(LIB_SUFFIX AND NOT IS_SYMLINK /usr/lib64)
41            set(LIB_SUFFIX "64")
42        else()
43            set(LIB_SUFFIX "")
44        endif()
45    else()
46        set(LIB_SUFFIX "")
47    endif()
48
49    # Put the value into cache
50    set(LIB_SUFFIX "${LIB_SUFFIX}" CACHE STRING "Library directory suffix (e.g. 64 for /usr/lib64).")
51
52    message(STATUS "LIB_SUFFIX autodetected as '${LIB_SUFFIX}', libraries will be installed into ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
53endif()
54