Skip to content

Commit

Permalink
Adapted for conan builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Musil committed Aug 17, 2022
1 parent 49ecef7 commit b3644c1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the minimum required version of CMake for this project.
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.15)

# Set project name.
project(OpenVRSDK)
Expand All @@ -22,7 +22,7 @@ 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_SHARED_LIBS "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)
Expand All @@ -42,7 +42,7 @@ endif()
# Get platform.
if(WIN32)
set(PLATFORM_NAME "win")
if(NOT BUILD_SHARED)
if(NOT BUILD_SHARED_LIBS)
add_definitions(-DOPENVR_BUILD_STATIC)
endif()
elseif(UNIX AND NOT APPLE)
Expand All @@ -68,9 +68,9 @@ elseif(APPLE)
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})
#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")
Expand All @@ -80,7 +80,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# Set custom libc++ usage here
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX)
if(USE_CUSTOM_LIBCXX)
if(BUILD_SHARED)
if(BUILD_SHARED_LIBS)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
Expand Down
28 changes: 14 additions & 14 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DBUILD_SHARED_LIBS=ON -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -18,7 +18,7 @@
"inheritEnvironments": [ "msvc_x86" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DBUILD_SHARED_LIBS=ON -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -29,7 +29,7 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DBUILD_SHARED_LIBS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -40,7 +40,7 @@
"inheritEnvironments": [ "msvc_x86" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -51,7 +51,7 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -62,7 +62,7 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -73,7 +73,7 @@
"inheritEnvironments": [ "msvc_x86" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=d -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -84,7 +84,7 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"cmakeCommandArgs": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -95,7 +95,7 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -106,7 +106,7 @@
"inheritEnvironments": [ "msvc_x86" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"cmakeCommandArgs": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
Expand All @@ -116,7 +116,7 @@
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_DEBUG_POSTFIX=cd -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DBUILD_SHARED_LIBS=ON -DCMAKE_DEBUG_POSTFIX=cd -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
Expand All @@ -139,7 +139,7 @@
"configurationType": "Release",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_SHARED=ON -DCMAKE_RELEASE_POSTFIX=c -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"cmakeCommandArgs": "-DBUILD_SHARED_LIBS=ON -DCMAKE_RELEASE_POSTFIX=c -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
Expand All @@ -162,7 +162,7 @@
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=cd -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=cd -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
Expand All @@ -185,7 +185,7 @@
"configurationType": "Release",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_RELEASE_POSTFIX=c -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"cmakeCommandArgs": "-DCMAKE_RELEASE_POSTFIX=c -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=\"MultiThreaded$<$<CONFIG:Debug>:Debug>\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
Expand Down
13 changes: 9 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ 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(BUILD_SHARED_LIBS 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)
endif(BUILD_SHARED_LIBS OR BUILD_FRAMEWORK)
elseif(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions( -DWIN64 )
Expand Down Expand Up @@ -66,7 +66,7 @@ source_group("VRCommon" FILES
)

# Build the library.
if(BUILD_SHARED)
if(BUILD_SHARED_LIBS)
add_library(${LIBNAME} SHARED ${SOURCE_FILES})
elseif(BUILD_FRAMEWORK)
set( LIBNAME "OpenVR" )
Expand Down Expand Up @@ -101,7 +101,12 @@ endif()
target_link_libraries(${LIBNAME} ${EXTRA_LIBS} ${CMAKE_DL_LIBS})
target_include_directories(${LIBNAME} PUBLIC ${OPENVR_HEADER_DIR})

install(TARGETS ${LIBNAME} DESTINATION lib)
install(TARGETS ${LIBNAME}
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

install(FILES ${PUBLIC_HEADER_FILES} DESTINATION include/openvr)

# Generate a .pc file for linux environments
Expand Down

0 comments on commit b3644c1

Please sign in to comment.