diff --git a/hellocardboard-android/CMakeLists.txt b/hellocardboard-android/CMakeLists.txt index 8a19995..ce18344 100644 --- a/hellocardboard-android/CMakeLists.txt +++ b/hellocardboard-android/CMakeLists.txt @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.4.1) +cmake_minimum_required(VERSION 3.22.1) +project(hellocardboard_android VERSION 1.0.0 LANGUAGES CXX) # C++ flags. set(CMAKE_CXX_STANDARD 17) @@ -20,24 +21,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) add_compile_options(-Wall -Wextra) # Standard Android dependencies -find_library(android-lib android) -find_library(GLESv2-lib GLESv2) -find_library(GLESv3-lib GLESv3) -find_library(log-lib log) +find_library(ANDROID_LIB android) +find_library(GLESv2_LIB GLESv2) +find_library(GLESv3_LIB GLESv3) +find_library(LOG_LIB log) set(libs_dir ${CMAKE_CURRENT_SOURCE_DIR}/libraries) +set(CARDBOARD_LIB ${libs_dir}/jni/${ANDROID_ABI}/libGfxPluginCardboard.so) +set(CARDBOARD_INCLUDE_DIR ${libs_dir}) + # === Cardboard Sample === # Sources file(GLOB native_srcs "src/main/jni/*.cc") # Output binary add_library(cardboard_jni SHARED ${native_srcs}) # Includes -target_include_directories(cardboard_jni PRIVATE ${libs_dir}) +target_include_directories(cardboard_jni PRIVATE ${CARDBOARD_INCLUDE_DIR}) # Build target_link_libraries(cardboard_jni - ${android-lib} - ${GLESv2-lib} - ${GLESv3-lib} - ${log-lib} - ${libs_dir}/jni/${ANDROID_ABI}/libGfxPluginCardboard.so) + ${ANDROID_LIB} + ${GLESv2_LIB} + ${GLESv3_LIB} + ${LOG_LIB} + ${CARDBOARD_LIB}) diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index c70925b..758843d 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -12,21 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.4.1) +cmake_minimum_required(VERSION 3.22.1) +project(cardboard_sdk VERSION 1.0.0 LANGUAGES CXX) # C++ flags. set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) add_compile_options(-Wall -Wextra) +# If these are already defined, the existing value is used, rather then the default here. +option(CARDBOARDSDK_RENDERING_GLESv3 "Enable rendering with GLESv3" ON) +option(CARDBOARDSDK_RENDERING_VULKAN "Enable rendering with Vulkan" ON) +option(CARDBOARDSDK_UNITY_PLUGIN "Enable use as a Unity plugin" ON) + # Standard Android dependencies -find_library(android-lib android) -find_library(GLESv2-lib GLESv2) -find_library(log-lib log) +find_library(ANDROID_LIB android) +find_library(GLESv2_LIB GLESv2) +find_library(LOG_LIB log) # #gles3 - Library is only needed if OpenGL ES 3.0 support is desired. Remove # the following line if OpenGL ES 3.0 support is not needed. -find_library(GLESv3-lib GLESv3) +if(CARDBOARDSDK_RENDERING_GLESv3) + find_library(GLESv3_LIB GLESv3) +endif() include_directories(.) @@ -50,22 +58,27 @@ file(GLOB screen_params_srcs "screen_params/android/*.cc") file(GLOB device_params_srcs "device_params/android/*.cc") # Rendering Sources file(GLOB rendering_opengl_srcs "rendering/opengl_*.cc") -# #vulkan This is required for Vulkan rendering. Remove the following two lines -# if Vulkan rendering is not needed. -file(GLOB rendering_vulkan_srcs "rendering/android/*.cc") -file(GLOB rendering_vulkan_wrapper_srcs "rendering/android/vulkan/*.cc") - -# === Cardboard Unity JNI === -file(GLOB cardboard_unity_jni_srcs "unity/android/*.cc") - -# === Cardboard Unity Wrapper === -file(GLOB cardboard_xr_unity_srcs - "unity/xr_unity_plugin/*.cc" - "unity/xr_unity_plugin/vulkan/*.cc" -) -# === Cardboard XR Provider for Unity === -file(GLOB cardboard_xr_provider_srcs "unity/xr_provider/*.cc") +if(CARDBOARDSDK_RENDERING_VULKAN) + # #vulkan This is required for Vulkan rendering. Remove the following two lines + # if Vulkan rendering is not needed. + file(GLOB rendering_vulkan_srcs "rendering/android/*.cc") + file(GLOB rendering_vulkan_wrapper_srcs "rendering/android/vulkan/*.cc") +endif() + +if(CARDBOARDSDK_UNITY_PLUGIN) + # === Cardboard Unity JNI === + file(GLOB cardboard_unity_jni_srcs "unity/android/*.cc") + + # === Cardboard Unity Wrapper === + file(GLOB cardboard_xr_unity_srcs + "unity/xr_unity_plugin/*.cc" + "unity/xr_unity_plugin/vulkan/*.cc" + ) + + # === Cardboard XR Provider for Unity === + file(GLOB cardboard_xr_provider_srcs "unity/xr_provider/*.cc") +endif() # Output binary add_library(GfxPluginCardboard SHARED @@ -91,24 +104,41 @@ add_library(GfxPluginCardboard SHARED # Cardboard XR Provider for Unity sources ${cardboard_xr_provider_srcs}) -# Includes -target_include_directories(GfxPluginCardboard - PRIVATE ../third_party/unity_plugin_api) +if(CARDBOARDSDK_UNITY_PLUGIN) + # Includes + target_include_directories(GfxPluginCardboard + PRIVATE ../third_party/unity_plugin_api) +endif() -# #vulkan This is required for Vulkan rendering. Remove the following line if -# Vulkan rendering is not needed. -add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR=1) +if(CARDBOARDSDK_RENDERING_VULKAN) + # #vulkan This is required for Vulkan rendering. Remove the following line if + # Vulkan rendering is not needed. + target_compile_definitions(GfxPluginCardboard PUBLIC VK_USE_PLATFORM_ANDROID_KHR=1) +endif() # Build target_link_libraries(GfxPluginCardboard - ${android-lib} - ${GLESv2-lib} - # #gles3 - Library is only needed if OpenGL ES 3.0 support is desired. - # Remove the following line if OpenGL ES 3.0 support is not needed. - ${GLESv3-lib} - ${log-lib} - # #vulkan - This is required for Vulkan rendering (it is required to load - # libvulkan.so at runtime). Remove the following line if Vulkan rendering - # is not needed - dl + PUBLIC + ${ANDROID_LIB} + ${GLESv2_LIB} + ${LOG_LIB} ) + +if(CARDBOARDSDK_RENDERING_VULKAN) + target_link_libraries(GfxPluginCardboard + PUBLIC + # #vulkan - This is required for Vulkan rendering (it is required to load + # libvulkan.so at runtime). Remove the following line if Vulkan rendering + # is not needed + dl + ) +endif() + +if(CARDBOARDSDK_RENDERING_GLESv3) + target_link_libraries(GfxPluginCardboard + PUBLIC + # #gles3 - Library is only needed if OpenGL ES 3.0 support is desired. + # Remove the following line if OpenGL ES 3.0 support is not needed. + ${GLESv3_LIB} + ) +endif()