Unreviewed, silence -Wimplicit-fallthrough in openvr
[WebKit-https.git] / Source / ThirdParty / openvr / CMakeLists.txt
1 # Set the minimum required version of CMake for this project.
2 cmake_minimum_required(VERSION 2.8)
3
4 # Setup some options.
5 option(BUILD_SHARED "Builds the library as shared library" OFF)
6 option(USE_LIBCXX "Uses libc++ instead of libstdc++" ON)
7 option(USE_CUSTOM_LIBCXX "Uses a custom libc++" OFF)
8
9 add_definitions( -DVR_API_PUBLIC )
10
11 # Check if 32 or 64 bit system.
12 set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
13 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
14   set(PROCESSOR_ARCH "64")
15 else()
16   set(PROCESSOR_ARCH "32")
17 endif()
18
19 # Get platform.
20 if(WIN32)
21        set(PLATFORM_NAME "win")
22 elseif(UNIX AND NOT APPLE)
23   if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
24     set(PLATFORM_NAME "linux")
25     add_definitions(-DLINUX -DPOSIX)
26     if(PROCESSOR_ARCH MATCHES "64")
27         add_definitions(-DLINUX64)
28     endif()
29   endif()
30 elseif(APPLE)
31   if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*" OR CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
32     set(PLATFORM_NAME "osx")
33     add_definitions(-DOSX -DPOSIX)
34   endif()
35 endif()
36
37 # Enable some properties.
38 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
39        # Enable c++11 and hide symbols which shouldn't be visible
40        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -fvisibility=hidden")
41
42        # Set custom libc++ usage here
43        if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX)
44               if(USE_CUSTOM_LIBCXX)
45                      if(BUILD_SHARED)
46                             set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
47                      endif()
48                      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
49                      include_directories( ${LIBCXX_INCLUDE} ${LIBCXX_ABI_INCLUDE})
50                      message(STATUS "Using custom libc++")
51               else()
52                      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
53                      message(STATUS "Using libc++")
54               endif()
55        endif()
56 endif()
57
58 add_subdirectory(src)