external_cldnn.cmake 3.07 KB
Newer Older
1
# ******************************************************************************
2
# Copyright 2017-2019 Intel Corporation
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#
# 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.
# ******************************************************************************

# Enable ExternalProject CMake module
include(ExternalProject)

#------------------------------------------------------------------------------
# Download and install GoogleTest ...
#------------------------------------------------------------------------------

set(CLDNN_GIT_REPO_URL https://github.com/intel/clDNN.git)
25
set(CLDNN_GIT_LABEL v0.1.0)
26 27 28 29 30 31 32 33 34 35
set(OUT_DIR ${EXTERNAL_PROJECTS_ROOT}/cldnn/out)

ExternalProject_Add(
    ext_cldnn
    PREFIX cldnn
    GIT_REPOSITORY ${CLDNN_GIT_REPO_URL}
    GIT_TAG ${CLDNN_GIT_LABEL}
    # Disable install step
    INSTALL_COMMAND ""
    UPDATE_COMMAND ""
36 37 38 39 40
    CMAKE_GENERATOR ${CMAKE_GENERATOR}
    CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
    CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
    CMAKE_ARGS
                ${NGRAPH_FORWARD_CMAKE_ARGS}
41
                -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
42
                # -DCLDNN__OUTPUT_DIR=out/Debug
43 44 45
                -DCLDNN__INCLUDE_TESTS=OFF
                -DCLDNN__INCLUDE_CORE_INTERNAL_TESTS=OFF
                -DCLDNN__INCLUDE_TUTORIAL=OFF
46 47 48 49 50 51 52 53 54 55
    EXCLUDE_FROM_ALL TRUE
    )

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

add_library(libcldnn INTERFACE)
if (CLDNN_ROOT_DIR)
    find_package(CLDNN REQUIRED)
    target_include_directories(libcldnn SYSTEM INTERFACE ${CLDNN_INCLUDE_DIRS})
    target_link_libraries(libcldnn INTERFACE ${CLDNN_LIBRARIES})
56 57 58 59 60 61 62
    install(
	FILES 
	    ${CLDNN_LIBRARIES}
	DESTINATION 
	    ${NGRAPH_INSTALL_LIB}
	OPTIONAL
        )
63 64
else()
    ExternalProject_Get_Property(ext_cldnn SOURCE_DIR BINARY_DIR)
65 66 67 68 69 70 71 72
    set(CLDNN_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}clDNN64${CMAKE_SHARED_LIBRARY_SUFFIX})
    ExternalProject_Add_Step(
        ext_cldnn
        CopyCLDNN
        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DIR}/build/out/Linux64/${CMAKE_BUILD_TYPE}/${CLDNN_LIB} ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CLDNN_LIB}
        COMMENT "Copy cldnn runtime libraries to ngraph build directory."
        DEPENDEES install
        )
73 74
    add_dependencies(libcldnn ext_cldnn)
    target_include_directories(libcldnn SYSTEM INTERFACE ${SOURCE_DIR}/api)
75 76 77 78 79 80 81 82
    target_link_libraries(libcldnn INTERFACE ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CLDNN_LIB})
    install(
        FILES
            ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CLDNN_LIB}
        DESTINATION
            ${NGRAPH_INSTALL_LIB}
        OPTIONAL
        )
83
endif()