Commit 7c84ad26 authored by Ilya Churaev's avatar Ilya Churaev Committed by Scott Cyphers

Fixed multi arch build (#3587)

parent 89769846
......@@ -23,10 +23,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.")
endif()
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
message(FATAL_ERROR "Ninja generator not supported.")
endif()
if (CMAKE_BUILD_TYPE)
set(RELEASE_TYPES Debug Release RelWithDebInfo MinSizeRel)
list(FIND RELEASE_TYPES ${CMAKE_BUILD_TYPE} INDEX_FOUND)
......@@ -199,6 +195,7 @@ option(NGRAPH_INTERPRETER_STATIC_LIB_ENABLE "Enable build INTERPRETER backend as
option(NGRAPH_CPU_STATIC_LIB_ENABLE "Enable build CPU backend as a static library" FALSE)
option(NGRAPH_PLAIDML_STATIC_LIB_ENABLE "Enable build PlaidML backend as a static library" FALSE)
option(NGRAPH_DYNAMIC_COMPONENTS_ENABLE "Enable dynamic loading of components" TRUE)
option(NGRAPH_NATIVE_ARCH_ENABLE "Enable build for native archtecture" TRUE)
if (NGRAPH_CPU_ENABLE)
option(NGRAPH_TBB_ENABLE "Control usage of TBB for CPU backend" TRUE)
endif()
......@@ -273,6 +270,7 @@ NORMALIZE_BOOL(NGRAPH_USE_PREBUILT_LLVM)
NORMALIZE_BOOL(NGRAPH_PLAIDML_ENABLE)
NORMALIZE_BOOL(NGRAPH_JSON_ENABLE)
NORMALIZE_BOOL(NGRAPH_NATIVE_ARCH_ENABLE)
NORMALIZE_BOOL(NGRAPH_STATIC_LIB_ENABLE)
NORMALIZE_BOOL(NGRAPH_INTERPRETER_STATIC_LIB_ENABLE)
NORMALIZE_BOOL(NGRAPH_CPU_STATIC_LIB_ENABLE)
......@@ -309,10 +307,19 @@ message(STATUS "NGRAPH_INTERPRETER_STATIC_LIB_ENABLE: ${NGRAPH_INTERPRETER_STATI
message(STATUS "NGRAPH_CPU_STATIC_LIB_ENABLE: ${NGRAPH_CPU_STATIC_LIB_ENABLE}")
message(STATUS "NGRAPH_PLAIDML_STATIC_LIB_ENABLE: ${NGRAPH_PLAIDML_STATIC_LIB_ENABLE}")
message(STATUS "NGRAPH_DYNAMIC_COMPONENTS_ENABLE: ${NGRAPH_DYNAMIC_COMPONENTS_ENABLE}")
message(STATUS "NGRAPH_NATIVE_ARCH_ENABLE: ${NGRAPH_NATIVE_ARCH_ENABLE}")
if (NGRAPH_CPU_ENABLE)
message(STATUS "NGRAPH_TBB_ENABLE: ${NGRAPH_TBB_ENABLE}")
endif()
if("${CMAKE_GENERATOR}" STREQUAL "Ninja" AND (NGRAPH_TOOLS_ENABLE OR NGRAPH_CPU_ENABLE OR NGRAPH_MLIR_ENABLE OR
NGRAPH_INTELGPU_ENABLE OR NGRAPH_GPU_ENABLE OR NGRAPH_INTERPRETER_ENABLE OR NGRAPH_NOP_ENABLE OR
NGRAPH_GPUH_ENABLE OR NGRAPH_GENERIC_CPU_ENABLE OR NGRAPH_ONNX_IMPORT_ENABLE OR NGRAPH_PLAIDML_ENABLE OR
NGRAPH_JSON_ENABLE))
message(FATAL_ERROR "Ninja generator not supported.")
endif()
#-----------------------------------------------------------------------------------------------
# Installation logic...
#-----------------------------------------------------------------------------------------------
......@@ -351,7 +358,7 @@ endif()
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$" AND NOT NGRAPH_BUILD_DIR)
message( STATUS "Setting clang flags...")
include( cmake/clang_4_0_flags.cmake )
endif()
......@@ -386,7 +393,7 @@ if (NGRAPH_CODE_COVERAGE_ENABLE)
endif()
# Enable build target CPU features
if(NOT WIN32)
if(NOT WIN32 AND NGRAPH_NATIVE_ARCH_ENABLE)
set(NGRAPH_TARGET_ARCH native CACHE
STRING "Target CPU architecture to build for. Defaults to the native CPU architecture")
......@@ -515,19 +522,21 @@ message(STATUS "CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
# External projects install directory
#-----------------------------------------------------------------------------------------------
set(NGRAPH_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/ngraph)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
if(WIN32)
set(NGRAPH_LIBRARY_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR}/${CMAKE_CFG_INTDIR})
set(NGRAPH_LIBRARY_INSTALL_SRC_DIRECTORY ${NGRAPH_BUILD_DIR}/\${CMAKE_INSTALL_CONFIG_NAME})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
set(NGRAPH_ARCHIVE_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR}/${CMAKE_CFG_INTDIR})
set(NGRAPH_ARCHIVE_INSTALL_SRC_DIRECTORY ${NGRAPH_BUILD_DIR}/\${CMAKE_INSTALL_CONFIG_NAME})
set(CMAKE_PDB_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
else()
set(NGRAPH_LIBRARY_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
set(NGRAPH_LIBRARY_INSTALL_SRC_DIRECTORY ${NGRAPH_BUILD_DIR})
if (NOT NGRAPH_BUILD_DIR)
set(NGRAPH_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/ngraph)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
if(WIN32)
set(NGRAPH_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR})
set(NGRAPH_LIBRARY_INSTALL_SRC_DIRECTORY ${NGRAPH_BUILD_DIR}/\${CMAKE_INSTALL_CONFIG_NAME})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
set(NGRAPH_ARCHIVE_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR}/${CMAKE_CFG_INTDIR})
set(NGRAPH_ARCHIVE_INSTALL_SRC_DIRECTORY ${NGRAPH_BUILD_DIR}/\${CMAKE_INSTALL_CONFIG_NAME})
set(CMAKE_PDB_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${NGRAPH_BUILD_DIR})
else()
set(NGRAPH_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(NGRAPH_LIBRARY_INSTALL_SRC_DIRECTORY ${NGRAPH_BUILD_DIR})
endif()
endif()
set(EXTERNAL_INSTALL_DIR ${CMAKE_BINARY_DIR}/external)
......
......@@ -20,7 +20,7 @@ function(NGRAPH_GET_CURRENT_HASH)
COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD
RESULT_VARIABLE result
OUTPUT_VARIABLE HASH
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
ERROR_QUIET)
if(NOT HASH)
......@@ -36,7 +36,7 @@ function(NGRAPH_GET_TAG_OF_CURRENT_HASH)
COMMAND ${GIT_EXECUTABLE} show-ref
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE TAG_LIST
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
ERROR_QUIET)
NGRAPH_GET_CURRENT_HASH()
......@@ -64,7 +64,7 @@ function(NGRAPH_GET_MOST_RECENT_TAG)
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --match v*.*.*
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE TAG
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
ERROR_QUIET)
if (NOT ${TAG} STREQUAL "")
......@@ -88,7 +88,7 @@ function(NGRAPH_GET_VERSION_LABEL)
set(NGRAPH_VERSION_LABEL "?.?.?+${HASH}" PARENT_SCOPE)
else()
# Not in a git repo
file(READ ${CMAKE_SOURCE_DIR}/TAG NGRAPH_TAG)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/TAG NGRAPH_TAG)
string(STRIP ${NGRAPH_TAG} NGRAPH_TAG)
set(NGRAPH_VERSION_LABEL "${NGRAPH_TAG}" PARENT_SCOPE)
endif()
......
......@@ -636,7 +636,8 @@ endif()
# Defines macro in C++ to load backend plugin
target_include_directories(ngraph PUBLIC "${NGRAPH_INCLUDE_PATH}")
if (NOT WIN32)
target_link_libraries(ngraph PUBLIC dl pthread)
find_package(Threads REQUIRED)
target_link_libraries(ngraph PUBLIC dl Threads::Threads)
endif()
if (NGRAPH_ONNX_IMPORT_ENABLE)
......
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