Unverified Commit 34bf01c8 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

Build LLVM at CMake configure time and use CMake config file. (#4144)

* Build LLVM at CMake config time and use CMake config file for dependencies.

* Temp save.

* Codegen functioning.

* Support prebuilt LLVM.

* Remove zlib.

* Relax CMake minimum version.

* Fix bug.

* Lower CMake version requirement.

* Pass more args.

* Add proper quote.

* Remove quotes.

* Try to separate flags for external projects.

* Don't pass flags to LLVM.

* Pass CXX abi.

* Remove stale print.

* Update gtest flags.

* Try to fix build issue.

* Patch LLVM to prevent building clang-tools-extra.
Co-authored-by: 's avataraslepko <44713115+aslepko@users.noreply.github.com>
parent c737a573
......@@ -110,54 +110,6 @@ if (APPLE)
endif()
endif()
if (NGRAPH_MLIR_ENABLE)
#MLIR uses the latest version of LLVM which requires C++14.
set(NGRAPH_CXX_STANDARD 14)
else()
set(NGRAPH_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD ${NGRAPH_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Create compilation database compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Setup CMAKE_ARGS to be forwarded to External Projects
set(NGRAPH_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=${CMAKE_EXPORT_COMPILE_COMMANDS}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=${CMAKE_POSITION_INDEPENDENT_CODE}
)
if (CMAKE_OSX_SYSROOT)
set(NGRAPH_FORWARD_CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
)
endif()
if (NOT MSVC)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
set(NGRAPH_FORWARD_CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endif()
message(STATUS "NGRAPH_FORWARD_CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}")
# Prevent Eigen from using any LGPL3 code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY -DTBB_USE_THREADING_TOOLS")
ngraph_var(NGRAPH_USE_PREBUILT_MLIR DEFAULT "FALSE")
ngraph_var(NGRAPH_USE_PREBUILT_LLVM DEFAULT "FALSE")
......@@ -276,7 +228,6 @@ if (NGRAPH_CPU_ENABLE)
NORMALIZE_BOOL(NGRAPH_TBB_ENABLE)
endif()
message(STATUS "NGRAPH_CXX_STANDARD: ${NGRAPH_CXX_STANDARD}")
message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}")
message(STATUS "NGRAPH_DOC_BUILD_ENABLE: ${NGRAPH_DOC_BUILD_ENABLE}")
message(STATUS "NGRAPH_TOOLS_ENABLE: ${NGRAPH_TOOLS_ENABLE}")
......@@ -317,6 +268,51 @@ if("${CMAKE_GENERATOR}" STREQUAL "Ninja" AND (NGRAPH_TOOLS_ENABLE OR NGRAPH_CPU_
message(FATAL_ERROR "Ninja generator not supported.")
endif()
if (NGRAPH_CPU_ENABLE AND NGRAPH_MLIR_ENABLE)
#MLIR uses the latest version of LLVM which requires C++14.
set(NGRAPH_CXX_STANDARD 14)
else()
set(NGRAPH_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD ${NGRAPH_CXX_STANDARD})
message(STATUS "NGRAPH_CXX_STANDARD: ${NGRAPH_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Create compilation database compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Setup CMAKE_ARGS to be forwarded to External Projects
set(NGRAPH_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=${CMAKE_EXPORT_COMPILE_COMMANDS}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=${CMAKE_POSITION_INDEPENDENT_CODE}
)
if (CMAKE_OSX_SYSROOT)
set(NGRAPH_FORWARD_CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
)
endif()
if (NOT MSVC)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
set(NGRAPH_FORWARD_CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endif()
message(STATUS "NGRAPH_FORWARD_CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}")
#-----------------------------------------------------------------------------------------------
# Installation logic...
......@@ -352,17 +348,41 @@ if (LINUX)
endif()
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
# Compile Flags to pass to external projects...
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
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 )
include(cmake/sdl.cmake)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
message( STATUS "nGraph using CXX11 ABI: " ${NGRAPH_USE_CXX_ABI} )
list(APPEND NGRAPH_COMMON_FLAGS -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI})
endif()
endif()
string(REPLACE " " ";" NGRAPH_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " " ";" NGRAPH_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
list(APPEND NGRAPH_COMMON_CXX_FLAGS ${NGRAPH_CMAKE_CXX_FLAGS} ${NGRAPH_COMMON_FLAGS})
list(APPEND NGRAPH_COMMON_C_FLAGS ${NGRAPH_CMAKE_C_FLAGS} ${NGRAPH_COMMON_FLAGS})
message(STATUS "NGRAPH_COMMON_CXX_FLAGS ${NGRAPH_COMMON_CXX_FLAGS}")
message(STATUS "NGRAPH_COMMON_C_FLAGS ${NGRAPH_COMMON_C_FLAGS}")
# Set baseline flags for nGraph source files
string(REPLACE ";" " " CMAKE_ORIGINAL_CXX_FLAGS "${NGRAPH_COMMON_CXX_FLAGS}")
#-----------------------------------------------------------------------------------------------
# Compile Flags for nGraph...
#-----------------------------------------------------------------------------------------------
# Prevent Eigen from using any LGPL3 code
set(CMAKE_CXX_FLAGS "${CMAKE_ORIGINAL_CXX_FLAGS} -DEIGEN_MPL2_ONLY -DTBB_USE_THREADING_TOOLS")
if (WIN32)
string(REPLACE "/W3" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# Compiler-specific logic...
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP")
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
......@@ -380,17 +400,11 @@ else()
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
endif()
include(cmake/sdl.cmake)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
message( STATUS "nGraph using CXX11 ABI: " ${NGRAPH_USE_CXX_ABI} )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}")
endif()
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()
set(CMAKE_ORIGINAL_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ngraph_var(NGRAPH_WARNINGS_AS_ERRORS DEFAULT "OFF")
if (${NGRAPH_WARNINGS_AS_ERRORS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
......@@ -607,9 +621,7 @@ else()
endif()
if(NGRAPH_CODEGEN_ENABLE)
if (NGRAPH_USE_PREBUILT_LLVM OR DEFINED LLVM_TARBALL_URL)
include(cmake/external_llvm_prebuilt.cmake)
elseif (NOT MSVC)
if (NOT MSVC)
include(cmake/external_llvm.cmake)
else()
message(FATAL_ERROR "CODEGEN is not supported on Windows!")
......
......@@ -14,31 +14,31 @@
# limitations under the License.
# ******************************************************************************
add_compile_options(-Werror=return-type)
add_compile_options(-Werror=inconsistent-missing-override)
add_compile_options(-Werror=comment)
add_compile_options(-pedantic-errors)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=inconsistent-missing-override")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=comment")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# whitelist errors here
#add_compile_options(-Weverything)
add_compile_options(-Wall)
# add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
#add_compile_options(-Wno-c++98-compat-pedantic)
#add_compile_options(-Wno-weak-vtables)
#add_compile_options(-Wno-global-constructors)
#add_compile_options(-Wno-exit-time-destructors)
#add_compile_options(-Wno-missing-prototypes)
#add_compile_options(-Wno-missing-noreturn)
#add_compile_options(-Wno-covered-switch-default)
#add_compile_options(-Wno-undef)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-prototypes")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-noreturn")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.1.0)
#add_compile_options(-Wno-zero-as-null-pointer-constant)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant")
endif()
endif()
# should remove these
add_compile_options(-Wno-float-conversion)
add_compile_options(-Wno-padded)
add_compile_options(-Wno-conversion)
add_compile_options(-Wno-undefined-func-template)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-func-template")
......@@ -44,9 +44,9 @@ endif()
if(UNIX)
# workaround for compile error
# related: https://github.com/intel/mkl-dnn/issues/55
set(GTEST_CXX_FLAGS "-Wno-unused-result ${CMAKE_CXX_FLAGS} -Wno-undef")
set(GTEST_CXX_FLAGS "-Wno-unused-result ${CMAKE_ORIGINAL_CXX_FLAGS} -Wno-undef")
else()
set(GTEST_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(GTEST_CXX_FLAGS ${CMAKE_ORIGINAL_CXX_FLAGS})
endif()
#Build for ninja
......
This diff is collapsed.
This diff is collapsed.
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 27754f3394..6ca3882728 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -118,12 +118,6 @@ foreach(proj ${LLVM_ENABLE_PROJECTS})
string(TOUPPER "${proj}" upper_proj)
STRING(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
- # There is a widely spread opinion that clang-tools-extra should be merged
- # into clang. The following simulates it by always enabling clang-tools-extra
- # when enabling clang.
- if (proj STREQUAL "clang")
- set(LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../clang-tools-extra")
- endif()
endforeach()
# Build llvm with ccache if the package is present
# ******************************************************************************
# Copyright 2017-2020 Intel Corporation
#
# 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.4.3)
include(ExternalProject)
project(llvm NONE)
set(NGRAPH_USE_PREBUILT_LLVM @NGRAPH_USE_PREBUILT_LLVM@)
set(LLVM_TARBALL_URL @LLVM_TARBALL_URL@)
set(LLVM_SHA1_HASH @LLVM_SHA1_HASH@)
if(NGRAPH_USE_PREBUILT_LLVM)
message(STATUS "LLVM: Using prebuilt LLVM")
# Override default LLVM binaries
if(NOT DEFINED LLVM_TARBALL_URL)
if(APPLE)
set(NGRAPH_LLVM_VERSION 8.0.0)
set(LLVM_TARBALL_URL http://releases.llvm.org/${NGRAPH_LLVM_VERSION}/clang+llvm-${NGRAPH_LLVM_VERSION}-x86_64-apple-darwin.tar.xz)
set(LLVM_SHA1_HASH a5674f2ce5b9ed1b67d92689d319ed3b46d66e29)
elseif(UNIX AND NOT APPLE)
set(NGRAPH_LLVM_VERSION 8.0.0)
if(EXISTS /etc/lsb-release)
execute_process(COMMAND grep DISTRIB_RELEASE /etc/lsb-release OUTPUT_VARIABLE UBUNTU_VER_LINE)
string(REGEX MATCH "[0-9.]+" UBUNTU_VER ${UBUNTU_VER_LINE})
message(STATUS "Ubuntu version: ${UBUNTU_VER} detected.")
set(LLVM_TARBALL_URL http://releases.llvm.org/${NGRAPH_LLVM_VERSION}/clang+llvm-${NGRAPH_LLVM_VERSION}-x86_64-linux-gnu-ubuntu-${UBUNTU_VER}.tar.xz)
if(UBUNTU_VER MATCHES "14.04")
set(LLVM_SHA1_HASH 552ea458b70961b7922a4bbe9de1434688342dbf)
elseif(UBUNTU_VER MATCHES "16.04")
set(LLVM_SHA1_HASH 2be69be355b012ae206dbc0ea7d84b831d77dc27)
elseif(UBUNTU_VER MATCHES "18.04")
set(LLVM_SHA1_HASH 6aeb8aa0998d37be67d886b878f27de5e5ccc5e4)
else()
message(FATAL_ERROR "No prebuilt LLVM available for Ubuntu ${UBUNTU_VER} on llvm.org, please set LLVM_TARBALL_URL manually.")
endif()
else()
message(FATAL_ERROR "Prebuilt LLVM: Only Ubuntu Linux is supported.")
endif()
else()
message(FATAL_ERROR "Prebuilt LLVM: unsupported OS.")
endif()
else()
if(NOT DEFINED LLVM_SHA1_HASH)
message(FATAL_ERROR "Prebuilt LLVM: please provide LLVM_SHA_HASH.")
endif()
endif()
ExternalProject_Add(
ext_llvm
PREFIX llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
SOURCE_DIR @LLVM_INSTALL_ROOT@
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
else()
message(STATUS "LLVM: Building LLVM from source")
# Revert prior changes to make incremental build work.
set(LLVM_PATCH_REVERT_COMMAND cd @LLVM_PROJECT_ROOT@/llvm/src/ext_llvm && git reset HEAD --hard)
set(LLVM_CMAKE_ARGS @NGRAPH_FORWARD_CMAKE_ARGS@
-DCMAKE_INSTALL_PREFIX=@LLVM_INSTALL_ROOT@
-DLLVM_ENABLE_PROJECTS:STRING=clang$<SEMICOLON>openmp
-DLLVM_INCLUDE_DOCS=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INCLUDE_GO_TESTS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_BENCHMARKS=OFF
-DLLVM_BUILD_TOOLS=OFF
-DLLVM_BUILD_UTILS=OFF
-DLLVM_BUILD_RUNTIMES=OFF
-DLLVM_BUILD_RUNTIME=OFF
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_ENABLE_BINDINGS=OFF
-DLLVM_ENABLE_TERMINFO=OFF
-DLLVM_ENABLE_ZLIB=OFF
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
-DLIBOMP_OMPT_SUPPORT=OFF
-DCLANG_ENABLE_ARCMT=OFF
-DCLANG_ANALYZER_ENABLE_Z3_SOLVER=OFF
-DCLANG_ENABLE_STATIC_ANALYZER=OFF)
if(${CMAKE_VERSION} VERSION_LESS 3.7)
ExternalProject_Add(
ext_llvm
PREFIX llvm
GIT_REPOSITORY https://github.com/llvm/llvm-project.git
GIT_TAG llvmorg-8.0.0
CMAKE_GENERATOR "@CMAKE_GENERATOR@"
CMAKE_GENERATOR_PLATFORM @CMAKE_GENERATOR_PLATFORM@
CMAKE_GENERATOR_TOOLSET @CMAKE_GENERATOR_TOOLSET@
UPDATE_COMMAND ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../ext_llvm/llvm -G "@CMAKE_GENERATOR@" ${LLVM_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
PATCH_COMMAND ${LLVM_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace @CMAKE_CURRENT_SOURCE_DIR@/cmake/llvm.patch
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
ext_llvm
PREFIX llvm
GIT_REPOSITORY https://github.com/llvm/llvm-project.git
GIT_TAG llvmorg-8.0.0
GIT_SHALLOW 1
CMAKE_GENERATOR "@CMAKE_GENERATOR@"
CMAKE_GENERATOR_PLATFORM @CMAKE_GENERATOR_PLATFORM@
CMAKE_GENERATOR_TOOLSET @CMAKE_GENERATOR_TOOLSET@
CMAKE_ARGS ${LLVM_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
UPDATE_COMMAND ""
PATCH_COMMAND ${LLVM_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace @CMAKE_CURRENT_SOURCE_DIR@/cmake/llvm.patch
SOURCE_SUBDIR llvm
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
endif()
endif()
......@@ -23,14 +23,13 @@ endif()
set(SDL_cmake_included true)
if(UNIX)
set(SDL_CXX_FLAGS "-O2 -Wformat -Wformat-security")
set(SDL_CXX_FLAGS "${SDL_CXX_FLAGS} -D_FORTIFY_SOURCE=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
list(APPEND NGRAPH_COMMON_FLAGS -Wformat -Wformat-security)
list(APPEND NGRAPH_COMMON_FLAGS -O2 -D_FORTIFY_SOURCE=2)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
set(SDL_CXX_FLAGS "${SDL_CXX_FLAGS} -fstack-protector-all")
list(APPEND NGRAPH_COMMON_FLAGS -fstack-protector-all)
else()
set(SDL_CXX_FLAGS "${SDL_CXX_FLAGS} -fstack-protector-strong")
list(APPEND NGRAPH_COMMON_FLAGS -fstack-protector-strong)
endif()
# GCC might be very paranoid for partial structure initialization, e.g.
......@@ -42,12 +41,10 @@ if(UNIX)
# set(CMAKE_SRC_CCXX_FLAGS "${CMAKE_SRC_CCXX_FLAGS} -Wmissing-field-initializers")
# set(CMAKE_EXAMPLE_CCXX_FLAGS "${CMAKE_EXAMPLE_CCXX_FLAGS} -Wmissing-field-initializers")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(SDL_CXX_FLAGS "${SDL_CXX_FLAGS} -fstack-protector-all")
list(APPEND NGRAPH_COMMON_FLAGS -fstack-protector-all)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
list(APPEND NGRAPH_COMMON_FLAGS -fstack-protector)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SDL_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SDL_CXX_FLAGS}")
if(APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-bind_at_load")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-bind_at_load")
......
......@@ -35,10 +35,8 @@ if(NOT WIN32)
set_source_files_properties(compiler.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti")
endif()
get_target_property(LLVM_INCLUDE_DIR libllvm INTERFACE_INCLUDE_DIRECTORIES)
# find_file(HEADER_1 cmath HINTS /usr/include/c++/7)
get_filename_component(CLANG_INCLUDE_DIR ${LLVM_INCLUDE_DIR}/../lib/clang/${NGRAPH_LLVM_VERSION}/include ABSOLUTE)
get_filename_component(CLANG_INTRIN_INCLUDE_DIR ${LLVM_INCLUDE_DIRS}/../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include ABSOLUTE)
if(NGRAPH_CPU_ENABLE)
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
......@@ -47,7 +45,7 @@ if(NGRAPH_CPU_ENABLE)
list(APPEND HEADER_SEARCH_DEFINES MKLDNN_HEADERS_PATH="${MKLDNN_INCLUDE_DIR}")
endif()
list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${CLANG_INCLUDE_DIR}")
list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${CLANG_INTRIN_INCLUDE_DIR}")
list(APPEND HEADER_SEARCH_DEFINES NGRAPH_HEADERS_PATH="${NGRAPH_INCLUDE_PATH}")
if(NGRAPH_TBB_ENABLE)
......
......@@ -31,9 +31,8 @@ set (SRC
add_executable(resource_generator EXCLUDE_FROM_ALL ${SRC})
add_dependencies(resource_generator libllvm)
get_target_property(LLVM_INCLUDE_DIR libllvm INTERFACE_INCLUDE_DIRECTORIES)
get_filename_component(CLANG_INCLUDE_DIR ${LLVM_INCLUDE_DIR}/../lib/clang/${NGRAPH_LLVM_VERSION}/include ABSOLUTE)
list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${CLANG_INCLUDE_DIR}")
get_filename_component(CLANG_INTRIN_INCLUDE_DIR ${LLVM_INCLUDE_DIRS}/../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include ABSOLUTE)
list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${CLANG_INTRIN_INCLUDE_DIR}")
list(APPEND HEADER_SEARCH_DEFINES NGRAPH_HEADERS_PATH="${NGRAPH_INCLUDE_PATH}")
if(NGRAPH_CPU_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