Commit 1b168117 authored by Robert Kimball's avatar Robert Kimball

fix eigen external project

add eigen as external project.
add very simple eigen unit test to test building/linking
parent 961b4e0a
# Copyright 2017 Nervana Systems Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.7)
# Enable ExternalProject CMake module
include(ExternalProject)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)
#----------------------------------------------------------------------------------------------------------
# Download and install GoogleTest ...
#----------------------------------------------------------------------------------------------------------
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
ExternalProject_Add(
eigen
URL http://bitbucket.org/eigen/eigen/get/3.3.3.zip
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/eigen
INSTALL_COMMAND make install
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
)
#----------------------------------------------------------------------------------------------------------
ExternalProject_Get_Property(eigen source_dir binary_dir)
set(EIGEN_INCLUDE_DIR "${EXTERNAL_INSTALL_LOCATION}/include/Eigen3" PARENT_SCOPE)
......@@ -13,7 +13,12 @@
include_directories(
SYSTEM
"${GTEST_INCLUDE_DIR}"
${GTEST_INCLUDE_DIR}
${EIGEN_INCLUDE_DIR}
)
include_directories(
${NGRAPH_INCLUDE_DIR}
)
set (SRC
......@@ -25,6 +30,7 @@ set (SRC
uuid.cpp
topological_sort.cpp
op.cpp
eigen.cpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
......@@ -35,7 +41,7 @@ add_executable(unit-test ${SRC})
target_link_libraries(unit-test ngraph libgtest pthread)
target_link_libraries(unit-test ${CMAKE_DL_LIBS})
add_dependencies(unit-test ngraph libgtest)
add_dependencies(unit-test ngraph libgtest eigen)
add_custom_target(check
COMMAND ${PROJECT_BINARY_DIR}/test/unit-test
......
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <iostream>
#include <Eigen/Dense>
#include "gtest/gtest.h"
using Eigen::MatrixXd;
TEST(eigen, simple)
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
EXPECT_FLOAT_EQ(m(1,1), 1.5);
}
......@@ -12,3 +12,4 @@
# limitations under the License.
include( ../cmake/external_gtest.cmake )
include( ../cmake/external_eigen.cmake )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment