diff options
author | Vitaly Lipatov <lav@etersoft.ru> | 2020-01-30 10:55:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-01-30 14:14:47 (GMT) |
commit | c18ed7236db5720bab383e6de78415177922bff3 (patch) | |
tree | e86ce6be824a8cb0af5abf839533b561879a6bd4 /Modules/GNUInstallDirs.cmake | |
parent | 7dd5ca66c911a422878f53d998eb457297eaf804 (diff) | |
download | CMake-c18ed7236db5720bab383e6de78415177922bff3.zip CMake-c18ed7236db5720bab383e6de78415177922bff3.tar.gz CMake-c18ed7236db5720bab383e6de78415177922bff3.tar.bz2 |
GNUInstallDirs: Warn when CMAKE_SYSTEM_NAME is not set
If a project writes `include(GNUInstallDirs)` before `project()` then
`CMAKE_SYSTEM_NAME` may not be set and an incorrect `LIBDIR` may be
computed. Warn about this case.
Diffstat (limited to 'Modules/GNUInstallDirs.cmake')
-rw-r--r-- | Modules/GNUInstallDirs.cmake | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index f95e6e2..9ef22b9 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -221,6 +221,11 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set # default one. When CMAKE_INSTALL_PREFIX changes, the value is # updated to the new default, unless the user explicitly changed it. endif() + if (NOT DEFINED CMAKE_SYSTEM_NAME OR NOT DEFINED CMAKE_SIZEOF_VOID_P) + message(AUTHOR_WARNING + "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " + "Please enable at least one language before including GNUInstallDirs.") + endif() if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/arch-release") @@ -235,16 +240,10 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set endif() endif() else() # not debian, rely on CMAKE_SIZEOF_VOID_P: - if(NOT DEFINED CMAKE_SIZEOF_VOID_P) - message(AUTHOR_WARNING - "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " - "Please enable at least one language before including GNUInstallDirs.") - else() - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(_LIBDIR_DEFAULT "lib64") - if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) - set(__LAST_LIBDIR_DEFAULT "lib64") - endif() + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(_LIBDIR_DEFAULT "lib64") + if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) + set(__LAST_LIBDIR_DEFAULT "lib64") endif() endif() endif() |