Skip to content

Commit

Permalink
added gflags + bugfixes + rebase on bvlc/caffe
Browse files Browse the repository at this point in the history
* added gflags requirement in CMake
* fixed a bug that linked some tests into caffe lib
* renamed tools/caffe due to conflicting target names with caffe lib
* rebased onto bvlc/caffe
  • Loading branch information
Adam Kosiorek authored and jeffdonahue committed Aug 17, 2014
1 parent f2f3b4c commit 9f9b013
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 14 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ before_install:

install:
# CMake 2.8.12
<<<<<<< HEAD
- wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz -O /tmp/cmake.tar.gz && tar -C /tmp -xvf /tmp/cmake.tar.gz && rm /tmp/cmake.tar.gz
- cd /tmp/cmake-2.8.12 && ./bootstrap --prefix=/usr && make -j4 && sudo make install -j4 && cd - #&& rm -r /tmp/cmake-2.8.12
=======
- wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Linux-i386.tar.gz -O /tmp/cmake.tar.gz && tar -C /tmp -xvf /tmp/cmake.tar.gz && rm /tmp/cmake.tar.gz
- wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Linux-i386.tar.gz -O /tmp/cmake.tar.gz && tar -C /tmp -xvf /tmp/cmake.tar.gz && rm /tmp/cmake.tar.gz
- cd /tmp/cmake-2.8.12.2-Linux-i386 && sudo cp * /usr/ -r && cd - && rm -r /tmp/cmake-2.8.12.2-Linux-i386
>>>>>>> cmake from binaries
#
- wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz -O /tmp/glog-0.3.3.tar.gz && tar -C /tmp -xzvf /tmp/glog-0.3.3.tar.gz && rm /tmp/glog-0.3.3.tar.gz
- cd /tmp/glog-0.3.3 && ./configure && make -j4 && sudo make install -j4 && cd -
Expand Down Expand Up @@ -63,7 +58,7 @@ script:
## Cleaning
- cd ..
- rm -r build

# Make build
## CPU-GPU: build only.
- export CPU_ONLY=0
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ endif()
### Configuration ###########################################################################
# Compiler Flags
set(CMAKE_CXX_COMPILER_FLAGS ${CMAKE_CXX_COMPILER_FLAGS} -Wall)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )#-O3)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )#set global flags here)
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} )#set debug flags here)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )#set release flags here)

# Global Definitions
if(CPU_ONLY)
Expand Down
48 changes: 48 additions & 0 deletions CMakeScripts/FindGFlags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# - Try to find GFLAGS
#
# The following variables are optionally searched for defaults
# GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found
#
# The following are set after configuration is done:
# GFLAGS_FOUND
# GFLAGS_INCLUDE_DIRS
# GFLAGS_LIBRARIES
# GFLAGS_LIBRARYRARY_DIRS

include(FindPackageHandleStandardArgs)

set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags")

# We are testing only a couple of files in the include directories
if(WIN32)
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
PATHS ${GFLAGS_ROOT_DIR}/src/windows)
else()
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
PATHS ${GFLAGS_ROOT_DIR})
endif()

if(MSVC)
find_library(GFLAGS_LIBRARY_RELEASE
NAMES libgflags
PATHS ${GFLAGS_ROOT_DIR}
PATH_SUFFIXES Release)

find_library(GFLAGS_LIBRARY_DEBUG
NAMES libgflags-debug
PATHS ${GFLAGS_ROOT_DIR}
PATH_SUFFIXES Debug)

set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG})
else()
find_library(GFLAGS_LIBRARY gflags)
endif()

find_package_handle_standard_args(GFLAGS DEFAULT_MSG
GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)


if(GFLAGS_FOUND)
set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY})
endif()
11 changes: 9 additions & 2 deletions src/caffe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ find_package(Threads REQUIRED)
find_package(Glog REQUIRED)
include_directories(${GLOG_INCLUDE_DIRS})

# Google-gflags
find_package(GFlags REQUIRED)
include_directories(${GFLAGS_INCLUDE_DIRS})

# BLAS
if(BLAS STREQUAL "atlas")

Expand Down Expand Up @@ -61,13 +65,13 @@ add_subdirectory(proto)

# Recursively find source files
## test sources
file(GLOB_RECURSE TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_*.cpp)
file(GLOB_RECURSE TEST_CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_*.cpp)

## all cpp sources
file(GLOB_RECURSE CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

## remove test sources from cpp sources
list(REMOVE_ITEM CPP_SOURCES ${TEST_SOURCES})
list(REMOVE_ITEM CPP_SOURCES ${TEST_CPP_SOURCES})

add_library(caffe ${CPP_SOURCES})
# both depend on proto
Expand All @@ -84,6 +88,8 @@ if(NOT CPU_ONLY)

# cuda sources
file(GLOB_RECURSE CU_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
file(GLOB_RECURSE TEST_CU_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_*.cu)
list(REMOVE_ITEM CU_SOURCES ${TEST_CU_SOURCES})
cuda_add_library(caffe_cu ${CU_SOURCES})
add_dependencies(caffe_cu proto)
target_link_libraries(caffe caffe_cu
Expand All @@ -94,6 +100,7 @@ endif()

target_link_libraries(caffe proto
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES}
${HDF5_LIBRARIES}
${OpenCV_LIBS}
${LEVELDB_LIBS}
Expand Down
10 changes: 7 additions & 3 deletions src/caffe/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ include_directories(
)

set(TEST_MAIN test_caffe_main.cpp)
list(REMOVE_ITEM TEST_SOURCES ${TEST_MAIN})
list(REMOVE_ITEM TEST_CPP_SOURCES ${TEST_MAIN})

if(NOT CPU_ONLY)
set(TEST_CPP_SOURCES ${TEST_CPP_SOURCES} ${TEST_CU_SOURCES})
endif()

# Build each test separately
foreach(source ${TEST_SOURCES})
foreach(source ${TEST_CPP_SOURCES})
get_filename_component(name ${source} NAME_WE)
set(TEST_NAME ${name}${TEST_EXT})
add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_MAIN} ${source} ../blob.cpp)
Expand All @@ -50,7 +54,7 @@ foreach(source ${TEST_SOURCES})
endforeach()

# Build a compound test excluded from the ALL target
add_executable(${ALL_TEST} EXCLUDE_FROM_ALL ${TEST_SOURCES} ${TEST_MAIN})
add_executable(${ALL_TEST} EXCLUDE_FROM_ALL ${TEST_CPP_SOURCES} ${TEST_MAIN})
target_link_libraries(${ALL_TEST} gtest caffe)
add_dependencies(${ALL_TEST} ${TEST_TARGETS})
# output dir
Expand Down
File renamed without changes.

0 comments on commit 9f9b013

Please sign in to comment.