diff --git a/.ci/.ci.yaml b/.ci/.ci.yaml index d532fa0..1bdfa6d 100644 --- a/.ci/.ci.yaml +++ b/.ci/.ci.yaml @@ -11,7 +11,7 @@ jobs: - job: Linux timeoutInMinutes: 360 pool: - vmImage: 'ubuntu-latest' + vmImage: ubuntu-16.04 steps: - template: linux-steps.yaml @@ -19,24 +19,24 @@ jobs: - job: macOS timeoutInMinutes: 360 pool: - vmImage: macOS-10.14 + vmImage: macOS-latest steps: - template: macos-steps.yaml # Windows build. -- job: WindowsVS15 +- job: WindowsVS16 timeoutInMinutes: 360 - displayName: Windows VS15 + displayName: Windows VS16 pool: - vmImage: vs2017-win2016 + vmImage: windows-2019 strategy: matrix: Plain: CMakeArgs-mlpack: '-DDEBUG=ON -DPROFILE=OFF -DBUILD_PYTHON_BINDINGS=OFF -DBUILD_TESTS=OFF' - CMakeGenerator: '-G "Visual Studio 15 2017 Win64"' - MSBuildVersion: '15.0' + CMakeGenerator: '-G "Visual Studio 16 2019"' + MSBuildVersion: '16.0' steps: - template: windows-steps.yaml \ No newline at end of file diff --git a/.ci/linux-steps.yaml b/.ci/linux-steps.yaml index 758f577..09501c1 100644 --- a/.ci/linux-steps.yaml +++ b/.ci/linux-steps.yaml @@ -19,12 +19,17 @@ steps: sudo apt-get install -y --allow-unauthenticated liblapack-dev g++ libboost1.70-dev libarmadillo-dev xz-utils curl https://data.kurg.org/armadillo-8.400.0.tar.xz | tar -xvJ && cd armadillo* cmake . && make && sudo make install && cd .. + + # Install cereal. + wget https://github.com/USCiLab/cereal/archive/v1.3.0.tar.gz + tar -xvzpf v1.3.0.tar.gz # Unpack into cereal-1.3.0/. + cd cereal-1.3.0/ displayName: 'Install Build Dependencies' # Configure CMake Args for mlpack. - script: | unset BOOST_ROOT - cd mlpack && mkdir build && cd build && cmake $(CMakeArgs-mlpack) .. + cd mlpack && mkdir build && cd build && cmake $(CMakeArgs-mlpack) -DCEREAL_INCLUDE_DIR=../../cereal-1.3.0/include/ .. displayName: 'CMake for mlpack' # Install mlpack @@ -38,7 +43,7 @@ steps: displayName: 'Installing Protobuf' # Configure mlboard (CMake) -- script: mkdir build && cd build && cmake .. +- script: mkdir build && cd build && cmake -DCEREAL_INCLUDE_DIR=../cereal-1.3.0/include/ .. displayName: 'CMake for mlboard' # Build mlboard diff --git a/.ci/macos-steps.yaml b/.ci/macos-steps.yaml index 64a8a9b..596a7e7 100644 --- a/.ci/macos-steps.yaml +++ b/.ci/macos-steps.yaml @@ -8,10 +8,14 @@ steps: # Install mlpack from master to get new functionalities instantly. - script: | set -e - sudo xcode-select --switch /Applications/Xcode_10.1.app/Contents/Developer + sudo xcode-select --switch /Applications/Xcode_12.2.app/Contents/Developer unset BOOST_ROOT - pip install cython numpy pandas zipp configparser - brew install openblas armadillo boost + if [ "$(binding)" == "python" ]; then + pip install --upgrade pip + pip install cython numpy pandas zipp configparser + fi + + brew install openblas armadillo boost cereal git clone --depth 1 https://github.com/mlpack/jenkins-conf.git conf git clone --depth 1 https://github.com/mlpack/mlpack.git displayName: 'Install Build Dependencies' diff --git a/.ci/windows-steps.yaml b/.ci/windows-steps.yaml index b4dd5a9..04246c4 100644 --- a/.ci/windows-steps.yaml +++ b/.ci/windows-steps.yaml @@ -10,31 +10,26 @@ steps: - powershell: | nuget install OpenBLAS -o $(Agent.ToolsDirectory) nuget install boost -o $(Agent.ToolsDirectory) -Version 1.60.0 - nuget install boost_unit_test_framework-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 - nuget install boost_program_options-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install boost_random-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 - nuget install boost_serialization-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install boost_math_c99-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install boost_filesystem-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install boost_system-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install boost_date_time-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install boost_regex-vc140 -o $(Agent.ToolsDirectory) -Version 1.60.0 nuget install OpenBLAS -o $(Agent.ToolsDirectory) + nuget install unofficial-flayan-cereal -o $(Agent.ToolsDirectory) mkdir -p $(Agent.ToolsDirectory)/boost_libs - cp $(Agent.ToolsDirectory)/boost_program_options-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs cp $(Agent.ToolsDirectory)/boost_math_c99-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs cp $(Agent.ToolsDirectory)/boost_random-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs - cp $(Agent.ToolsDirectory)/boost_serialization-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs - cp $(Agent.ToolsDirectory)/boost_unit_test_framework-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs cp $(Agent.ToolsDirectory)/boost_filesystem-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs cp $(Agent.ToolsDirectory)/boost_system-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs cp $(Agent.ToolsDirectory)/boost_date_time-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs cp $(Agent.ToolsDirectory)/boost_regex-vc140.1.60.0.0/lib/native/address-model-64/lib/*.* $(Agent.ToolsDirectory)/boost_libs git clone https://github.com/tronkko/dirent.git - cp "dirent/include/dirent.h" "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/include" - cp "dirent/include/dirent.h" "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/include" + cp "dirent/include/dirent.h" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29333/include" + cp "dirent/include/dirent.h" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29333/include" cp "dirent/include/dirent.h" "C:/Program Files (x86)/include" cp "dirent/include/dirent.h" "C:/Program Files/include" displayName: 'Fetch build dependencies' @@ -79,9 +74,11 @@ steps: -DLAPACK_LIBRARIES:FILEPATH=$(Agent.ToolsDirectory)\OpenBLAS.0.2.14.1\lib\native\lib\x64\libopenblas.dll.a ` -DARMADILLO_INCLUDE_DIR="..\..\armadillo-8.400.0\include" ` -DARMADILLO_LIBRARY="..\..\armadillo-8.400.0\Release\armadillo.lib" ` + -DCEREAL_INCLUDE_DIR=$(Agent.ToolsDirectory)\unofficial-flayan-cereal.1.2.2\build\native\include ` -DBOOST_INCLUDEDIR=$(Agent.ToolsDirectory)\boost.1.60.0.0\lib\native\include ` -DBOOST_LIBRARYDIR=$(Agent.ToolsDirectory)\boost_libs ` -DBUILD_JULIA_BINDINGS=OFF ` + -DBUILD_R_BINDINGS=OFF ` -DCMAKE_BUILD_TYPE=Release .. displayName: 'Configure mlpack' @@ -140,6 +137,7 @@ steps: -DBOOST_LIBRARYDIR=$(Agent.ToolsDirectory)\boost_libs ` -DARMADILLO_INCLUDE_DIR="..\armadillo-8.400.0\include" ` -DARMADILLO_LIBRARY="..\armadillo-8.400.0\Release\armadillo.lib" ` + -DCEREAL_INCLUDE_DIR=$(Agent.ToolsDirectory)\unofficial-flayan-cereal.1.2.2\build\native\include ` -DProtobuf_INCLUDE_DIR="..\protobuf\src\" ` -DPROTOBUF_LIBRARY="$(Agent.ToolsDirectory)\boost_libs\libprotobuf.lib" ` -DProtobuf_PROTOC_EXECUTABLE="..\protobuf\cmake\solution\Release\protoc.exe" ` diff --git a/CMake/Findcereal.cmake b/CMake/Findcereal.cmake new file mode 100644 index 0000000..dd54d36 --- /dev/null +++ b/CMake/Findcereal.cmake @@ -0,0 +1,56 @@ +#Findcereal.cmake +find_path(CEREAL_INCLUDE_DIR + NAMES cereal + PATHS "$ENV{ProgramFiles}/cereal/include" + ) + +if(CEREAL_INCLUDE_DIR) + # ------------------------------------------------------------------------ + # Extract version information from + # ------------------------------------------------------------------------ + set(CEREAL_FOUND YES) + set(CEREAL_VERSION_MAJOR 0) + set(CEREAL_VERSION_MINOR 0) + set(CEREAL_VERSION_PATCH 0) + + if(EXISTS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp") + + # Read and parse cereal version header file for version number + file(READ "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" + _CEREAL_HEADER_CONTENTS) + string(REGEX REPLACE ".*#define CEREAL_VERSION_MAJOR ([0-9]+).*" "\\1" + CEREAL_VERSION_MAJOR "${_CEREAL_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define CEREAL_VERSION_MINOR ([0-9]+).*" "\\1" + CEREAL_VERSION_MINOR "${_CEREAL_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define CEREAL_VERSION_PATCH ([0-9]+).*" "\\1" + CEREAL_VERSION_PATCH "${_CEREAL_HEADER_CONTENTS}") + + elseif(EXISTS "${CEREAL_INCLUDE_DIR}/cereal/details/polymorphic_impl_fwd.hpp") + + set(CEREAL_VERSION_MAJOR 1) + set(CEREAL_VERSION_MINOR 2) + set(CEREAL_VERSION_PATCH 0) + elseif(EXISTS "${CEREAL_INCLUDE_DIR}/cereal/types/valarray.hpp") + + set(CEREAL_VERSION_MAJOR 1) + set(CEREAL_VERSION_MINOR 1) + set(CEREAL_VERSION_PATCH 2) + elseif(EXISTS "${CEREAL_INCLUDE_DIR}/cereal/cereal.hpp") + + set(CEREAL_VERSION_MAJOR 1) + set(CEREAL_VERSION_MINOR 1) + set(CEREAL_VERSION_PATCH 1) +else() + + set(CEREAL_FOUND NO) + endif() + set(CEREAL_VERSION_STRING "${CEREAL_VERSION_MAJOR}.${CEREAL_VERSION_MINOR}.${CEREAL_VERSION_PATCH}") +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(cereal + REQUIRED_VARS CEREAL_INCLUDE_DIR + VERSION_VAR CEREAL_VERSION_STRING + ) + +mark_as_advanced(CEREAL_INCLUDE_DIR) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a8b9bfb..12013bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project(mlboard # Set required C++ standard to C++11. set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CEREAL_VERSION "1.1.2") # Include modules in the CMake directory. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake") @@ -63,11 +64,9 @@ endif() # Remove this when serialization is removed from mlpack. set(Boost_ADDITIONAL_VERSIONS "1.49.0" "1.50.0" "1.51.0" "1.52.0" "1.53.0" "1.54.0" "1.55.0") -find_package(Boost 1.49 - COMPONENTS - serialization - REQUIRED -) +find_package(Boost 1.49) + +find_package(cereal "${CEREAL_VERSION}" REQUIRED) # In Visual Studio, automatic linking is performed, so we don't need to worry # about it. Clear the list of libraries to link against and let Visual Studio @@ -96,6 +95,7 @@ add_subdirectory(include/proto) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(MLBOARD_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR} + ${CEREAL_INCLUDE_DIR} ${ARMADILLO_INCLUDE_DIR} ${PROTOBUF_INCLUDE_DIR} )