[CMake] Fwd: CMAKE_HOST_SYSTEM_NAME is empty

Orban, Laszlo laszlo.orban at balabit.com
Thu Apr 25 03:29:19 EDT 2019


Hi all,

Please help me an issue I'm facing with CMAKE_HOST_SYSTEM_NAME on FreeBSD
10.3. It gives back empty string, if I read it before the 'project(...)'.
As far as I understood, CMAKE_SYSTEM_NAME can be used only after the
'project(...)' call, but CMAKE_HOST_SYSTEM_NAME should simply give back the
result of 'uname -s' and could be used before 'project'.
I'd like to use CMAKE_HOST_SYSTEM_NAME in my Compilers module to switch to
clang instead of gcc in case if the host system is FreeBSD.

CMakeLists.txt:

...
include(Version)
include(BuildType)
include(Compilers)
*message ( "!Before project='${CMAKE_HOST_SYSTEM_NAME}'" )*
*project ( WanderfulProject LANGUAGES C )*
*message ( "!After project='${CMAKE_HOST_SYSTEM_NAME}'" )*
include(Endianness)
include(GNUInstallDirs)
include(Configure)
...


Output:

...

*!Before project=''*
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
*!After project='FreeBSD'*
*...*

Additional info:

$ cmake --version
cmake version 3.4.1
$ uname -K
1003000
$ uname -s
FreeBSD
$ uname -m
amd64
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190425/0e6d9de8/attachment.html>


More information about the CMake mailing list