Permalink
Browse files

Fix out of the source build

This allows use of a separate directory for source and object
files

Change-Id: I81186f503131f5ef72627146c1e9f6c0f1f5840a
Reviewed-on: http://review.couchbase.org/33933
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
  • Loading branch information...
1 parent 069ab01 commit 290dcd61cf7572dd76a21a299d4aed75c1c99d81 @trondn trondn committed Feb 26, 2014
Showing with 25 additions and 11 deletions.
  1. +12 −11 CMakeLists.txt
  2. +13 −0 src/couchscript.cc
View
@@ -8,6 +8,7 @@ INCLUDE(CheckTypeSize)
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../platform/include
${CMAKE_INSTALL_PREFIX}/include)
INCLUDE_DIRECTORIES(AFTER ${ICU_INCLUDE_DIR}
@@ -112,14 +113,14 @@ ADD_EXECUTABLE(couchscript src/couchscript.cc)
SET_TARGET_PROPERTIES(couchscript PROPERTIES COMPILE_FLAGS -I${LUA_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(couchscript couchstore ${LUA_LIBRARIES})
-ADD_TEST(couchstore-localdoc couchscript tests/localdoc.lua)
-ADD_TEST(couchstore-corrupt couchscript tests/corrupt.lua)
-ADD_TEST(couchstore-bulk couchscript tests/bulk.lua)
-ADD_TEST(couchstore-changes-since-filter couchscript tests/changessincefilter.lua)
-ADD_TEST(couchstore-compact couchscript tests/compact.lua)
-ADD_TEST(couchstore-dropdel couchscript tests/dropdel.lua)
-ADD_TEST(couchstore-largefile couchscript tests/largefile.lua)
-ADD_TEST(couchstore-large couchscript tests/large.lua)
+ADD_TEST(couchstore-localdoc couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/localdoc.lua)
+ADD_TEST(couchstore-corrupt couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/corrupt.lua)
+ADD_TEST(couchstore-bulk couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/bulk.lua)
+ADD_TEST(couchstore-changes-since-filter couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/changessincefilter.lua)
+ADD_TEST(couchstore-compact couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/compact.lua)
+ADD_TEST(couchstore-dropdel couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/dropdel.lua)
+ADD_TEST(couchstore-largefile couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/largefile.lua)
+ADD_TEST(couchstore-large couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/large.lua)
ENDIF(LUA_FOUND)
MACRO (M_ADD_PYTHON_TEST name pyfile)
@@ -129,9 +130,9 @@ MACRO (M_ADD_PYTHON_TEST name pyfile)
"LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}")
ENDMACRO()
-M_ADD_PYTHON_TEST(couchstore-purge tests/purge.py)
-M_ADD_PYTHON_TEST(couchstore-rewind tests/rewind.py)
-M_ADD_PYTHON_TEST(couchstore-changecount tests/changecount.py)
+M_ADD_PYTHON_TEST(couchstore-purge ${CMAKE_CURRENT_SOURCE_DIR}/tests/purge.py)
+M_ADD_PYTHON_TEST(couchstore-rewind ${CMAKE_CURRENT_SOURCE_DIR}/tests/rewind.py)
+M_ADD_PYTHON_TEST(couchstore-changecount ${CMAKE_CURRENT_SOURCE_DIR}/tests/changecount.py)
ADD_EXECUTABLE(couchstore_testapp tests/testapp.c
tests/file_merger_tests.c
View
@@ -7,6 +7,8 @@
#include <sysexits.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sstream>
+#include <string>
#include <libcouchstore/couch_db.h>
#include "internal.h"
@@ -791,6 +793,17 @@ int main(int argc, char **argv)
exit(EX_USAGE);
}
+ if (getenv("LUA_PATH") == NULL) {
+ std::string path = argv[1];
+ size_t pos = path.find_last_of("/\\");
+ if (pos != std::string::npos) {
+ path.resize(pos);
+ std::stringstream ss;
+ ss << "LUA_PATH=" << path << "/?.lua;;";
+ putenv(strdup(ss.str().c_str()));
+ }
+ }
+
lua_State *ls = luaL_newstate();
luaL_openlibs(ls);

0 comments on commit 290dcd6

Please sign in to comment.