| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a7ac8bc commit 67b497d
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,11 @@ endif() | |||
| 9 | 9 | # ---[ Caffe project | |
| 10 | 10 | project(Caffe C CXX) | |
| 11 | 11 | ||
| 12 | + # ---[ Caffe version | ||
| 13 | + set(CAFFE_TARGET_VERSION "1.0.0-rc3") | ||
| 14 | + set(CAFFE_TARGET_SOVERSION "1.0.0-rc3") | ||
| 15 | + add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION}) | ||
| 16 | + | ||
| 12 | 17 | # ---[ Using cmake scripts and modules | |
| 13 | 18 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) | |
| 14 | 19 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,9 +29,17 @@ SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \ | |||
| 29 | 29 | \( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print) | |
| 30 | 30 | ||
| 31 | 31 | # The target shared library name | |
| 32 | + LIBRARY_NAME := $(PROJECT) | ||
| 32 | 33 | LIB_BUILD_DIR := $(BUILD_DIR)/lib | |
| 33 | - STATIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).a | ||
| 34 | - DYNAMIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).so | ||
| 34 | + STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a | ||
| 35 | + DYNAMIC_VERSION_MAJOR := 1 | ||
| 36 | + DYNAMIC_VERSION_MINOR := 0 | ||
| 37 | + DYNAMIC_VERSION_REVISION := 0-rc3 | ||
| 38 | + DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so | ||
| 39 | + #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR) | ||
| 40 | + DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION) | ||
| 41 | + DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT) | ||
| 42 | + COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION) | ||
| 35 | 43 | ||
| 36 | 44 | ############################## | |
| 37 | 45 | # Get all source files | |
@@ -253,6 +261,7 @@ ifeq ($(LINUX), 1) | |||
| 253 | 261 | # boost::thread is reasonably called boost_thread (compare OS X) | |
| 254 | 262 | # We will also explicitly add stdc++ to the link target. | |
| 255 | 263 | LIBRARIES += boost_thread stdc++ | |
| 264 | + VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 256 | 265 | endif | |
| 257 | 266 | ||
| 258 | 267 | # OS X: | |
@@ -276,6 +285,7 @@ ifeq ($(OSX), 1) | |||
| 276 | 285 | # we need to explicitly ask for the rpath to be obeyed | |
| 277 | 286 | DYNAMIC_FLAGS := -install_name @rpath/libcaffe.so | |
| 278 | 287 | ORIGIN := @loader_path | |
| 288 | + VERSIONFLAGS += -Wl,-install_name,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib | ||
| 279 | 289 | else | |
| 280 | 290 | ORIGIN := \$$ORIGIN | |
| 281 | 291 | endif | |
@@ -478,7 +488,7 @@ py: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY) | |||
| 478 | 488 | $(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME) | |
| 479 | 489 | @ echo CXX/LD -o $@ $< | |
| 480 | 490 | $(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \ | |
| 481 | - -o $@ $(LINKFLAGS) -l$(PROJECT) $(PYTHON_LDFLAGS) \ | ||
| 491 | + -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \ | ||
| 482 | 492 | -Wl,-rpath,$(ORIGIN)/../../build/lib | |
| 483 | 493 | ||
| 484 | 494 | mat$(PROJECT): mat | |
@@ -542,7 +552,8 @@ $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK) | |||
| 542 | 552 | ||
| 543 | 553 | $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR) | |
| 544 | 554 | @ echo LD -o $@ | |
| 545 | - $(Q)$(CXX) -shared -o $@ $(OBJS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS) | ||
| 555 | + $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS) | ||
| 556 | + @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT) | ||
| 546 | 557 | ||
| 547 | 558 | $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR) | |
| 548 | 559 | @ echo AR -o $@ | |
@@ -573,19 +584,19 @@ $(TEST_ALL_BIN): $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \ | |||
| 573 | 584 | | $(DYNAMIC_NAME) $(TEST_BIN_DIR) | |
| 574 | 585 | @ echo CXX/LD -o $@ $< | |
| 575 | 586 | $(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \ | |
| 576 | - -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 587 | + -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 577 | 588 | ||
| 578 | 589 | $(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \ | |
| 579 | 590 | $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR) | |
| 580 | 591 | @ echo LD $< | |
| 581 | 592 | $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \ | |
| 582 | - -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 593 | + -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 583 | 594 | ||
| 584 | 595 | $(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \ | |
| 585 | 596 | $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR) | |
| 586 | 597 | @ echo LD $< | |
| 587 | 598 | $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \ | |
| 588 | - -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(PROJECT) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 599 | + -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib | ||
| 589 | 600 | ||
| 590 | 601 | # Target for extension-less symlinks to tool binaries with extension '*.bin'. | |
| 591 | 602 | $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR) | |
@@ -594,12 +605,12 @@ $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR) | |||
| 594 | 605 | ||
| 595 | 606 | $(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME) | |
| 596 | 607 | @ echo CXX/LD -o $@ | |
| 597 | - $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \ | ||
| 608 | + $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \ | ||
| 598 | 609 | -Wl,-rpath,$(ORIGIN)/../lib | |
| 599 | 610 | ||
| 600 | 611 | $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME) | |
| 601 | 612 | @ echo CXX/LD -o $@ | |
| 602 | - $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \ | ||
| 613 | + $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \ | ||
| 603 | 614 | -Wl,-rpath,$(ORIGIN)/../../lib | |
| 604 | 615 | ||
| 605 | 616 | proto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER) | |
@@ -661,6 +672,7 @@ $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS) | |||
| 661 | 672 | # add libraries | |
| 662 | 673 | cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib | |
| 663 | 674 | install -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib | |
| 675 | + cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT) | ||
| 664 | 676 | # add python - it's not the standard way, indeed... | |
| 665 | 677 | cp -r python $(DISTRIBUTE_DIR)/python | |
| 666 | 678 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,7 +101,7 @@ function(caffe_print_configuration_summary) | |||
| 101 | 101 | caffe_status("") | |
| 102 | 102 | caffe_status("******************* Caffe Configuration Summary *******************") | |
| 103 | 103 | caffe_status("General:") | |
| 104 | - caffe_status(" Version : ${Caffe_VERSION}") | ||
| 104 | + caffe_status(" Version : ${CAFFE_TARGET_VERSION}") | ||
| 105 | 105 | caffe_status(" Git : ${Caffe_GIT_VERSION}") | |
| 106 | 106 | caffe_status(" System : ${CMAKE_SYSTEM_NAME}") | |
| 107 | 107 | caffe_status(" C++ compiler : ${CMAKE_CXX_COMPILER}") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,10 @@ | |||
| 18 | 18 | ||
| 19 | 19 | #include "caffe/util/device_alternate.hpp" | |
| 20 | 20 | ||
| 21 | + // Convert macro to string | ||
| 22 | + #define STRINGIFY(m) #m | ||
| 23 | + #define AS_STRING(m) STRINGIFY(m) | ||
| 24 | + | ||
| 21 | 25 | // gflags 2.1 issue: namespace google was changed to gflags without warning. | |
| 22 | 26 | // Luckily we will be able to use GFLAGS_GFLAGS_H_ to detect if it is version | |
| 23 | 27 | // 2.1. If yes, we will add a temporary solution to redirect the namespace. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver | |
| 2 | 2 | from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list | |
| 3 | + from ._caffe import __version__ | ||
| 3 | 4 | from .proto.caffe_pb2 import TRAIN, TEST | |
| 4 | 5 | from .classifier import Classifier | |
| 5 | 6 | from .detector import Detector | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,6 +212,9 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SolveOverloads, Solve, 0, 1); | |||
| 212 | 212 | BOOST_PYTHON_MODULE(_caffe) { | |
| 213 | 213 | // below, we prepend an underscore to methods that will be replaced | |
| 214 | 214 | // in Python | |
| 215 | + | ||
| 216 | + bp::scope().attr("__version__") = AS_STRING(CAFFE_VERSION); | ||
| 217 | + | ||
| 215 | 218 | // Caffe utility functions | |
| 216 | 219 | bp::def("set_mode_cpu", &set_mode_cpu); | |
| 217 | 220 | bp::def("set_mode_gpu", &set_mode_gpu); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,10 @@ endif() | |||
| 20 | 20 | add_library(caffe ${srcs}) | |
| 21 | 21 | target_link_libraries(caffe proto ${Caffe_LINKER_LIBS}) | |
| 22 | 22 | caffe_default_properties(caffe) | |
| 23 | + set_target_properties(caffe PROPERTIES | ||
| 24 | + VERSION ${CAFFE_TARGET_VERSION} | ||
| 25 | + SOVERSION ${CAFFE_TARGET_SOVERSION} | ||
| 26 | + ) | ||
| 23 | 27 | ||
| 24 | 28 | # ---[ Tests | |
| 25 | 29 | add_subdirectory(test) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | namespace bp = boost::python; | |
| 4 | 4 | #endif | |
| 5 | 5 | ||
| 6 | + #include <gflags/gflags.h> | ||
| 6 | 7 | #include <glog/logging.h> | |
| 7 | 8 | ||
| 8 | 9 | #include <cstring> | |
@@ -378,6 +379,8 @@ RegisterBrewFunction(time); | |||
| 378 | 379 | int main(int argc, char** argv) { | |
| 379 | 380 | // Print output to stderr (while still logging). | |
| 380 | 381 | FLAGS_alsologtostderr = 1; | |
| 382 | + // Set version | ||
| 383 | + gflags::SetVersionString(AS_STRING(CAFFE_VERSION)); | ||
| 381 | 384 | // Usage message. | |
| 382 | 385 | gflags::SetUsageMessage("command line brew\n" | |
| 383 | 386 | "usage: caffe <command> <args>\n\n" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments