Created
November 11, 2018 22:46
-
-
Save jrandom/a245192f7e9c9ebebca4c445f8bb7798 to your computer and use it in GitHub Desktop.
OpenVR: Corrected src/CMakeLists.txt to allow building of static library using the instructions in src/README
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Project name. | |
project(openvr_api) | |
set( LIBNAME "openvr_api" ) | |
# Set some properies for specific files. | |
if(APPLE) | |
set(CMAKE_MACOSX_RPATH 1) | |
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") | |
set_source_files_properties(vrcommon/pathtools_public.cpp vrcommon/vrpathregistry_public.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++") | |
endif() | |
if(BUILD_SHARED OR BUILD_FRAMEWORK) | |
find_library(FOUNDATION_FRAMEWORK Foundation) | |
mark_as_advanced(FOUNDATION_FRAMEWORK) | |
set(EXTRA_LIBS ${EXTRA_LIBS} ${FOUNDATION_FRAMEWORK}) | |
endif(BUILD_SHARED OR BUILD_FRAMEWORK) | |
elseif(WIN32) | |
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | |
add_definitions( -DWIN64 ) | |
set( LIBNAME "openvr_api64" ) | |
endif() | |
endif() | |
# SYSTEM PROPERTIES | |
if(NOT PLATFORM) | |
if(CMAKE_SIZEOF_VOID_P MATCHES 8) | |
set(PLATFORM 64) | |
else() | |
set(PLATFORM 32) | |
endif() | |
endif() | |
message(STATUS "Compilation set for ${PLATFORM}bits architectures.") | |
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |
add_definitions(-DLINUX -DPOSIX) | |
set(ARCH_TARGET linux64) | |
if(${PLATFORM} MATCHES 32) | |
message(WARNING "OpenVR x86 binaries not provided on GNU/Linux.") | |
endif() | |
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |
set(CMAKE_MACOSX_RPATH 0) | |
add_definitions(-DOSX -DPOSIX) | |
set(ARCH_TARGET osx32) | |
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | |
add_definitions(-D_WIN32) | |
set(ARCH_TARGET win${PLATFORM}) | |
# Binaries path for thirdparties are not generics so we try to guess their suffixes. | |
set(WINDOWS_PATH_SUFFIXES win${PLATFORM} Win${PLATFORM} x${PLATFORM}) | |
endif() | |
# Add include folders. | |
include_directories(${CMAKE_SOURCE_DIR}) | |
include_directories(${CMAKE_SOURCE_DIR}/../headers) | |
include_directories(${CMAKE_SOURCE_DIR}/vrcommon) | |
if(USE_CUSTOM_LIBCXX) | |
link_directories( | |
${LIBCXX_LIB_DIR} | |
) | |
endif() | |
# Set the source group and files. | |
set(CORE_FILES | |
openvr_api_public.cpp | |
jsoncpp.cpp | |
) | |
set(VRCOMMON_FILES | |
vrcommon/dirtools_public.cpp | |
vrcommon/envvartools_public.cpp | |
vrcommon/pathtools_public.cpp | |
vrcommon/sharedlibtools_public.cpp | |
vrcommon/hmderrors_public.cpp | |
vrcommon/vrpathregistry_public.cpp | |
vrcommon/strtools_public.cpp | |
) | |
set(SOURCE_FILES | |
${CORE_FILES} | |
${VRCOMMON_FILES} | |
) | |
source_group("Src" FILES | |
${CORE_FILES} | |
) | |
source_group("VRCommon" FILES | |
${VRCOMMON_FILES} | |
) | |
# Build the library. | |
if(BUILD_SHARED) | |
add_library(${LIBNAME} SHARED ${SOURCE_FILES}) | |
elseif(BUILD_FRAMEWORK) | |
set( LIBNAME "OpenVR" ) | |
add_library( ${LIBNAME} | |
SHARED ${SOURCE_FILES} | |
${CMAKE_SOURCE_DIR}/headers/openvr.h | |
${CMAKE_SOURCE_DIR}/headers/openvr_api.cs | |
${CMAKE_SOURCE_DIR}/headers/openvr_api.json | |
${CMAKE_SOURCE_DIR}/headers/openvr_capi.h | |
${CMAKE_SOURCE_DIR}/headers/openvr_driver.h | |
) | |
set_target_properties(OpenVR PROPERTIES | |
FRAMEWORK TRUE | |
FRAMEWORK_VERSION A | |
MACOSX_FRAMEWORK_IDENTIFIER com.valvesoftware.OpenVR.framework | |
MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/Info.plist | |
# "current version" in semantic format in Mach-O binary file | |
VERSION 1.0.6 | |
# "compatibility version" in semantic format in Mach-O binary file | |
SOVERSION 1.0.0 | |
PUBLIC_HEADER "${CMAKE_SOURCE_DIR}/headers/openvr.h;${CMAKE_SOURCE_DIR}/headers/openvr_api.cs;${CMAKE_SOURCE_DIR}/headers/openvr_api.json;${CMAKE_SOURCE_DIR}/headers/openvr_capi.h;${CMAKE_SOURCE_DIR}/headers/openvr_driver.h" | |
LINKER_LANGUAGE CXX | |
) | |
else() | |
add_library(${LIBNAME} STATIC ${SOURCE_FILES}) | |
endif() | |
if(USE_CUSTOM_LIBCXX) | |
set(EXTRA_LIBS ${EXTRA_LIBS} c++ c++abi) | |
endif() | |
target_link_libraries(${LIBNAME} ${EXTRA_LIBS}) | |
install(TARGETS ${LIBNAME} DESTINATION lib) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment