Skip to content

Commit

Permalink
added Yosemite support
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoly Baksheev committed Jan 2, 2015
1 parent 31fcb38 commit e3e2786
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 25 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@ if(UNIX OR APLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
endif()

if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
endif()

add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)

# ---[ Warnings
caffe_warnings_disable(CMAKE_CXX_FLAGS -Wno-sign-compare -Wno-uninitialized)

# ---[ Config generation
configure_file(cmake/Templates/caffe_config.h.in "${CMAKE_BINARY_DIR}/caffe_config.h")

# ---[ Subdirectories
# ---[ Includes
set(Caffe_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
include_directories(${Caffe_INCLUDE_DIR} ${CMAKE_BINARY_DIR})
include_directories(BEFORE src) # This is needed for gtest. Ugly code layout!

# ---[ Subdirectories
add_subdirectory(src/gtest)
add_subdirectory(src/caffe)
add_subdirectory(tools)
Expand Down
4 changes: 4 additions & 0 deletions cmake/Cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ macro(caffe_cuda_compile objlist_variable)
list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC)
endif()

if(APPLE)
list(APPEND CUDA_NVCC_FLAGS -Xcompiler -Wno-unused-function)
endif()

cuda_compile(cuda_objcs ${ARGN})

foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
Expand Down
42 changes: 21 additions & 21 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ list(APPEND Caffe_LINKER_LIBS ${OpenCV_LIBS})
message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")

# ---[ BLAS
set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MLK")

if(BLAS STREQUAL "Atlas" OR BLAS STREQUAL "atlas")

find_package(Atlas REQUIRED)
include_directories(SYSTEM ${Atlas_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${Atlas_LIBRARIES})

elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open")

find_package(OpenBLAS REQUIRED)
include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${OpenBLAS_LIB})

elseif(BLAS STREQUAL "MLK" OR BLAS STREQUAL "mkl")

find_package(MKL REQUIRED)
include_directories(SYSTEM ${MKL_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${MKL_LIBRARIES})

if(NOT APPLE)
set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MLK")

if(BLAS STREQUAL "Atlas" OR BLAS STREQUAL "atlas")
find_package(Atlas REQUIRED)
include_directories(SYSTEM ${Atlas_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${Atlas_LIBRARIES})
elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open")
find_package(OpenBLAS REQUIRED)
include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${OpenBLAS_LIB})
elseif(BLAS STREQUAL "MLK" OR BLAS STREQUAL "mkl")
find_package(MKL REQUIRED)
include_directories(SYSTEM ${MKL_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${MKL_LIBRARIES})
endif()
elseif(APPLE)
find_package(vecLib REQUIRED)
include_directories(SYSTEM ${vecLib_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${vecLib_LINKER_LIBS})
endif()

# ---[ Python
Expand Down
34 changes: 34 additions & 0 deletions cmake/Modules/FindvecLib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Find the vecLib libraries as part of Accelerate.framework or as standalon framework
#
# The following are set after configuration is done:
# VECLIB_FOUND
# vecLib_INCLUDE_DIR
# vecLib_LINKER_LIBS


if(NOT APPLE)
return()
endif()

set(__veclib_include_suffix "Frameworks/vecLib.framework/Versions/Current/Headers")

find_path(vecLib_INCLUDE_DIR vecLib.h
DOC "vecLib include directory"
PATHS /System/Library/${__veclib_include_suffix}
/System/Library/Frameworks/Accelerate.framework/Versions/Current/${__veclib_include_suffix}
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(vecLib DEFAULT_MSG vecLib_INCLUDE_DIR)

if(VECLIB_FOUND)
if(vecLib_INCLUDE_DIR MATCHES "^/System/Library/Frameworks/vecLib.framework.*")
set(vecLib_LINKER_LIBS -lcblas "-framework vecLib")
message(STATUS "Found standalone vecLib.framework")
else()
set(vecLib_LINKER_LIBS -lcblas "-framework Accelerate")
message(STATUS "Found vecLib as part of Accelerate.framework")
endif()

mark_as_advanced(vecLib_INCLUDE_DIR)
endif()
2 changes: 1 addition & 1 deletion cmake/Summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ function(caffe_print_configuration_summary)
caffe_status(" CPU_ONLY : ${CPU_ONLY}")
caffe_status("")
caffe_status("Dependencies:")
caffe_status(" BLAS : " APPLE THEN "Yes (vecLib)" ELSE "Yes (${BLAS})")
caffe_status(" glog : Yes")
caffe_status(" gflags : Yes")
caffe_status(" protobuf : " PROTOBUF_FOUND THEN "Yes (ver. ${PROTOBUF_VERSION})" ELSE "No" )
caffe_status(" lmdb : " LMDB_FOUND THEN "Yes (ver. ${LMDB_VERSION})" ELSE "No")
caffe_status(" Snappy : " SNAPPY_FOUND THEN "Yes (ver. ${Snappy_VERSION})" ELSE "No" )
caffe_status(" LevelDB : " LEVELDB_FOUND THEN "Yes" ELSE "No")
caffe_status(" OpenCV : Yes (ver. ${OpenCV_VERSION})")
caffe_status(" BLAS : Yes (${BLAS})")
caffe_status(" CUDA : " HAVE_CUDA THEN "Yes (ver. ${CUDA_VERSION})" ELSE "No" )
caffe_status("")
if(HAVE_CUDA)
Expand Down
7 changes: 6 additions & 1 deletion matlab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ if(build_using MATCHES "Matlab")
add_custom_target(matlab ALL DEPENDS ${Matlab_caffe_mex} SOURCES ${Matlab_srcs})

elseif(build_using MATCHES "Octave")
set(libflags -Wl,--whole-archive -lcaffe${CAffe_POSTFIX} -Wl,--no-whole-archive ${libflags})

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(libflags -Wl,-force_load,$<TARGET_LINKER_FILE:caffe> ${libflags})
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(libflags -Wl,--whole-archive -lcaffe${CAffe_POSTFIX} -Wl,--no-whole-archive ${libflags})
endif()

add_custom_command(OUTPUT ${Matlab_caffe_mex} COMMAND ${Octave_compiler}
ARGS --mex -o ${Matlab_caffe_mex} ${Matlab_srcs} ${cflags} ${link_folders} ${libflags} -Wl,-rpath,${rpath_folders}
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ file(GLOB_RECURSE python_srcs ${CMAKE_SOURCE_DIR}/python/*.cpp)

add_library(pycaffe SHARED ${python_srcs})
target_link_libraries(pycaffe ${Caffe_STATIC_LINK} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
set_target_properties(pycaffe PROPERTIES PREFIX "" OUTPUT_NAME "_caffe")
set_target_properties(pycaffe PROPERTIES PREFIX "" OUTPUT_NAME "_caffe" MACOSX_RPATH TRUE)
caffe_default_properties(pycaffe)

if(UNIX OR APPLE)
Expand Down

0 comments on commit e3e2786

Please sign in to comment.