View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0016061CMakeCMakepublic2016-04-13 11:022016-06-10 14:21
ReporterStefan Teleman 
Assigned To 
PrioritynormalSeveritytrivialReproducibilityalways
StatusclosedResolutionfixed 
Platformx86 x86_64 SPARCOSSolarisOS Version5.11, 5.12
Product VersionCMake 3.5 
Target VersionCMake 3.6Fixed in VersionCMake 3.6 
Summary0016061: define SOLARIS and CMAKE_HOST_SOLARIS as a cmake built-in
Descriptionin ${top_srcdir}/Source/cmState.cxx:

void cmState::Snapshot::SetDefaultDefinitions()

several builtins are defined: WIN32/CMAKE_HOST_WIN32, APPLE/CMAKE_HOST_APPLE,
etc.

We would like to submit this patch to add corresponding definitions
for Solaris: SOLARIS/CMAKE_HOST_SOLARIS

Proposed patch - cmState.cxx-solaris.patch - attached.

The patch is based on cmake 3.5.0.
Steps To ReproduceAlways - the SOLARIS/CMAKE_HOST_SOLARIS definition is not present
in cmake.
TagsNo tags attached.
Attached Filespatch file icon cmState.cxx-solaris.patch [^] (565 bytes) 2016-04-13 11:02 [Show Content]
patch file icon cmState.cxx-solaris-v2.patch [^] (1,228 bytes) 2016-04-13 17:04 [Show Content]

 Relationships

  Notes
(0040851)
Brad King (manager)
2016-04-13 11:39

One should be able to read CMAKE_SYSTEM_NAME and CMAKE_HOST_SYSTEM_NAME to detect Solaris. The other names like "APPLE" pre-date those variables and are kept only for historical reasons. Therefore I do not think we should add new ones.
(0040852)
Stefan Teleman (reporter)
2016-04-13 14:08

My understanding is that CMAKE_SYSTEM_NAME and CMAKE_HOST_SYSTEM_NAME
are not set by cmake. These variables being set are the responsibility
of the project using cmake.

This is unreliable.

We would like to have a reliable, always-on mechanism for identifying
Solaris, regardless of whether or not a specific project has correctly
defined CMAKE_SYSTEM_NAME and/or CMAKE_HOST_SYSTEM_NAME.
(0040853)
Stefan Teleman (reporter)
2016-04-13 14:21

Not to mention the fact that sending <X> number of patches to an
unknown <Y> number of CMake-based projects that did not properly
define CMAKE_SYSTEM_NAME or CMAKE_HOST_SYSTEM_NAME does not scale
at all.
(0040854)
Brad King (manager)
2016-04-13 14:24

CMAKE_SYSTEM_NAME and CMAKE_HOST_SYSTEM_NAME are always provided by CMake:

 https://cmake.org/cmake/help/v3.5/variable/CMAKE_HOST_SYSTEM_NAME.html [^]
 https://cmake.org/cmake/help/v3.5/variable/CMAKE_SYSTEM_NAME.html [^]

Several internal implementation details use them and so they must be set. The CMAKE_HOST_SYSTEM_NAME is always detected. The CMAKE_SYSTEM_NAME may be optionally set by a toolchain file to activate cross-compiling, but otherwise defaults to the CMAKE_HOST_SYSTEM_NAME value.
(0040855)
Stefan Teleman (reporter)
2016-04-13 14:58

%> ./cmake --version
cmake version 3.5.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
%> uname -a
SunOS xxxxxxx 5.12 s12_96 sun4v sparc sun4v Solaris
./cmake -P ./Solaris.cmake
--
-- SOLARIS is defined: 1
--
-- SUNOS is NOT defined
--
-- CMAKE_SYSTEM_NAME is NOT DEFINED!
--
-- CMAKE_HOST_SYSTEM_NAME is NOT DEFINED!
%> cat Solaris.cmake
function(solaris)
  message (STATUS "")
  IF (SOLARIS)
    message (STATUS "SOLARIS is defined: ${SOLARIS}")
  ELSE()
    message (STATUS "SOLARIS is NOT defined")
  ENDIF()
endfunction()

function(sunos)
  message (STATUS "")
  IF (SUNOS)
    message (STATUS "SUNOS is defined: ${SUNOS}")
  ELSE()
    message (STATUS "SUNOS is NOT defined")
  ENDIF()
endfunction()

function(cmake_system_name)
  message (STATUS "")
  IF (CMAKE_SYSTEM_NAME)
    message (STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
  ELSE()
    message (STATUS "CMAKE_SYSTEM_NAME is NOT DEFINED!")
  ENDIF()
endfunction()

function(cmake_host_system_name)
  message (STATUS "")
  IF (CMAKE_HOST_SYSTEM_NAME)
    message (STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
  ELSE()
    message (STATUS "CMAKE_HOST_SYSTEM_NAME is NOT DEFINED!")
  ENDIF()
endfunction()

solaris()
sunos()
cmake_system_name()
cmake_host_system_name()

I do not see any of these variables being set by default by cmake.

SOLARIS is the only OS identifier variable being set, and that only
because of the patch I have provided earlier.

Also: in ${top_srcdir} for CMake 3.5.0:

%> find . -type f -name "*.cxx" -exec egrep -e 'CMAKE_HOST_SYSTEM_NAME' -n {} \; -print
%> find . -type f -name "*.h" -exec egrep -e 'CMAKE_HOST_SYSTEM_NAME' -n {} \; -print
%>

CMAKE_HOST_SYSTEM_NAME does not appear to be set by CMake anywhere in
the code. So, how can it be set by default by CMake, then?
(0040856)
Brad King (manager)
2016-04-13 15:10

The variables are set by CMake in the context of a project with a CMakeLists.txt file. I didn't realize you're trying to do this for "cmake -P" mode before and forgot that it doesn't work for that.

Okay, I think we should add CMAKE_HOST_SOLARIS but not any name without a prefix.

Please run

$ git grep CMAKE_HOST_UNIX -- Help

to see where documentation for the new variable needs to be added and extend the patch to include it.
(0040858)
Stefan Teleman (reporter)
2016-04-13 15:18
edited on: 2016-04-13 15:20

Okay, CMAKE_HOST_SOLARIS works great.

Stay tuned for an updated patch.

(0040861)
Stefan Teleman (reporter)
2016-04-13 17:05

New patch - Version 2 - attached.
(0040867)
Brad King (manager)
2016-04-15 13:26

Thanks, applied:

Solaris: Add a CMAKE_HOST_SOLARIS variable
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5dc6cfd6 [^]
(0040873)
Stefan Teleman (reporter)
2016-04-15 20:10

Thank you very much!
(0041191)
Kitware Robot (administrator)
2016-06-10 14:21

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2016-04-13 11:02 Stefan Teleman New Issue
2016-04-13 11:02 Stefan Teleman File Added: cmState.cxx-solaris.patch
2016-04-13 11:39 Brad King Note Added: 0040851
2016-04-13 14:08 Stefan Teleman Note Added: 0040852
2016-04-13 14:21 Stefan Teleman Note Added: 0040853
2016-04-13 14:24 Brad King Note Added: 0040854
2016-04-13 14:58 Stefan Teleman Note Added: 0040855
2016-04-13 15:10 Brad King Note Added: 0040856
2016-04-13 15:18 Stefan Teleman Note Added: 0040858
2016-04-13 15:20 Stefan Teleman Note Edited: 0040858
2016-04-13 17:04 Stefan Teleman File Added: cmState.cxx-solaris-v2.patch
2016-04-13 17:05 Stefan Teleman Note Added: 0040861
2016-04-15 13:26 Brad King Note Added: 0040867
2016-04-15 13:26 Brad King Status new => resolved
2016-04-15 13:26 Brad King Resolution open => fixed
2016-04-15 13:26 Brad King Fixed in Version => CMake 3.6
2016-04-15 13:26 Brad King Target Version => CMake 3.6
2016-04-15 20:10 Stefan Teleman Note Added: 0040873
2016-06-10 14:21 Kitware Robot Note Added: 0041191
2016-06-10 14:21 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team