]> code.ossystems Code Review - openembedded-core.git/blob
4addea3bf153798b5af99ba8b47dca6c370fb7e7
[openembedded-core.git] /
1 From edca667684764cfcc0460e448e834fadf623a887 Mon Sep 17 00:00:00 2001
2 From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3 Date: Mon, 3 Jul 2017 14:49:18 +0300
4 Subject: [PATCH] Support installing demos, support out-of-tree builds
5
6 This is especially useful for cross-compile situation where testing
7 happens on target.
8
9 -DRESOURCE_INSTALL_DIR=<path> decides where data is installed (and
10 where the binaries will load the data from): if it's left empty,
11 then nothing will be installed and binaries will load the data from
12 CMAKE_SOURCE_DIR.
13
14 Binaries are now correctly built in CMAKE_BINARY_DIR.
15
16 Upstream-Status: Submitted [https://github.com/SaschaWillems/Vulkan/pull/352]
17 Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
18 ---
19  CMakeLists.txt             | 15 ++++++++++++++-
20  base/vulkanexamplebase.cpp |  2 +-
21  2 files changed, 15 insertions(+), 2 deletions(-)
22
23 diff --git a/CMakeLists.txt b/CMakeLists.txt
24 index b9886bc..4958fff 100644
25 --- a/CMakeLists.txt
26 +++ b/CMakeLists.txt
27 @@ -16,6 +16,8 @@ include_directories(base)
28  OPTION(USE_D2D_WSI "Build the project using Direct to Display swapchain" OFF)
29  OPTION(USE_WAYLAND_WSI "Build the project using Wayland swapchain" OFF)
30  
31 +set(RESOURCE_INSTALL_DIR "" CACHE PATH "Path to install resources to (leave empty for running uninstalled)")
32 +
33  # Use FindVulkan module added with CMAKE 3.7
34  if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
35         message(STATUS "Using module to find Vulkan")
36 @@ -108,6 +110,10 @@ function(buildExample EXAMPLE_NAME)
37                 add_executable(${EXAMPLE_NAME} ${MAIN_CPP} ${SOURCE} ${SHADERS})
38                 target_link_libraries(${EXAMPLE_NAME} ${Vulkan_LIBRARY} ${ASSIMP_LIBRARIES} ${WAYLAND_CLIENT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
39         endif(WIN32)
40 +
41 +       if(RESOURCE_INSTALL_DIR)
42 +               install(TARGETS ${EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
43 +       endif()
44  endfunction(buildExample)
45  
46  # Build all examples
47 @@ -117,6 +123,13 @@ function(buildExamples)
48         endforeach(EXAMPLE)
49  endfunction(buildExamples)
50  
51 +if(RESOURCE_INSTALL_DIR)
52 +       add_definitions(-DVK_EXAMPLE_DATA_DIR=\"${RESOURCE_INSTALL_DIR}/\")
53 +       install(DIRECTORY data/ DESTINATION ${RESOURCE_INSTALL_DIR}/)
54 +else()
55 +       add_definitions(-DVK_EXAMPLE_DATA_DIR=\"${CMAKE_SOURCE_DIR}/data/\")
56 +endif()
57 +
58  # Compiler specific stuff
59  IF(MSVC)
60         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
61 @@ -128,7 +141,7 @@ ELSE(WIN32)
62         link_libraries(${XCB_LIBRARIES} ${Vulkan_LIBRARY})
63  ENDIF(WIN32)
64  
65 -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
66 +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/")
67  
68  set(EXAMPLES 
69         bloom
70 diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp
71 index 647368a..a0f28a5 100644
72 --- a/base/vulkanexamplebase.cpp
73 +++ b/base/vulkanexamplebase.cpp
74 @@ -84,7 +84,7 @@ const std::string VulkanExampleBase::getAssetPath()
75  #if defined(__ANDROID__)
76         return "";
77  #else
78 -       return "./../data/";
79 +       return VK_EXAMPLE_DATA_DIR;
80  #endif
81  }
82  #endif
83 -- 
84 2.13.2
85