Skip to content

Commit 4be5ffa

Browse files
authored
Merge pull request #1195 from gangliao/sys
detect redhat and unknown in CMake
2 parents 7f0ad62 + febf9a0 commit 4be5ffa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cmake/system.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
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+
1523
IF(WIN32)
1624
SET(HOST_SYSTEM "win32")
1725
ELSE(WIN32)
@@ -30,6 +38,10 @@ ELSE(WIN32)
3038
SET(HOST_SYSTEM "debian")
3139
ELSEIF(LINUX_ISSUE MATCHES "Ubuntu")
3240
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")
3345
ENDIF()
3446
ENDIF(EXISTS "/etc/issue")
3547

@@ -40,6 +52,10 @@ ELSE(WIN32)
4052
ENDIF()
4153
ENDIF(EXISTS "/etc/redhat-release")
4254

55+
IF(NOT HOST_SYSTEM)
56+
SET(HOST_SYSTEM ${CMAKE_SYSTEM_NAME})
57+
ENDIF()
58+
4359
ENDIF(APPLE)
4460
ENDIF(WIN32)
4561

0 commit comments

Comments
 (0)