1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ # Detects the OS and sets appropriate variables.
16+ # CMAKE_SYSTEM_NAME only give us a coarse-grained name,
17+ # but the name like centos is necessary in some scenes
18+ # to distinguish system for customization.
19+ #
20+ # for instance, protobuf libs path is <install_dir>/lib64
21+ # on CentOS, but <install_dir>/lib on other systems.
22+
1523IF (WIN32 )
1624 SET (HOST_SYSTEM "win32" )
1725ELSE (WIN32 )
@@ -21,6 +29,7 @@ ELSE(WIN32)
2129 SET (MACOS_VERSION ${VERSION} )
2230 SET (HOST_SYSTEM "macosx" )
2331 ELSE (APPLE )
32+
2433 IF (EXISTS "/etc/issue" )
2534 FILE (READ "/etc/issue" LINUX_ISSUE)
2635 IF (LINUX_ISSUE MATCHES "CentOS" )
@@ -29,8 +38,24 @@ ELSE(WIN32)
2938 SET (HOST_SYSTEM "debian" )
3039 ELSEIF (LINUX_ISSUE MATCHES "Ubuntu" )
3140 SET (HOST_SYSTEM "ubuntu" )
41+ ELSEIF (LINUX_ISSUE MATCHES "Red Hat" )
42+ SET (HOST_SYSTEM "redhat" )
43+ ELSEIF (LINUX_ISSUE MATCHES "Fedora" )
44+ SET (HOST_SYSTEM "fedora" )
3245 ENDIF ()
3346 ENDIF (EXISTS "/etc/issue" )
47+
48+ IF (EXISTS "/etc/redhat-release" )
49+ FILE (READ "/etc/redhat-release" LINUX_ISSUE)
50+ IF (LINUX_ISSUE MATCHES "CentOS" )
51+ SET (HOST_SYSTEM "centos" )
52+ ENDIF ()
53+ ENDIF (EXISTS "/etc/redhat-release" )
54+
55+ IF (NOT HOST_SYSTEM )
56+ SET (HOST_SYSTEM ${CMAKE_SYSTEM_NAME} )
57+ ENDIF ()
58+
3459 ENDIF (APPLE )
3560ENDIF (WIN32 )
3661
@@ -47,7 +72,7 @@ SET(EXTERNAL_PROJECT_LOG_ARGS
4772 LOG_DOWNLOAD 0 # Wrap download in script to log output
4873 LOG_UPDATE 1 # Wrap update in script to log output
4974 LOG_CONFIGURE 1 # Wrap configure in script to log output
50- LOG_BUILD 1 # Wrap build in script to log output
75+ LOG_BUILD 0 # Wrap build in script to log output
5176 LOG_TEST 1 # Wrap test in script to log output
52- LOG_INSTALL 1 # Wrap install in script to log output
77+ LOG_INSTALL 0 # Wrap install in script to log output
5378)
0 commit comments