Skip to content

Commit

Permalink
Support more OSes (#10)
Browse files Browse the repository at this point in the history
* Support macos

* Link BLAS lib

* Add windows

* Fix windows io

* Fix test python layer

* Fix tests for win
  • Loading branch information
sunnycase authored Aug 28, 2021
1 parent f7ff752 commit 5024ff1
Show file tree
Hide file tree
Showing 23 changed files with 92 additions and 539 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
os: [ubuntu-18.04,windows-2019,macos-10.15]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Compiled Dynamic libraries
*.so
*.dylib
*.pyd

# Compiled Static libraries
*.lai
Expand Down
7 changes: 0 additions & 7 deletions .vscode/launch.json

This file was deleted.

17 changes: 7 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ if(NOT CONAN_EXPORTED)
conan_add_remote(NAME sunnycase URL https://conan.sunnycase.moe INDEX 0)
endif()

set(CMAKE_SKIP_RPATH OFF)
if (APPLE)
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
set(CMAKE_INSTALL_NAME_DIR "@rpath")
else ()
set(CMAKE_INSTALL_RPATH "$ORIGIN/..lib")
endif()

conan_cmake_run(CONANFILE conanfile.py
BASIC_SETUP TARGETS
OPTIONS ${CONAN_OPTS}
Expand All @@ -76,6 +67,10 @@ if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
endif()

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /W3 /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /DHAVE_CXX11_ATOMIC /DOS_WINDOWS")
endif()

caffe_set_caffe_link()

if(USE_libstdcpp)
Expand All @@ -84,7 +79,9 @@ if(USE_libstdcpp)
endif()

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

# ---[ Config generation
configure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_config.h")
Expand Down
48 changes: 11 additions & 37 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,54 +112,28 @@ if(NOT APPLE)
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")

if(BLAS STREQUAL "Open" OR BLAS STREQUAL "open")
find_package(OpenBLAS REQUIRED)
list(APPEND Caffe_LINKER_LIBS PUBLIC OpenBLAS::OpenBLAS)
set(BLA_VENDOR OpenBLAS)
elseif(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl")
find_package(MKL REQUIRED)
list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${MKL_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS PUBLIC ${MKL_LIBRARIES})
set(BLA_VENDOR Intel10_64lp)
list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_MKL)
endif()
elseif(APPLE)
find_package(vecLib REQUIRED)
list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${vecLib_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS PUBLIC ${vecLib_LINKER_LIBS})

if(VECLIB_FOUND)
if(NOT vecLib_INCLUDE_DIR MATCHES "^/System/Library/Frameworks/vecLib.framework.*")
list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_ACCELERATE)
endif()
set(BLA_VENDOR Apple)
endif()

if(APPLE)
if(NOT BLAS_LIBRARIES MATCHES "^/System/Library/Frameworks/vecLib.framework.*")
list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_ACCELERATE)
endif()
endif()

find_package(BLAS REQUIRED)
list(APPEND Caffe_LINKER_LIBS PRIVATE BLAS::BLAS)

# ---[ Python
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)

if(BUILD_python)
#if(NOT "${python_version}" VERSION_LESS "3")
# # use python3
# find_package(PythonInterp)
# find_package(PythonLibs)
# find_package(NumPy)
# # Find the matching boost python implementation
# set(version ${PYTHONLIBS_VERSION_STRING})

# STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} )
# find_package(Boost COMPONENTS "python-py${boost_py_version}")
# set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})

# while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND)
# STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} )

# STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} )
# find_package(Boost COMPONENTS "python-py${boost_py_version}")
# set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})

# STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} )
# if("${has_more_version}" STREQUAL "")
# break()
# endif()
# endwhile()
set(HAVE_PYTHON TRUE)
if(BUILD_python_layer)
list(APPEND Caffe_DEFINITIONS PRIVATE -DWITH_PYTHON_LAYER)
Expand Down
4 changes: 0 additions & 4 deletions cmake/Misc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "Default install path" FORCE)
endif()

# ---[ RPATH settings
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOLEAN "Use link paths for shared library rpath")
set(CMAKE_MACOSX_RPATH TRUE)

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} __is_systtem_dir)
if(${__is_systtem_dir} STREQUAL -1)
Expand Down
52 changes: 0 additions & 52 deletions cmake/Modules/FindAtlas.cmake

This file was deleted.

190 changes: 0 additions & 190 deletions cmake/Modules/FindLAPACK.cmake

This file was deleted.

Loading

0 comments on commit 5024ff1

Please sign in to comment.