Unverified Commit 08dcd01b authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

Cleanup how compile flags are set and used by nGraph and external projects. (#2942)

* Cleanup how compile flags set and used by nGraph and external projects.
Set C++11 through CMake and pass it down to external projects.
Prefer CMake variables such as CMAKE_POSITION_INDEPENDENT_CODE and
CMAKE_CXX_STANDARD instead of explicitly setting compiler dependent
flags.
Create json compilation database for external projects.
CMAKE_CXX_FLAGS is used as common global options for nGraph and external
projects.
add_compile_options() is used for local options for current and sub
directories.
add_definitions() is used for setting definitions for current and sub
directories.
Note: Global options are not passed down to some external projects.
Note: mkl-dnn resets CMAKE_CXX_FLAGS internally.
Note: TBB and MLSL are not CMake based.
Noet: Eigen and json is header only library.

* Fix error.

* Fix error. (second attempt)

* Cleanup code.

* Allow check for undefined macro.

* Try to fix cldnn issue.

* Set type for CMake arguments.

* Pass C++ standard to protobuf.

* Pass C++ standard down to TBB.

* Change how Clang specific flags are handled.

* Fix error.

* Workaround for compile error on Baidu's PDPD docker.

* Fix windows build error.
parent b520e839
...@@ -114,18 +114,32 @@ if (APPLE) ...@@ -114,18 +114,32 @@ if (APPLE)
endif() endif()
endif() endif()
set(NGRAPH_CXX_STANDARD 11)
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 # 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) if (CMAKE_OSX_SYSROOT)
set(NGRAPH_FORWARD_CMAKE_ARGS set(NGRAPH_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} )
)
else()
set(NGRAPH_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)
endif() endif()
if (NOT MSVS) if (NOT MSVS)
...@@ -145,9 +159,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY -DTBB_USE_THREADING_TO ...@@ -145,9 +159,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY -DTBB_USE_THREADING_TO
ngraph_var(NGRAPH_USE_PREBUILT_LLVM DEFAULT "FALSE") ngraph_var(NGRAPH_USE_PREBUILT_LLVM DEFAULT "FALSE")
# Create compilation database compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(NGRAPH_UNIT_TEST_ENABLE "Control the building of unit tests" TRUE) option(NGRAPH_UNIT_TEST_ENABLE "Control the building of unit tests" TRUE)
option(NGRAPH_TOOLS_ENABLE "Control the building of tool" TRUE) option(NGRAPH_TOOLS_ENABLE "Control the building of tool" TRUE)
option(NGRAPH_CPU_ENABLE "Control the building of the CPU backend" TRUE) option(NGRAPH_CPU_ENABLE "Control the building of the CPU backend" TRUE)
...@@ -303,10 +314,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$") ...@@ -303,10 +314,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$")
endif() endif()
if (WIN32) if (WIN32)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "/W0 /EHsc /MP") set(CMAKE_CXX_FLAGS "/W0 /EHsc /MP")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
# These can be uncommented once we have visibility fully in place # These can be uncommented once we have visibility fully in place
...@@ -418,6 +427,20 @@ if(NGRAPH_DEPRECATED_ENABLE) ...@@ -418,6 +427,20 @@ if(NGRAPH_DEPRECATED_ENABLE)
add_definitions(-DNGRAPH_DEPRECATED_ENABLE) add_definitions(-DNGRAPH_DEPRECATED_ENABLE)
endif() endif()
if(NGRAPH_JSON_ENABLE)
add_definitions(-DNGRAPH_JSON_ENABLE)
endif()
add_definitions(-DPROJECT_ROOT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
#-----------------------------------------------------------------------------------------------
# Print Global Options
#-----------------------------------------------------------------------------------------------
message(STATUS "Compile Flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "Shared Link Flags: ${CMAKE_SHARED_LINKER_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
# External projects install directory # External projects install directory
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
...@@ -464,7 +487,6 @@ endif() ...@@ -464,7 +487,6 @@ endif()
include(cmake/external_gtest.cmake) include(cmake/external_gtest.cmake)
if(NGRAPH_JSON_ENABLE) if(NGRAPH_JSON_ENABLE)
add_definitions(-DNGRAPH_JSON_ENABLE)
include(cmake/external_json.cmake) include(cmake/external_json.cmake)
endif() endif()
if(NGRAPH_CPU_ENABLE OR NGRAPH_GENERIC_CPU_ENABLE) if(NGRAPH_CPU_ENABLE OR NGRAPH_GENERIC_CPU_ENABLE)
...@@ -512,22 +534,9 @@ if (NGRAPH_HALIDE) ...@@ -512,22 +534,9 @@ if (NGRAPH_HALIDE)
include(cmake/external_halide.cmake) include(cmake/external_halide.cmake)
endif() endif()
add_definitions(-DPROJECT_ROOT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "Compile Flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "Shared Link Flags: ${CMAKE_SHARED_LINKER_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
add_subdirectory(src) add_subdirectory(src)
if (NGRAPH_UNIT_TEST_ENABLE) add_subdirectory(test)
add_subdirectory(test)
message(STATUS "unit tests enabled")
else()
add_subdirectory(test/models)
add_subdirectory(test/util)
message(STATUS "unit tests disabled")
endif()
if (NGRAPH_DOC_BUILD_ENABLE) if (NGRAPH_DOC_BUILD_ENABLE)
add_subdirectory(doc) add_subdirectory(doc)
......
...@@ -14,42 +14,43 @@ ...@@ -14,42 +14,43 @@
# limitations under the License. # limitations under the License.
# ****************************************************************************** # ******************************************************************************
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type") add_compile_options(-Werror=return-type)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=inconsistent-missing-override") add_compile_options(-Werror=inconsistent-missing-override)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=comment") add_compile_options(-Werror=comment)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") add_compile_options(-pedantic-errors)
# whitelist errors here # whitelist errors here
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything") add_compile_options(-Weverything)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments") add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic") add_compile_options(-Wno-c++98-compat-pedantic)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables") add_compile_options(-Wno-weak-vtables)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors") add_compile_options(-Wno-global-constructors)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors") add_compile_options(-Wno-exit-time-destructors)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-prototypes") add_compile_options(-Wno-missing-prototypes)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-noreturn") add_compile_options(-Wno-missing-noreturn)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch") add_compile_options(-Wno-switch)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum") add_compile_options(-Wno-switch-enum)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default") add_compile_options(-Wno-covered-switch-default)
add_compile_options(-Wno-undef)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.1.0) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.1.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant") add_compile_options(-Wno-zero-as-null-pointer-constant)
endif() endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.0.0") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.0.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-lambda-capture") add_compile_options(-Wno-unused-lambda-capture)
endif() endif()
endif() endif()
# # should remove these # should remove these
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast") # add_compile_options(-Wno-old-style-cast)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-conversion") add_compile_options(-Wno-float-conversion)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-conversion") add_compile_options(-Wno-sign-conversion)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded") add_compile_options(-Wno-padded)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") add_compile_options(-Wno-sign-compare)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") add_compile_options(-Wno-unused-parameter)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion") add_compile_options(-Wno-conversion)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion") add_compile_options(-Wno-double-promotion)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-func-template") add_compile_options(-Wno-undefined-func-template)
...@@ -26,15 +26,6 @@ set(CLDNN_GIT_LABEL a05c9f29c5690a4beb9cd8c9f712cfb4399b2a6d) ...@@ -26,15 +26,6 @@ set(CLDNN_GIT_LABEL a05c9f29c5690a4beb9cd8c9f712cfb4399b2a6d)
set(BOOST_VERSION 1.64.0) set(BOOST_VERSION 1.64.0)
set(OUT_DIR ${EXTERNAL_PROJECTS_ROOT}/cldnn/out) set(OUT_DIR ${EXTERNAL_PROJECTS_ROOT}/cldnn/out)
if(NOT WIN32)
set(COMPILE_FLAGS -fPIC)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}")
endif()
endif()
ExternalProject_Add( ExternalProject_Add(
ext_cldnn ext_cldnn
PREFIX cldnn PREFIX cldnn
...@@ -48,10 +39,12 @@ ExternalProject_Add( ...@@ -48,10 +39,12 @@ ExternalProject_Add(
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS} ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
# -DCLDNN__OUTPUT_DIR=out/Debug # -DCLDNN__OUTPUT_DIR=out/Debug
-DCLDNN__BOOST_VERSION=${BOOST_VERSION} -DCLDNN__BOOST_VERSION=${BOOST_VERSION}
-DCLDNN__INCLUDE_TESTS=FALSE -DCLDNN__INCLUDE_TESTS=OFF
-DCLDNN__INCLUDE_TUTORIAL=FALSE -DCLDNN__INCLUDE_CORE_INTERNAL_TESTS=OFF
-DCLDNN__INCLUDE_TUTORIAL=OFF
EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_ALL TRUE
) )
......
...@@ -24,22 +24,9 @@ include(ExternalProject) ...@@ -24,22 +24,9 @@ include(ExternalProject)
SET(GTEST_GIT_REPO_URL https://github.com/google/googletest.git) SET(GTEST_GIT_REPO_URL https://github.com/google/googletest.git)
SET(GTEST_GIT_LABEL release-1.8.1) SET(GTEST_GIT_LABEL release-1.8.1)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}")
endif()
endif()
set(GMOCK_OUTPUT_DIR ${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock) set(GMOCK_OUTPUT_DIR ${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock)
set(GTEST_OUTPUT_DIR ${GMOCK_OUTPUT_DIR}/gtest) set(GTEST_OUTPUT_DIR ${GMOCK_OUTPUT_DIR}/gtest)
if (APPLE OR LINUX)
set(COMPILE_FLAGS -fPIC)
endif()
set(GTEST_CMAKE_ARGS
-DCMAKE_CXX_FLAGS=${COMPILE_FLAGS}
)
if(WIN32) if(WIN32)
list(APPEND GTEST_CMAKE_ARGS list(APPEND GTEST_CMAKE_ARGS
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=${GTEST_OUTPUT_DIR} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=${GTEST_OUTPUT_DIR}
...@@ -48,6 +35,14 @@ if(WIN32) ...@@ -48,6 +35,14 @@ if(WIN32)
) )
endif() endif()
if(LINUX)
# workaround for compile error
# related: https://github.com/intel/mkl-dnn/issues/55
set(GTEST_CXX_FLAGS -Wno-unused-result ${CMAKE_CXX_FLAGS})
else()
set(GTEST_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif()
ExternalProject_Add( ExternalProject_Add(
ext_gtest ext_gtest
PREFIX gtest PREFIX gtest
...@@ -61,6 +56,7 @@ ExternalProject_Add( ...@@ -61,6 +56,7 @@ ExternalProject_Add(
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS} ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${GTEST_CXX_FLAGS}
${GTEST_CMAKE_ARGS} ${GTEST_CMAKE_ARGS}
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build" BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build"
EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_ALL TRUE
......
...@@ -52,6 +52,7 @@ ExternalProject_Add( ...@@ -52,6 +52,7 @@ ExternalProject_Add(
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS} ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DLLVM_DIR=${HALIDE_LLVM_DIR} -DLLVM_DIR=${HALIDE_LLVM_DIR}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/halide -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/halide
-DHALIDE_SHARED_LIBRARY=OFF -DHALIDE_SHARED_LIBRARY=OFF
......
...@@ -18,12 +18,6 @@ include(ExternalProject) ...@@ -18,12 +18,6 @@ include(ExternalProject)
set(NGRAPH_LLVM_VERSION 8.0.0) set(NGRAPH_LLVM_VERSION 8.0.0)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
set(COMPILE_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}")
endif()
endif()
ExternalProject_Add( ExternalProject_Add(
ext_clang ext_clang
PREFIX clang PREFIX clang
...@@ -77,8 +71,8 @@ ExternalProject_Add( ...@@ -77,8 +71,8 @@ ExternalProject_Add(
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM} CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS} CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_ASM_COMPILER=${LLVM_CMAKE_ASM_COMPILER} -DCMAKE_ASM_COMPILER=${LLVM_CMAKE_ASM_COMPILER}
-DCMAKE_CXX_FLAGS=${COMPILE_FLAGS}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/llvm -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/llvm
-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_DOCS=OFF
-DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF
......
...@@ -41,6 +41,7 @@ ExternalProject_Add( ...@@ -41,6 +41,7 @@ ExternalProject_Add(
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM} CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS} CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DONNX_GEN_PB_TYPE_STUBS=OFF -DONNX_GEN_PB_TYPE_STUBS=OFF
-DCMAKE_PREFIX_PATH=${Protobuf_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${Protobuf_INSTALL_PREFIX}
-DONNX_ML=TRUE -DONNX_ML=TRUE
......
...@@ -38,6 +38,7 @@ if (WIN32) ...@@ -38,6 +38,7 @@ if (WIN32)
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS} ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF
-Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_WITH_ZLIB=OFF
-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_TESTS=OFF
...@@ -60,7 +61,8 @@ elseif (APPLE) ...@@ -60,7 +61,8 @@ elseif (APPLE)
GIT_TAG ${NGRAPH_PROTOBUF_GIT_TAG} GIT_TAG ${NGRAPH_PROTOBUF_GIT_TAG}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${EXTERNAL_PROJECTS_ROOT}/protobuf --disable-shared CXXFLAGS=-fPIC CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${EXTERNAL_PROJECTS_ROOT}/protobuf --disable-shared
BUILD_COMMAND $(MAKE) "CXXFLAGS=-std=c++${NGRAPH_CXX_STANDARD} -fPIC"
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp" TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp" STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download" DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download"
...@@ -77,7 +79,8 @@ else() ...@@ -77,7 +79,8 @@ else()
GIT_TAG ${NGRAPH_PROTOBUF_GIT_TAG} GIT_TAG ${NGRAPH_PROTOBUF_GIT_TAG}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${EXTERNAL_PROJECTS_ROOT}/protobuf --disable-shared CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=-fPIC CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${EXTERNAL_PROJECTS_ROOT}/protobuf --disable-shared CXX=${CMAKE_CXX_COMPILER}
BUILD_COMMAND $(MAKE) "CXXFLAGS=-std=c++${NGRAPH_CXX_STANDARD} -fPIC"
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp" TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp" STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download" DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download"
......
...@@ -32,7 +32,7 @@ if(NGRAPH_TBB_ENABLE) ...@@ -32,7 +32,7 @@ if(NGRAPH_TBB_ENABLE)
include(${TBB_ROOT}/cmake/TBBBuild.cmake) include(${TBB_ROOT}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build
tbb_build_prefix=tbb CONFIG_DIR TBB_DIR) tbb_build_prefix=tbb stdver=c++${NGRAPH_CXX_STANDARD} CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb) find_package(TBB REQUIRED tbb)
if (NOT TBB_FOUND) if (NOT TBB_FOUND)
message(FATAL_ERROR "TBB is needed by the CPU backend and was not found") message(FATAL_ERROR "TBB is needed by the CPU backend and was not found")
......
...@@ -23,7 +23,7 @@ endif() ...@@ -23,7 +23,7 @@ endif()
set(SDL_cmake_included true) set(SDL_cmake_included true)
if(UNIX) if(UNIX)
set(SDL_CXX_FLAGS "-O2 -fPIC -Wformat -Wformat-security") set(SDL_CXX_FLAGS "-O2 -Wformat -Wformat-security")
set(SDL_CXX_FLAGS "${SDL_CXX_FLAGS} -D_FORTIFY_SOURCE=2") set(SDL_CXX_FLAGS "${SDL_CXX_FLAGS} -D_FORTIFY_SOURCE=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
# ****************************************************************************** # ******************************************************************************
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIN_NGRAPH_LIBRARY") add_definitions(-DIN_NGRAPH_LIBRARY)
include_directories(ngraph) include_directories(ngraph)
......
...@@ -525,7 +525,7 @@ endif() ...@@ -525,7 +525,7 @@ endif()
if(NGRAPH_ADDRESS_SANITIZER) if(NGRAPH_ADDRESS_SANITIZER)
message(STATUS "Enable Address Sanitizer") message(STATUS "Enable Address Sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer") add_compile_options(-g -fsanitize=address -fno-omit-frame-pointer)
endif() endif()
add_subdirectory(codegen) add_subdirectory(codegen)
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
if (NGRAPH_GENERIC_CPU_ENABLE) if (NGRAPH_GENERIC_CPU_ENABLE)
find_package(OpenMP) find_package(OpenMP)
if (OPENMP_FOUND) if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") add_compile_options(${OpenMP_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif() endif()
add_library(gcpu_backend SHARED gcpu_backend.cpp gcpu_executable.cpp node_wrapper.cpp) add_library(gcpu_backend SHARED gcpu_backend.cpp gcpu_executable.cpp node_wrapper.cpp)
if(NGRAPH_LIB_VERSIONING_ENABLE) if(NGRAPH_LIB_VERSIONING_ENABLE)
...@@ -27,7 +26,6 @@ if (NGRAPH_GENERIC_CPU_ENABLE) ...@@ -27,7 +26,6 @@ if (NGRAPH_GENERIC_CPU_ENABLE)
SOVERSION ${NGRAPH_API_VERSION}) SOVERSION ${NGRAPH_API_VERSION})
endif() endif()
target_link_libraries(gcpu_backend PRIVATE ngraph libeigen) target_link_libraries(gcpu_backend PRIVATE ngraph libeigen)
target_compile_options(gcpu_backend PUBLIC -fopenmp)
install(TARGETS gcpu_backend install(TARGETS gcpu_backend
LIBRARY DESTINATION "${NGRAPH_INSTALL_LIB}" LIBRARY DESTINATION "${NGRAPH_INSTALL_LIB}"
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <iostream> #include <cstdio>
#include "ngraph/runtime/gpu/nvcc/kernels.hpp" #include "ngraph/runtime/gpu/nvcc/kernels.hpp"
using namespace ngraph; using namespace ngraph;
......
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
# limitations under the License. # limitations under the License.
# ****************************************************************************** # ******************************************************************************
add_definitions("-DSERIALIZED_ZOO=\"${CMAKE_CURRENT_SOURCE_DIR}/models\"")
if(NOT NGRAPH_UNIT_TEST_ENABLE)
message(STATUS "unit tests disabled")
add_subdirectory(util)
return()
endif()
message(STATUS "unit tests enabled")
if(LINUX) if(LINUX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
endif() endif()
...@@ -22,7 +32,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ...@@ -22,7 +32,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.0.0") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.0.0")
# gtest has issues with this with v1.8.x # gtest has issues with this with v1.8.x
# gtest issue is supposed to be addressed after v1.8.x # gtest issue is supposed to be addressed after v1.8.x
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant") add_compile_options(-Wno-zero-as-null-pointer-constant)
endif() endif()
endif() endif()
...@@ -127,8 +137,7 @@ if (NGRAPH_GENERIC_CPU_ENABLE) ...@@ -127,8 +137,7 @@ if (NGRAPH_GENERIC_CPU_ENABLE)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} GCPU) set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} GCPU)
endif() endif()
add_subdirectory(models) add_definitions("-DTEST_FILES=\"${CMAKE_CURRENT_SOURCE_DIR}/files\"")
add_subdirectory(files)
add_subdirectory(util) add_subdirectory(util)
# backend specific test files must meet the following requirements: # backend specific test files must meet the following requirements:
...@@ -212,12 +221,11 @@ add_executable(unit-test ${SRC}) ...@@ -212,12 +221,11 @@ add_executable(unit-test ${SRC})
target_include_directories(unit-test PRIVATE ".") target_include_directories(unit-test PRIVATE ".")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions("-DCURDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"") add_definitions("-DJSON_INCLUDES=\"${JSON_INCLUDE_DIR}\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_INCLUDES=\\\"${JSON_INCLUDE_DIR}\\\"")
if(NGRAPH_ADDRESS_SANITIZER) if(NGRAPH_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer") add_compile_options(-g -fsanitize=address -fno-omit-frame-pointer)
endif() endif()
target_link_libraries(unit-test PRIVATE ngraph_test_util) target_link_libraries(unit-test PRIVATE ngraph_test_util)
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_FILES=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSERIALIZED_ZOO=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"" PARENT_SCOPE)
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