external_eigen.cmake 2.23 KB
Newer Older
1
# ******************************************************************************
2 3
# Copyright 2017-2018 Intel Corporation
#
4 5 6
# 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
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10 11 12 13 14
# 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.
15
# ******************************************************************************
16 17 18 19

# Enable ExternalProject CMake module
include(ExternalProject)

20
set(EIGEN_INSTALL_DIR ${EXTERNAL_INSTALL_DIR}/eigen)
21
set(EIGEN_PROJECT eigen)
Jai Menon's avatar
Jai Menon committed
22 23
set(EIGEN_GIT_TAG d608d9f3f577118981acbdd40da9dcf6b514668a)
set(EIGEN_GIT_URL https://github.com/jmenon/eigen)
24 25

#----------------------------------------------------------------------------------------------------------
Jai Menon's avatar
Jai Menon committed
26
# Download and install Eigen
27 28 29
#----------------------------------------------------------------------------------------------------------

# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
30 31
if (${CMAKE_VERSION} VERSION_LESS 3.2)
    ExternalProject_Add(
32
        ${EIGEN_PROJECT}
Jai Menon's avatar
Jai Menon committed
33 34
        GIT_REPOSITORY ${EIGEN_GIT_URL}
        GIT_TAG ${EIGEN_GIT_TAG}
35
        UPDATE_COMMAND ""
36
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
37 38 39
        )
else()
    ExternalProject_Add(
40
        ${EIGEN_PROJECT}
Jai Menon's avatar
Jai Menon committed
41 42
        GIT_REPOSITORY ${EIGEN_GIT_URL}
        GIT_TAG ${EIGEN_GIT_TAG}
43
        UPDATE_COMMAND ""
44
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
45
        BUILD_BYPRODUCTS "${EIGEN_INSTALL_DIR}/include/eigen3"
46 47
        )
endif()
48 49 50 51 52

#----------------------------------------------------------------------------------------------------------

ExternalProject_Get_Property(eigen source_dir binary_dir)

53
set(EIGEN_INCLUDE_DIR "${EIGEN_INSTALL_DIR}/include/eigen3" PARENT_SCOPE)