diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29b69c5c..3e63475f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,7 @@ if(APPLE) elseif(WIN32) if(CMAKE_SIZEOF_VOID_P EQUAL 8) add_definitions( -DWIN64 ) - set( LIBNAME "openvr_api64" ) + # set( LIBNAME "openvr_api64" ) endif() endif() @@ -99,11 +99,46 @@ if(USE_CUSTOM_LIBCXX) endif() target_link_libraries(${LIBNAME} ${EXTRA_LIBS} ${CMAKE_DL_LIBS}) -target_include_directories(${LIBNAME} PUBLIC ${OPENVR_HEADER_DIR}) - -install(TARGETS ${LIBNAME} DESTINATION lib) +target_include_directories(${LIBNAME} + PUBLIC + $ + $) install(FILES ${PUBLIC_HEADER_FILES} DESTINATION include/openvr) +##### Installation targets ##### +install(TARGETS ${LIBNAME} EXPORT OpenVRTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) + +##### Export files ##### +if (WIN32) + set(PKG_PREFIX "cmake") +else () + set(PKG_PREFIX "lib/cmake/OpenVR") +endif () + +include(CMakePackageConfigHelpers) +write_basic_package_version_file("${CMAKE_BINARY_DIR}/OpenVRConfigVersion.cmake" + VERSION ${OPENVR_VERSION} + COMPATIBILITY AnyNewerVersion +) + +install(EXPORT OpenVRTargets + FILE OpenVRTargets.cmake + NAMESPACE OpenVR:: + DESTINATION ${PKG_PREFIX} +) + +install( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/OpenVRConfig.cmake + ${CMAKE_BINARY_DIR}/OpenVRConfigVersion.cmake + DESTINATION ${PKG_PREFIX} + COMPONENT Devel +) + + # Generate a .pc file for linux environments if(PLATFORM_NAME MATCHES "linux") set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") diff --git a/src/OpenVRConfig.cmake b/src/OpenVRConfig.cmake new file mode 100644 index 00000000..fbc177b0 --- /dev/null +++ b/src/OpenVRConfig.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/OpenVRTargets.cmake")