Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename CMake Options #1156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ string(REGEX REPLACE "${VERSION_BUILD_REGEX}" "\\1" VERSION_BUILD ${VERSION_BUIL
set(OPENVR_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")

# 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)
option(OPENVR_BUILD_SHARED "Builds the library as shared library" OFF)
option(OPENVR_BUILD_FRAMEWORK "Builds the library as an apple Framework" OFF)
option(OPENVR_BUILD_UNIVERSAL "Builds the shared or framework as a universal (fat, 32- & 64-bit) binary" ON)
option(OPENVR_BUILD_OSX_I386 "Builds the shared or framework as a 32-bit binary, even on a 64-bit platform" OFF)
option(OPENVR_USE_LIBCXX "Uses libc++ instead of libstdc++" ON)
option(OPENVR_USE_CUSTOM_LIBCXX "Uses a custom libc++" OFF)

add_definitions( -DVR_API_PUBLIC )

Expand All @@ -42,7 +42,7 @@ endif()
# Get platform.
if(WIN32)
set(PLATFORM_NAME "win")
if(NOT BUILD_SHARED)
if(NOT OPENVR_BUILD_SHARED)
add_definitions(-DOPENVR_BUILD_STATIC)
endif()
elseif(UNIX AND NOT APPLE)
Expand All @@ -57,30 +57,26 @@ 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)
if(OPENVR_BUILD_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
endif()
if(BUILD_OSX_I386)
if(OPENVR_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_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_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)
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND OPENVR_USE_LIBCXX)
if(OPENVR_USE_CUSTOM_LIBCXX)
if(OPENVR_BUILD_SHARED)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
Expand Down
13 changes: 6 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ if(APPLE)
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)
if(OPENVR_BUILD_SHARED OR OPENVR_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)
endif(OPENVR_BUILD_SHARED OR OPENVR_BUILD_FRAMEWORK)
elseif(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions( -DWIN64 )
set( LIBNAME "openvr_api64" )
endif()
endif()

# Add include folders.
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../headers ${CMAKE_CURRENT_SOURCE_DIR}/vrcommon)

if(USE_CUSTOM_LIBCXX)
if(OPENVR_USE_CUSTOM_LIBCXX)
link_directories(
${LIBCXX_LIB_DIR}
)
Expand Down Expand Up @@ -66,9 +65,9 @@ source_group("VRCommon" FILES
)

# Build the library.
if(BUILD_SHARED)
if(OPENVR_BUILD_SHARED)
add_library(${LIBNAME} SHARED ${SOURCE_FILES})
elseif(BUILD_FRAMEWORK)
elseif(OPENVR_BUILD_FRAMEWORK)
set( LIBNAME "OpenVR" )
add_library( ${LIBNAME}
SHARED ${SOURCE_FILES}
Expand All @@ -94,7 +93,7 @@ else()
add_library(${LIBNAME} STATIC ${SOURCE_FILES})
endif()

if(USE_CUSTOM_LIBCXX)
if(OPENVR_USE_CUSTOM_LIBCXX)
set(EXTRA_LIBS ${EXTRA_LIBS} c++ c++abi)
endif()

Expand Down