forked from ValveSoftware/openvr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
76 lines (67 loc) · 2.53 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Set the minimum required version of CMake for this project.
cmake_minimum_required(VERSION 2.8)
# Set project name.
project(OpenVRSDK)
# Setup some options.
option(BUILD_SHARED "Builds the library as shared library" OFF)
option(BUILD_FRAMEWORK "Builds the library as an apple Framework" OFF)
option(BUILD_UNIVERSAL "Builds the shared or framework as a universal (fat, 32- & 64-bit) binary" ON)
option(BUILD_OSX_I386 "Builds the shared or framework as a 32-bit binary, even on a 64-bit platform" OFF)
option(USE_LIBCXX "Uses libc++ instead of libstdc++" ON)
option(USE_CUSTOM_LIBCXX "Uses a custom libc++" OFF)
add_definitions( -DVR_API_PUBLIC )
# Check if 32 or 64 bit system.
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PROCESSOR_ARCH "64")
else()
set(PROCESSOR_ARCH "32")
endif()
# Get platform.
if(WIN32)
set(PLATFORM_NAME "win")
elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(PLATFORM_NAME "linux")
add_definitions(-DLINUX -DPOSIX)
if(PROCESSOR_ARCH MATCHES "64")
add_definitions(-DLINUX64)
endif()
endif()
elseif(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*" OR CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(PLATFORM_NAME "osx")
add_definitions(-DOSX -DPOSIX)
if(BUILD_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
endif()
if(BUILD_OSX_I386)
set(PROCESSOR_ARCH "32")
set(CMAKE_OSX_ARCHITECTURES "i386")
endif()
endif()
endif()
# Set output folder for static and shared libraries
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH})
# Enable some properties.
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# Enable c++11 and hide symbols which shouldn't be visible
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -fvisibility=hidden")
# Set custom libc++ usage here
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX)
if(USE_CUSTOM_LIBCXX)
if(BUILD_SHARED)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
include_directories( ${LIBCXX_INCLUDE} ${LIBCXX_ABI_INCLUDE})
message(STATUS "Using custom libc++")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
message(STATUS "Using libc++")
endif()
endif()
endif()
add_subdirectory(src)