diff --git a/CMakeLists.txt b/CMakeLists.txt index 28276db..d0acab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,17 +5,12 @@ project(vsgvr DESCRIPTION "VulkanSceneGraph based virtual reality viewer" LANGUAGES CXX ) - set(VSGVR_SOVERSION 0) + option( BUILD_SHARED_LIBS "Build shared libraries" OFF ) option( VSGVR_BUILD_EXAMPLES "Whether to build VSGVR examples" ON ) -if( NOT CMAKE_BUILD_TYPE AND NOT MSVC ) - set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE ) - set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "MinSizeRel" "RelWithDebInfo" ) -endif() - if( NOT VSGVR_XR_PLATFORM ) # OPENXR_GENERIC - The standard openxr_loader.so, built from deps/openxr # OPENXR_SYSTEM - Whatever OpenXR is available via find_package @@ -30,11 +25,47 @@ set( OpenGL_GL_PREFERENCE GLVND ) # Package/System requirements if(ANDROID) + # On Android, allow vsg to be located outside the Android sysroot find_package(vsg 1.0.0 NO_CMAKE_FIND_ROOT_PATH) else() find_package(vsg 1.0.0) endif() +# vsgMacros.cmake - Follow vsg conventions for the most part +vsg_setup_dir_vars() +vsg_setup_build_vars() +set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "MinSizeRel" "RelWithDebInfo" ) +get_property( generator_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG ) +if( generator_is_multi_config ) + set( CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo" CACHE STRING "Build configuration types") +endif() + +# TODO: Will re-visit these, and fix when vsgvr is more mature +# (Dev primarily on Windows/Visual Studio, or in Android Studio) +# +# vsg_add_target_clang_format( +# FILES +# ${PROJECT_SOURCE_DIR}/vsgvr/include/vsgvr/*.h +# ${PROJECT_SOURCE_DIR}/vsgvr/srv/vsgvr/*.cpp +# ) +# vsg_add_target_cppcheck( +# FILES +# ${PROJECT_SOURCE_DIR}/vsgvr/include/vsgvr/*.h +# ${PROJECT_SOURCE_DIR}/vsgvr/srv/vsgvr/*.cpp +# ) +# vsg_add_target_docs( +# FILES +# ${PROJECT_SOURCE_DIR}/vsgvr/include +# ) +# vsg_add_target_clobber() + +vsg_add_target_uninstall() +vsg_add_feature_summary() +vsg_add_cmake_support_files( + CONFIG_TEMPLATE vsgvrConfig.cmake.in +) + +# Other Dependencies find_package(Vulkan REQUIRED) set(OpenXR_LIBRARY openxr_loader) @@ -60,30 +91,10 @@ elseif( VSGVR_XR_PLATFORM STREQUAL "OPENXR_OCULUS_MOBILE" ) "${VSGVR_OCULUS_OPENXR_MOBILE_SDK}/3rdParty/khronos/openxr/OpenXR-SDK/include") endif() -vsg_setup_dir_vars() -vsg_setup_build_vars() - -vsg_add_target_clang_format( - FILES - ${PROJECT_SOURCE_DIR}/vsgvr/include/vsgvr/*.h - ${PROJECT_SOURCE_DIR}/vsgvr/srv/vsgvr/*.cpp -) -vsg_add_target_cppcheck( - FILES - ${PROJECT_SOURCE_DIR}/vsgvr/include/vsgvr/*.h - ${PROJECT_SOURCE_DIR}/vsgvr/srv/vsgvr/*.cpp -) -vsg_add_target_clobber() -vsg_add_target_docs( - FILES - ${PROJECT_SOURCE_DIR}/vsgvr/include -) -vsg_add_target_uninstall() - +# VSGVR add_subdirectory( vsgvr ) if( VSGVR_BUILD_EXAMPLES ) add_subdirectory( examples ) endif() -vsg_add_feature_summary() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9d17adb..8ecab81 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,6 @@ if(ANDROID) -# Quest sample is loaded backwards - Open the project in Android Studio, and VSGVR will be included through CMake +# Quest samples are loaded backwards - Open the project in Android Studio, and VSGVR will be included through CMake else() add_subdirectory( generic ) endif() diff --git a/examples/generic/CMakeLists.txt b/examples/generic/CMakeLists.txt index c995891..233bc07 100644 --- a/examples/generic/CMakeLists.txt +++ b/examples/generic/CMakeLists.txt @@ -1,4 +1,8 @@ add_executable( vsgvr_example_generic main.cpp ) + target_link_libraries( vsgvr_example_generic vsg::vsg vsgvr ) +install(TARGETS vsgvr_example_generic) + +set_target_properties( vsgvr_example_generic PROPERTIES FOLDER "examples" ) diff --git a/vsgvr/CMakeLists.txt b/vsgvr/CMakeLists.txt index e3d5734..2cedf5c 100644 --- a/vsgvr/CMakeLists.txt +++ b/vsgvr/CMakeLists.txt @@ -1,9 +1,15 @@ -set( SOURCES +set( HEADERS_ACTIONS include/vsgvr/actions/OpenXRAction.h include/vsgvr/actions/OpenXRActionPoseBinding.h include/vsgvr/actions/OpenXRActionSet.h +) + +set( HEADERS_APP include/vsgvr/app/OpenXRViewer.h +) + +set( HEADERS_XR include/vsgvr/xr/OpenXRCommon.h include/vsgvr/xr/OpenXREventHandler.h include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h @@ -13,7 +19,9 @@ set( SOURCES include/vsgvr/xr/OpenXRSwapchain.h include/vsgvr/xr/OpenXRTraits.h include/vsgvr/xr/OpenXRViewMatrix.h +) +set( SOURCES src/vsgvr/actions/OpenXRAction.cpp src/vsgvr/actions/OpenXRActionPoseBinding.cpp src/vsgvr/actions/OpenXRActionSet.cpp @@ -27,24 +35,40 @@ set( SOURCES ) if( ANDROID ) - list(APPEND SOURCES + list(APPEND HEADERS_XR include/vsgvr/xr/OpenXRAndroidTraits.h + ) + list(APPEND SOURCES src/vsgvr/xr/OpenXRAndroidTraits.cpp ) endif() -add_library( vsgvr ${SOURCES} ${HEADERS} ) +add_library( vsgvr ${HEADERS_ACTIONS} ${HEADERS_APP} ${HEADERS_XR} ${SOURCES} ) -target_include_directories( - vsgvr PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include +target_include_directories(vsgvr PUBLIC + $ + $ ) + target_link_libraries( vsgvr PUBLIC vsg::vsg ${OpenXR_LIBRARY} ) +set_target_properties( vsgvr PROPERTIES FOLDER "vsgvr" ) + +# TODO: This needs to be in a header - Otherwise anyone linking to vsgvr without +# going through CMake will have to define it themselves if(WIN32 AND BUILD_SHARED_LIBS) target_compile_definitions(vsgvr PRIVATE "VSGVR_DECLSPEC=__declspec(dllexport)") target_compile_definitions(vsgvr INTERFACE "VSGVR_DECLSPEC=__declspec(dllimport)") else() - target_compile_definitions( vsgvr PUBLIC "VSGVR_DECLSPEC=" ) + target_compile_definitions(vsgvr PUBLIC "VSGVR_DECLSPEC=") endif() +set_target_properties(vsgvr PROPERTIES + VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} + SOVERSION ${VSGVR_SOVERSION} +) + +install(TARGETS vsgvr ${INSTALL_TARGETS_DEFAULT_FLAGS}) +install(FILES ${HEADERS_ACTIONS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vsgvr/actions) +install(FILES ${HEADERS_APP} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vsgvr/app) +install(FILES ${HEADERS_XR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vsgvr/xr) diff --git a/vsgvr/vsgvrConfig.cmake.in b/vsgvrConfig.cmake.in similarity index 100% rename from vsgvr/vsgvrConfig.cmake.in rename to vsgvrConfig.cmake.in