diff --git a/CMakeLists.txt b/CMakeLists.txt index 01cffc7c9..82ca38782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ else() endif() # set the minimum required version across the board -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.1.0) project(OpenMW) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index ee4c61a6c..697391dd9 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -207,7 +207,6 @@ if (MSVC) endif (MSVC) if(BUILD_OPENMW) - if (NOT ANDROID) openmw_add_executable(openmw ${OPENMW_FILES} @@ -236,12 +235,17 @@ if(BUILD_OPENMW) endif() if(BUILD_OPENMW_VR) +# Use of FetchContent to include the OpenXR SDK requires CMake 3.11 + if(${CMAKE_VERSION} VERSION_LESS "3.11") + message(FATAL_ERROR "Building openmw_vr requires CMake version 3.11 or later.") + endif() + # TODO: Openmw and openmw_vr should preferrably share game code as a static or shared library # instead of being compiled separately, though for now that's not possible as i depend on # USE_OPENXR preprocessor switches. set(OPENMW_VR_FILES vrengine.cpp - ) + ) add_openmw_dir (mwvr openxraction openxrinput openxrmanager openxrmanagerimpl openxrswapchain openxrswapchainimpl realisticcombat @@ -263,7 +267,10 @@ if(BUILD_OPENMW_VR) GIT_TAG release-1.0.9 ) FetchContent_MakeAvailable(OpenXR) + target_link_libraries(openmw_vr openxr_loader) + # openxr makes include directories private + # Delete this line when the issue is solved: https://github.com/KhronosGroup/OpenXR-SDK-Source/issues/195 target_include_directories(openmw_vr PRIVATE ${openxr_SOURCE_DIR}/include) # Preprocessor variable used to control code paths to vr code diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake index 2408cae2b..b86c32a8f 100644 --- a/cmake/OpenMWMacros.cmake +++ b/cmake/OpenMWMacros.cmake @@ -205,3 +205,15 @@ macro (copy_all_resource_files source_dir destination_dir_base destination_dir_r copy_resource_file("${source_dir}/${f}" "${destination_dir_base}" "${destination_dir_relative}/${filename}") endforeach (f) endmacro (copy_all_resource_files) + +if(NOT ${CMAKE_VERSION} VERSION_LESS 3.11) + if(${CMAKE_VERSION} VERSION_LESS 3.14) + macro(FetchContent_MakeAvailable NAME) + FetchContent_GetProperties(${NAME}) + if(NOT ${NAME}_POPULATED) + FetchContent_Populate(${NAME}) + add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR}) + endif() + endmacro() + endif() +endif() \ No newline at end of file