Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Modules / CMakeSystemSpecificInformation.cmake
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4
5 # This file is included by cmGlobalGenerator::EnableLanguage.
6 # It is included after the compiler has been determined, so
7 # we know things like the compiler name and if the compiler is gnu.
8
9 # before cmake 2.6 these variables were set in cmMakefile.cxx. This is still
10 # done to keep scripts and custom language and compiler modules working.
11 # But they are reset here and set again in the platform files for the target
12 # platform, so they can be used for testing the target platform instead
13 # of testing the host platform.
14 set(APPLE  )
15 set(UNIX   )
16 set(CYGWIN )
17 set(MSYS )
18 set(WIN32  )
19 set(BSD )
20 set(LINUX )
21
22 function(_cmake_record_install_prefix )
23   set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_VALUE "${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE)
24   set(_CMAKE_SYSTEM_PREFIX_PATH_STAGING_PREFIX_VALUE "${CMAKE_STAGING_PREFIX}" PARENT_SCOPE)
25   set(icount 0)
26   set(scount 0)
27   foreach(value IN LISTS CMAKE_SYSTEM_PREFIX_PATH)
28     if(value STREQUAL CMAKE_INSTALL_PREFIX)
29       math(EXPR icount "${icount}+1")
30     endif()
31     if(value STREQUAL CMAKE_STAGING_PREFIX)
32       math(EXPR scount "${scount}+1")
33     endif()
34   endforeach()
35   set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_COUNT "${icount}" PARENT_SCOPE)
36   set(_CMAKE_SYSTEM_PREFIX_PATH_STAGING_PREFIX_COUNT "${scount}" PARENT_SCOPE)
37 endfunction()
38
39 # include Generic system information
40 include(CMakeGenericSystem)
41
42 # 2. now include SystemName.cmake file to set the system specific information
43 set(CMAKE_SYSTEM_INFO_FILE Platform/${CMAKE_SYSTEM_NAME})
44
45 include(${CMAKE_SYSTEM_INFO_FILE} OPTIONAL RESULT_VARIABLE _INCLUDED_SYSTEM_INFO_FILE)
46
47 if(NOT _INCLUDED_SYSTEM_INFO_FILE)
48   message("System is unknown to cmake, create:\n${CMAKE_SYSTEM_INFO_FILE}"
49           " to use this system, please post your config file on "
50           "discourse.cmake.org so it can be added to cmake")
51   if(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
52     configure_file(${CMAKE_BINARY_DIR}/CMakeCache.txt
53                    ${CMAKE_BINARY_DIR}/CopyOfCMakeCache.txt COPYONLY)
54     message("Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. "
55             "Please post that file on discourse.cmake.org.")
56   endif()
57 endif()
58
59 # optionally include a file which can do extra-generator specific things, e.g.
60 # CMakeFindEclipseCDT4.cmake asks gcc for the system include dirs for the Eclipse CDT4 generator
61 if(CMAKE_EXTRA_GENERATOR)
62   string(REPLACE " " "" _CMAKE_EXTRA_GENERATOR_NO_SPACES ${CMAKE_EXTRA_GENERATOR} )
63   include("CMakeFind${_CMAKE_EXTRA_GENERATOR_NO_SPACES}" OPTIONAL)
64 endif()
65
66
67 # for most systems a module is the same as a shared library
68 # so unless the variable CMAKE_MODULE_EXISTS is set just
69 # copy the values from the LIBRARY variables
70 # this has to be done after the system information has been loaded
71 if(NOT CMAKE_MODULE_EXISTS)
72   set(CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}")
73   set(CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
74 endif()
75
76
77 set(CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED 1)