MantisBT - CMake
View Issue Details
0016061CMakeCMakepublic2016-04-13 11:022016-06-10 14:21
Stefan Teleman 
 
normaltrivialalways
closedfixed 
x86 x86_64 SPARCSolaris5.11, 5.12
CMake 3.5 
CMake 3.6CMake 3.6 
0016061: define SOLARIS and CMAKE_HOST_SOLARIS as a cmake built-in
in ${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.
Always - the SOLARIS/CMAKE_HOST_SOLARIS definition is not present
in cmake.
No tags attached.
patch cmState.cxx-solaris.patch (565) 2016-04-13 11:02
https://public.kitware.com/Bug/file/5675/cmState.cxx-solaris.patch
patch cmState.cxx-solaris-v2.patch (1,228) 2016-04-13 17:04
https://public.kitware.com/Bug/file/5676/cmState.cxx-solaris-v2.patch
Issue History
2016-04-13 11:02Stefan TelemanNew Issue
2016-04-13 11:02Stefan TelemanFile Added: cmState.cxx-solaris.patch
2016-04-13 11:39Brad KingNote Added: 0040851
2016-04-13 14:08Stefan TelemanNote Added: 0040852
2016-04-13 14:21Stefan TelemanNote Added: 0040853
2016-04-13 14:24Brad KingNote Added: 0040854
2016-04-13 14:58Stefan TelemanNote Added: 0040855
2016-04-13 15:10Brad KingNote Added: 0040856
2016-04-13 15:18Stefan TelemanNote Added: 0040858
2016-04-13 15:20Stefan TelemanNote Edited: 0040858bug_revision_view_page.php?bugnote_id=40858#r2070
2016-04-13 17:04Stefan TelemanFile Added: cmState.cxx-solaris-v2.patch
2016-04-13 17:05Stefan TelemanNote Added: 0040861
2016-04-15 13:26Brad KingNote Added: 0040867
2016-04-15 13:26Brad KingStatusnew => resolved
2016-04-15 13:26Brad KingResolutionopen => fixed
2016-04-15 13:26Brad KingFixed in Version => CMake 3.6
2016-04-15 13:26Brad KingTarget Version => CMake 3.6
2016-04-15 20:10Stefan TelemanNote Added: 0040873
2016-06-10 14:21Kitware RobotNote Added: 0041191
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040851)
Brad King   
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   
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   
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   
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   
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   
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   
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   
2016-04-13 17:05   
New patch - Version 2 - attached.
(0040867)
Brad King   
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   
2016-04-15 20:10   
Thank you very much!
(0041191)
Kitware Robot   
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.