diff options
author | Brad King <brad.king@kitware.com> | 2020-01-31 13:46:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-31 13:46:27 (GMT) |
commit | 60edc8344606acf7ef9327190d1fd66bd72bb865 (patch) | |
tree | e67961b5861a4c7176668055ea1c561637dbc43b | |
parent | d70b71c14f6b631ee4570c530b7a48f2ca72de54 (diff) | |
parent | c18ed7236db5720bab383e6de78415177922bff3 (diff) | |
download | CMake-60edc8344606acf7ef9327190d1fd66bd72bb865.zip CMake-60edc8344606acf7ef9327190d1fd66bd72bb865.tar.gz CMake-60edc8344606acf7ef9327190d1fd66bd72bb865.tar.bz2 |
Merge topic 'GNUInstallDirs-no-system'
c18ed7236d GNUInstallDirs: Warn when CMAKE_SYSTEM_NAME is not set
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4300
-rw-r--r-- | Modules/GNUInstallDirs.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt | 8 | ||||
-rw-r--r-- | Tests/RunCMake/GNUInstallDirs/NoSystem.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake | 3 |
4 files changed, 22 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() diff --git a/Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt b/Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt new file mode 100644 index 0000000..36f064c --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt @@ -0,0 +1,8 @@ +^CMake Warning \(dev\) at .*/Modules/GNUInstallDirs.cmake:[0-9]+ \(message\): + Unable to determine default CMAKE_INSTALL_LIBDIR directory because no + target architecture is known. Please enable at least one language before + including GNUInstallDirs. +Call Stack \(most recent call first\): + NoSystem.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/GNUInstallDirs/NoSystem.cmake b/Tests/RunCMake/GNUInstallDirs/NoSystem.cmake new file mode 100644 index 0000000..19cf7be --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/NoSystem.cmake @@ -0,0 +1,2 @@ +unset(CMAKE_SYSTEM_NAME) +include(GNUInstallDirs) diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake index d671ee0..eb2c1a2 100644 --- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake +++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake @@ -16,4 +16,7 @@ foreach(case ) set(RunCMake-stderr-file ${case}${variant}-stderr.txt) run_cmake(${case}) + unset(RunCMake-stderr-file) endforeach() + +run_cmake(NoSystem) |