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
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) $@)

Loading…
Cancel
Save