mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 03:29:47 +00:00
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.
This commit is contained in:
parent
7dd5ca66c9
commit
c18ed7236d
@ -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()
|
||||
|
8
Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt
Normal file
8
Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt
Normal file
@ -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.$
|
2
Tests/RunCMake/GNUInstallDirs/NoSystem.cmake
Normal file
2
Tests/RunCMake/GNUInstallDirs/NoSystem.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
unset(CMAKE_SYSTEM_NAME)
|
||||
include(GNUInstallDirs)
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user