From a16fdbf605c8311472023b4f62a2862ee8f73f84 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Wed, 22 Apr 2015 19:39:45 +0300
Subject: [PATCH] Fix out-of-source build after adding
 test/app/module_api.test.lua

---
 cmake/utils.cmake            | 7 ++++++-
 test/app/module_api.test.lua | 3 +--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/cmake/utils.cmake b/cmake/utils.cmake
index 197d83b1e9..2402e4bd64 100644
--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -84,10 +84,15 @@ endfunction()
 function(apigen)
     set (dstfile "${CMAKE_BINARY_DIR}/src/module.h")
     set (tmpfile "${dstfile}.new")
+    set (headers)
+    # Get absolute path for header files (required of out-of-source build)
+    foreach (header ${ARGN})
+        list(APPEND headers ${CMAKE_CURRENT_SOURCE_DIR}/${header})
+    endforeach()
 
     add_custom_command(OUTPUT ${dstfile}
         COMMAND cat ${CMAKE_SOURCE_DIR}/src/module_header.h > ${tmpfile}
-        COMMAND cat ${ARGN} | ${CMAKE_SOURCE_DIR}/extra/apigen >> ${tmpfile}
+        COMMAND cat ${headers} | ${CMAKE_SOURCE_DIR}/extra/apigen >> ${tmpfile}
         COMMAND cat ${CMAKE_SOURCE_DIR}/src/module_footer.h >> ${tmpfile}
         COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmpfile} ${dstfile}
         COMMAND ${CMAKE_COMMAND} -E remove ${tmpfile}
diff --git a/test/app/module_api.test.lua b/test/app/module_api.test.lua
index b8e50193b6..0f28dca108 100755
--- a/test/app/module_api.test.lua
+++ b/test/app/module_api.test.lua
@@ -2,8 +2,7 @@
 
 box.cfg{logger = "tarantool.log"}
 
-local work_dir = require('fio').dirname(arg[0])
-package.cpath = work_dir..'/?.so;'
+package.cpath = '../app/?.so;'..package.cpath
 
 local test = require('tap').test("module_api", function(test)
     test:plan(7)
-- 
GitLab