From bdaf2194e083f691e468a560fd5934576dbb8221 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 27 Mar 2017 22:56:28 +0200 Subject: Makefile: Set the library directory when compiling sqlitepp_test Using the rpath linker option makes it possible to call sqlitepp_test directly without setting LD_LIBRARY_PATH. --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index fa94044..b3ad02f 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ DOCUMENTATION_DIR := doc SOURCE_NAMES_LIB := sqlitepp.cpp SOURCE_NAMES_TEST := sqlitepp_test.cpp -TARGET_LIB := $(LIBRARY_DIR)/libsqlitepp.so +TARGET_NAME_LIB := sqlitepp +TARGET_LIB := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/$(source)) OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o) DEPENDS_LIB := $(OBJECTS_LIB:.o=.d) @@ -28,7 +29,7 @@ DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST) CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR) CXXFLAGS += -fPIC LDFLAGS += $(LDFLAGS_SQLITE3) -LDFLAGS_TEST += -L$(LIBRARY_DIR) -lsqlitepp $(LDFLAGS_GTEST) +LDFLAGS_TEST += -L$(LIBRARY_DIR) -l$(TARGET_NAME_LIB) $(LDFLAGS_GTEST) -Wl,-rpath,$(LIBRARY_DIR) ifdef VERBOSE QUIET := @@ -54,10 +55,10 @@ doc: $(INCLUDES) doxygen memcheck: $(TARGET_TEST) - LD_LIBRARY_PATH=$(LIBRARY_DIR) valgrind --tool=memcheck ./$(TARGET_TEST) + valgrind --tool=memcheck ./$(TARGET_TEST) test: $(TARGET_TEST) - LD_LIBRARY_PATH=$(LIBRARY_DIR) ./$(TARGET_TEST) + ./$(TARGET_TEST) $(TARGET_LIB): $(OBJECTS_LIB) $(info (CXX) $@) -- cgit v1.2.3