Browse Source

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.
master
Robin Krahl 2 years ago
parent
commit
bdaf2194e0
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      Makefile

+ 5
- 4
Makefile View File

@@ -10,7 +10,8 @@ DOCUMENTATION_DIR := doc
10 10
 SOURCE_NAMES_LIB := sqlitepp.cpp
11 11
 SOURCE_NAMES_TEST := sqlitepp_test.cpp
12 12
 
13
-TARGET_LIB := $(LIBRARY_DIR)/libsqlitepp.so
13
+TARGET_NAME_LIB := sqlitepp
14
+TARGET_LIB := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so
14 15
 SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/$(source))
15 16
 OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o)
16 17
 DEPENDS_LIB := $(OBJECTS_LIB:.o=.d)
@@ -28,7 +29,7 @@ DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST)
28 29
 CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR)
29 30
 CXXFLAGS += -fPIC
30 31
 LDFLAGS += $(LDFLAGS_SQLITE3)
31
-LDFLAGS_TEST += -L$(LIBRARY_DIR) -lsqlitepp $(LDFLAGS_GTEST)
32
+LDFLAGS_TEST += -L$(LIBRARY_DIR) -l$(TARGET_NAME_LIB) $(LDFLAGS_GTEST) -Wl,-rpath,$(LIBRARY_DIR)
32 33
 
33 34
 ifdef VERBOSE
34 35
 	QUIET :=
@@ -54,10 +55,10 @@ doc: $(INCLUDES)
54 55
 	doxygen
55 56
 
56 57
 memcheck: $(TARGET_TEST)
57
-	LD_LIBRARY_PATH=$(LIBRARY_DIR) valgrind --tool=memcheck ./$(TARGET_TEST)
58
+	valgrind --tool=memcheck ./$(TARGET_TEST)
58 59
 
59 60
 test: $(TARGET_TEST)
60
-	LD_LIBRARY_PATH=$(LIBRARY_DIR) ./$(TARGET_TEST)
61
+	./$(TARGET_TEST)
61 62
 
62 63
 $(TARGET_LIB): $(OBJECTS_LIB)
63 64
 	$(info (CXX)   $@)

Loading…
Cancel
Save