summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 942df00)
raw | patch | inline | side by side (parent: 942df00)
author | Luke Yeager <luke.yeager@gmail.com> | |
Wed, 30 Sep 2015 20:28:36 +0000 (13:28 -0700) | ||
committer | Luke Yeager <luke.yeager@gmail.com> | |
Wed, 30 Sep 2015 20:28:36 +0000 (13:28 -0700) |
* shared library
* caffe binary (caffe --version)
* python module (caffe.__version__)
* caffe binary (caffe --version)
* python module (caffe.__version__)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 37f937fe4897a528084b527db73d059cacf1f731..606842b245588facd96efb0ff5af94447a67f4c4 100644 (file)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
# ---[ Caffe project
project(Caffe C CXX)
+# ---[ Caffe version
+set(CAFFE_TARGET_VERSION "0.14.0-alpha")
+set(CAFFE_TARGET_SOVERSION "0.14")
+add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION})
+
# ---[ Using cmake scripts and modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
diff --git a/Makefile b/Makefile
index 5fb6394e947b8afba9ec7a2b58610f63deb9d5b4..9d72bff78284de6b63916cf1e4db2fa7753ada20 100644 (file)
--- a/Makefile
+++ b/Makefile
\( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print)
# The target shared library name
+LIBRARY_NAME := $(PROJECT)$(LIBRARY_NAME_SUFFIX)
LIB_BUILD_DIR := $(BUILD_DIR)/lib
-STATIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).a
-DYNAMIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).so
+STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
+DYNAMIC_VERSION_MAJOR := 0
+DYNAMIC_VERSION_MINOR := 14
+DYNAMIC_VERSION_REVISION := 0-alpha
+DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
+DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR)
+DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_SONAME_SHORT).$(DYNAMIC_VERSION_REVISION)
+DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
+COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
##############################
# Get all source files
# boost::thread is reasonably called boost_thread (compare OS X)
# We will also explicitly add stdc++ to the link target.
LIBRARIES += boost_thread stdc++
+ VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_SONAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
endif
# OS X:
# we need to explicitly ask for the rpath to be obeyed
DYNAMIC_FLAGS := -install_name @rpath/libcaffe.so
ORIGIN := @loader_path
+ VERSIONFLAGS += -Wl,-install_name,$(DYNAMIC_SONAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
else
ORIGIN := \$$ORIGIN
endif
$(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@ $<
$(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \
- -o $@ $(LINKFLAGS) -l$(PROJECT) $(PYTHON_LDFLAGS) \
+ -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \
-Wl,-rpath,$(ORIGIN)/../../build/lib
mat$(PROJECT): mat
$(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
@ echo LD -o $@
- $(Q)$(CXX) -shared -o $@ $(OBJS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS)
+ $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS)
+ @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_SONAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_SONAME_SHORT)
+ @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_SONAME_SHORT) $(DYNAMIC_NAME_SHORT)
$(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
@ echo AR -o $@
| $(DYNAMIC_NAME) $(TEST_BIN_DIR)
@ echo CXX/LD -o $@ $<
$(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \
- -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib
+ -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib
$(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \
$(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
@ echo LD $<
$(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \
- -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib
+ -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib
$(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \
$(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
@ echo LD $<
$(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \
- -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib
+ -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib
# Target for extension-less symlinks to tool binaries with extension '*.bin'.
$(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR)
$(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@
- $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \
+ $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
-Wl,-rpath,$(ORIGIN)/../lib
$(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@
- $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \
+ $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
-Wl,-rpath,$(ORIGIN)/../../lib
proto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER)
# add libraries
cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib
cp $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib
+ cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_SONAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_SONAME_SHORT)
+ cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_SONAME_SHORT) $(DYNAMIC_NAME_SHORT)
# add python - it's not the standard way, indeed...
cp -r python $(DISTRIBUTE_DIR)/python
index a20bad2f5ce5e4dfc0b24dcebe84e4e99637ac20..29f7e35e7aec76961b10d36c9e20744c8149aa72 100644 (file)
--- a/Makefile.config.example
+++ b/Makefile.config.example
# enable pretty build (comment to see full commands)
Q ?= @
+
+# shared object suffix name to differentiate branches
+LIBRARY_NAME_SUFFIX := -nv
diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake
index 3d12e81a13020b4327b83da7ba2a1fbf419e5a52..966f5ef40e820bf0391276b85373141d058e817e 100644 (file)
--- a/cmake/Summary.cmake
+++ b/cmake/Summary.cmake
caffe_status("")
caffe_status("******************* Caffe Configuration Summary *******************")
caffe_status("General:")
- caffe_status(" Version : ${Caffe_VERSION}")
+ caffe_status(" Version : ${CAFFE_TARGET_VERSION}")
caffe_status(" Git : ${Caffe_GIT_VERSION}")
caffe_status(" System : ${CMAKE_SYSTEM_NAME}")
caffe_status(" C++ compiler : ${CMAKE_CXX_COMPILER}")
diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake
index 2401f252e9348243ceae21d060209668e86eefcc..8e649291020cee978d015194a66a846595ddfe7a 100644 (file)
--- a/cmake/Targets.cmake
+++ b/cmake/Targets.cmake
DEBUG_POSTFIX ${Caffe_DEBUG_POSTFIX}
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
- RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
+ RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin"
+ VERSION ${CAFFE_TARGET_VERSION}
+ SOVERSION ${CAFFE_TARGET_SOVERSION}
+ )
+
# make sure we build all external depepdencies first
if (DEFINED external_project_dependencies)
add_dependencies(${target} ${external_project_dependencies})
index ccda1bcae4f2325d700b439e79cff01ee95d5b22..b2a9d27f7644544a66291d212019571a2b41b21d 100644 (file)
--- a/python/caffe/__init__.py
+++ b/python/caffe/__init__.py
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list
+from ._caffe import CAFFE_VERSION as __version__
from .proto.caffe_pb2 import TRAIN, TEST
from .classifier import Classifier
from .detector import Detector
index ccd5776ac40e636b959546b740673127137dd9ae..d932e2f9f93738636ee2ff92e2faaafff0d50306 100644 (file)
--- a/python/caffe/_caffe.cpp
+++ b/python/caffe/_caffe.cpp
#define PyArray_SetBaseObject(arr, x) (PyArray_BASE(arr) = (x))
#endif
+// Hack to convert macro to string
+#define STRINGIZE(m) #m
+#define STRINGIZE2(m) STRINGIZE(m)
+
namespace bp = boost::python;
namespace caffe {
BOOST_PYTHON_MODULE(_caffe) {
// below, we prepend an underscore to methods that will be replaced
// in Python
+
+ bp::scope().attr("CAFFE_VERSION") = STRINGIZE2(CAFFE_VERSION);
+
// Caffe utility functions
bp::def("set_mode_cpu", &set_mode_cpu);
bp::def("set_mode_gpu", &set_mode_gpu);
index 40e6c11f5b015b05f68ec03bbb9c0e3e1cbfeccf..73ecd4496b1bb6be8164602c7d772d5657f4df48 100644 (file)
--- a/src/caffe/CMakeLists.txt
+++ b/src/caffe/CMakeLists.txt
add_library(caffe ${srcs})
target_link_libraries(caffe proto ${Caffe_LINKER_LIBS})
caffe_default_properties(caffe)
+set_target_properties(caffe PROPERTIES OUTPUT_NAME "caffe-nv")
# ---[ Tests
add_subdirectory(test)
diff --git a/tools/caffe.cpp b/tools/caffe.cpp
index e3f684b5ab33340015a3436f795ad37fddfc5873..2fd9b8043d2875bf3dbe204fe1803a0a3309b79d 100644 (file)
--- a/tools/caffe.cpp
+++ b/tools/caffe.cpp
namespace bp = boost::python;
#endif
+#include <gflags/gflags.h>
#include <glog/logging.h>
#include <cstring>
__Registerer_##func g_registerer_##func; \
}
+// Hack to convert macro to string
+#define STRINGIZE(m) #m
+#define STRINGIZE2(m) STRINGIZE(m)
+
static BrewFunction GetBrewFunction(const caffe::string& name) {
if (g_brew_map.count(name)) {
return g_brew_map[name];
int main(int argc, char** argv) {
// Print output to stderr (while still logging).
FLAGS_alsologtostderr = 1;
+ // Set version
+ gflags::SetVersionString(STRINGIZE2(CAFFE_VERSION));
// Usage message.
gflags::SetUsageMessage("command line brew\n"
"usage: caffe <command> <args>\n\n"