1
0
Fork 0

Fix OS detection for rocksdb. this fixes #1814

This commit is contained in:
Wilfried Goesgens 2016-05-09 11:06:25 +02:00
parent 21b27485ee
commit 030233a642
1 changed files with 61 additions and 4 deletions

View File

@ -73,12 +73,69 @@ endif()
set(ROCKSDB_PLATFORM_POSIX 1)
################################################################################
## OPERATION SYSTEM
################################################################################
set(OS_DEFINE "")
if (WIN32)
set(WINDOWS TRUE)
set(MSBUILD TRUE)
set(OS_DEFINE "OS_WIN")
elseif (UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(LINUX TRUE)
set(OS_DEFINE "OS_LINUX")
elseif (CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(FREEBSD TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(NETBSD TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(OPENBSD TRUE)
set(OS_DEFINE "OS_OPENBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(GNU TRUE)
set(OS_DEFINE "OS_LINUX")
elseif (CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(BSDI TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(FREEBSD TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SYSV5 TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif ((CMAKE_SYSTEM_NAME MATCHES "Solaris.*") OR (CMAKE_SYSTEM_NAME MATCHES "SunOS.*"))
set(SOLARIS TRUE)
set(OS_DEFINE "OS_SOLARIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(HPUX TRUE)
set(OS_DEFINE "OS_SOLARIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(AIX TRUE)
set(OS_DEFINE "OS_SOLARIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(MINIX TRUE)
set(OS_DEFINE "OS_FREEBSD")
endif ()
elseif (APPLE)
if (CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(DARWIN TRUE)
set(OS_DEFINE "OS_MACOSX")
elseif (CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(MACOSX TRUE)
set(OS_DEFINE "OS_MACOSX")
endif ()
endif ()
if (CMAKE_COMPILER_IS_GNUCC)
if (VERBOSE)
message(STATUS "Compiler type GNU: ${CMAKE_CXX_COMPILER}")
endif ()
set(BASE_FLAGS "${BASE_FLAGS} -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -fno-omit-frame-pointer -momit-leaf-frame-pointer -fno-builtin-memcmp -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -march=native -isystem -fPIC")
set(BASE_FLAGS "${BASE_FLAGS} -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -fno-omit-frame-pointer -momit-leaf-frame-pointer -fno-builtin-memcmp -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -march=native -isystem -fPIC -D${OS_DEFINE}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -Werror" CACHE INTERNAL "C debug flags")
@ -97,7 +154,7 @@ elseif (CMAKE_COMPILER_IS_CLANG)
message(STATUS "Compiler type CLANG: ${CMAKE_CXX_COMPILER}")
endif ()
set(BASE_FLAGS "${BASE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(BASE_FLAGS "${BASE_FLAGS} -Wall -Wextra -Wno-unused-parameter -D${OS_DEFINE}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")
@ -113,7 +170,7 @@ elseif (CMAKE_COMPILER_IS_CLANG)
elseif (MSVC)
if (VERBOSE)
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER} -D${OS_DEFINE}")
endif ()
set(CMAKE_C_FLAGS "/MTd" CACHE INTERNAL "default C++ compiler flags")
@ -145,7 +202,7 @@ else ()
# unknown compiler
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
set(BASE_FLAGS "${BASE_FLAGS} -Wall")
set(BASE_FLAGS "${BASE_FLAGS} -Wall -D${OS_DEFINE}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")