Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Fboemer/external project fix (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboemer authored and avijit-nervana committed Dec 11, 2018
1 parent 7a41d9f commit da0521b
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 79 deletions.
46 changes: 23 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT APPLE)
if(NOT APPLE)
# FIXME: Doesn't work for Ubuntu
execute_process(COMMAND cat /etc/os-release
execute_process(COMMAND cat /etc/os-release
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
Expand Down Expand Up @@ -106,7 +106,7 @@ endif()
# Therefore we are setting two entries in the RPATH:
# 1. $ORIGIN/.
# 2. $ORIGIN/../tensorflow/
#
#
set(CMAKE_MACOSX_RPATH 1)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/;@loader_path/../tensorflow;")
Expand All @@ -120,19 +120,18 @@ endif()
find_package(TensorFlow REQUIRED)

add_library(tensorflow_framework_lib SHARED IMPORTED)
set_target_properties(
tensorflow_framework_lib
PROPERTIES IMPORTED_LOCATION
set_target_properties(
tensorflow_framework_lib
PROPERTIES IMPORTED_LOCATION
${TensorFlow_DIR}/libtensorflow_framework.so
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(NGRAPH_TF_CXX11_ABI "${TensorFlow_CXX_ABI}")
message( STATUS "nGraph-TensorFlow using CXX11 ABI: ${NGRAPH_TF_CXX11_ABI}" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_TF_CXX11_ABI}")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_TF_CXX11_ABI}")

if(APPLE)
set(LIBNGRAPH_SO "libngraph.dylib")
else()
Expand All @@ -158,7 +157,7 @@ endif()
if(USE_PRE_BUILT_NGRAPH)
if(NOT NGRAPH_ARTIFACTS_DIR)
message(
FATAL_ERROR
FATAL_ERROR
"USE_PRE_BUILT_NGRAPH is ON but NGRAPH_ARTIFACTS_DIR is missing"
)
endif()
Expand All @@ -174,9 +173,9 @@ if(USE_PRE_BUILT_NGRAPH)
ABSOLUTE
)
if (NOT EXISTS ${NGRAPH_ARTIFACTS_DIR})
message(FATAL_ERROR
message(FATAL_ERROR
"nGraph artifacts directory doesn't exist: " ${NGRAPH_ARTIFACTS_DIR} )
endif()
endif()
else()
set(NGRAPH_ARTIFACTS_DIR ${CMAKE_CURRENT_BINARY_DIR}/ngraph/ngraph_dist)
endif()
Expand All @@ -194,22 +193,22 @@ if(UNIT_TEST_TF_CC_DIR)
ABSOLUTE
)
if (NOT EXISTS ${TF_PRE_BUILT_LOCATION})
message(FATAL_ERROR
message(FATAL_ERROR
"TensorFlow pre-built directory doesn't exist: " ${TF_PRE_BUILT_LOCATION} )
endif()

endif()

# Enable build target CPU features
set(
NGRAPH_TARGET_ARCH
native
NGRAPH_TARGET_ARCH
native
CACHE STRING "Target CPU architecture to build for.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${NGRAPH_TARGET_ARCH}")

set(
NGRAPH_TUNE_ARCH
native
NGRAPH_TUNE_ARCH
native
CACHE STRING "Target CPU architecture to tune for")

message(STATUS "UNIT_TEST_ENABLE: ${UNIT_TEST_ENABLE}")
Expand All @@ -228,14 +227,15 @@ if (NOT USE_PRE_BUILT_NGRAPH)
ext_ngraph
GIT_REPOSITORY https://github.com/NervanaSystems/ngraph
GIT_TAG 90aa7336dfbf21d3ecab1b50aa8676c2fe1bd75d
CMAKE_ARGS
CMAKE_ARGS
-DNGRAPH_DISTRIBUTED_ENABLE=${NGRAPH_DISTRIBUTED_ENABLE}
-DNGRAPH_INSTALL_PREFIX=${NGRAPH_ARTIFACTS_DIR}
-DNGRAPH_INSTALL_PREFIX=${NGRAPH_ARTIFACTS_DIR}
-DNGRAPH_USE_CXX_ABI=${TensorFlow_CXX_ABI}
-DNGRAPH_UNIT_TEST_ENABLE=FALSE
-DNGRAPH_TOOLS_ENABLE=${NGRAPH_TOOLS_ENABLE}
-DNGRAPH_DEX_ONLY=TRUE
-DNGRAPH_DEX_ONLY=TRUE
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DNGRAPH_GPU_ENABLE=${NGRAPH_GPU_ENABLE}
-DNGRAPH_DEBUG_ENABLE=${NGRAPH_DEBUG_ENABLE}
-DNGRAPH_PLAIDML_ENABLE=${NGRAPH_PLAIDML_ENABLE}
Expand All @@ -251,7 +251,7 @@ if (NOT USE_PRE_BUILT_NGRAPH)
UPDATE_COMMAND ""
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
)
endif()
endif()
set(NGRAPH_INSTALL_DIR ${NGRAPH_ARTIFACTS_DIR})


Expand All @@ -262,9 +262,9 @@ else()
endif()

add_library(ngraph_lib SHARED IMPORTED)
set_target_properties(
ngraph_lib
PROPERTIES IMPORTED_LOCATION
set_target_properties(
ngraph_lib
PROPERTIES IMPORTED_LOCATION
${NGRAPH_IMPORTED_LOCATION}
)

Expand Down
7 changes: 7 additions & 0 deletions cmake/external_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ SET(GTEST_GIT_REPO_URL https://github.com/google/googletest.git)
SET(GTEST_GIT_LABEL release-1.8.0)

set(CXX_FLAGS "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -fPIC")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
set(CXX_FLAGS "${CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}")
endif()
endif()

# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if (${CMAKE_VERSION} VERSION_LESS 3.2)
Expand All @@ -36,6 +41,7 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2)
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS ${CXX_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download"
Expand All @@ -52,6 +58,7 @@ else()
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS ${CXX_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download"
Expand Down
72 changes: 36 additions & 36 deletions python/CreatePipWhl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,58 +45,58 @@ if (PYTHON)
endif()
message(STATUS "LIB_SUFFIX: ${NGTF_INSTALL_DIR}/${LIB_SUFFIX}")
file(GLOB NGRAPH_LIB_FILES "${NGTF_INSTALL_DIR}/${LIB_SUFFIX}/lib*")

# Copy the ngraph_bridge libraries from install
foreach(DEP_FILE ${NGRAPH_LIB_FILES})
get_filename_component(lib_file_real_path ${DEP_FILE} ABSOLUTE)
get_filename_component(lib_file_name ${DEP_FILE} NAME)
set(ngraph_libraries "${ngraph_libraries}\"${lib_file_name}\",\n\t")
file(COPY ${lib_file_real_path}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge")
endforeach()
file(COPY ${lib_file_real_path}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge")
endforeach()

# Get the list of license files
file(GLOB NGRAPH_TF_LICENSE_FILES "${NGTF_SRC_DIR}/third-party/licenses/*")

# Get the list of license files
file(GLOB NGRAPH_TF_LICENCE_FILES "${NGTF_SRC_DIR}/third-party/licenses/*")

# Copy the licenses for ngraph-tf
foreach(DEP_FILE ${NGRAPH_TF_LICENCE_FILES})
foreach(DEP_FILE ${NGRAPH_TF_LICENSE_FILES})
get_filename_component(lic_file_real_path ${DEP_FILE} ABSOLUTE)
get_filename_component(lic_file_name ${DEP_FILE} NAME)
set(
license_files
license_files
"${license_files}\"licenses/${lic_file_name}\",\n\t")
file(COPY ${lic_file_real_path}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses")
endforeach()
file(COPY ${lic_file_real_path}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses")
endforeach()

# Get the list of license files for ngraph
file(GLOB NGRAPH_LICENCE_FILES "${NGRAPH_INSTALL_DIR}/licenses/*")
file(GLOB NGRAPH_LICENSE_FILES "${NGRAPH_INSTALL_DIR}/licenses/*")

# Copy the licenses for ngraph-tf
foreach(DEP_FILE ${NGRAPH_LICENCE_FILES})
foreach(DEP_FILE ${NGRAPH_LICENSE_FILES})
get_filename_component(lic_file_real_path ${DEP_FILE} ABSOLUTE)
get_filename_component(lic_file_name ${DEP_FILE} NAME)
set(
license_files
license_files
"${license_files}\"licenses/${lic_file_name}\",\n\t")
file(COPY ${lic_file_real_path}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses")
endforeach()
file(COPY ${lic_file_real_path}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses")
endforeach()

# Copy the LICENSE at the toplevel
file(COPY ${CMAKE_SOURCE_DIR}/../LICENSE
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/python/ngraph_bridge")
# Copy the LICENSE at the top level
file(COPY ${CMAKE_CURRENT_LIST_DIR}/../LICENSE
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge")
set(
licence_top_level
licence_top_level
"\"LICENSE\"")

configure_file(${SETUP_PY_IN} ${SETUP_PY})
configure_file(${INIT_PY_IN} ${INIT_PY})
if (APPLE)
execute_process(COMMAND
install_name_tool -change
libngraph.dylib
@loader_path/libngraph.dylib
execute_process(COMMAND
install_name_tool -change
libngraph.dylib
@loader_path/libngraph.dylib
${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/libngraph_bridge.dylib
RESULT_VARIABLE result
ERROR_VARIABLE ERR
Expand All @@ -106,10 +106,10 @@ if (PYTHON)
message(FATAL_ERROR "Cannot update @loader_path")
endif()

execute_process(COMMAND
install_name_tool -change
libngraph.dylib
@loader_path/libngraph.dylib
execute_process(COMMAND
install_name_tool -change
libngraph.dylib
@loader_path/libngraph.dylib
${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/libcpu_backend.dylib
RESULT_VARIABLE result
ERROR_VARIABLE ERR
Expand All @@ -128,10 +128,10 @@ if (PYTHON)

FOREACH(lib_file ${cpu_lib_list})
message("Library: " ${lib_file})
execute_process(COMMAND
install_name_tool -change
@rpath/${lib_file}
@loader_path/${lib_file}
execute_process(COMMAND
install_name_tool -change
@rpath/${lib_file}
@loader_path/${lib_file}
${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/libcpu_backend.dylib
RESULT_VARIABLE result
ERROR_VARIABLE ERR
Expand Down Expand Up @@ -190,5 +190,5 @@ if (PYTHON)
COMMAND ${PYTHON} "setup.py" "bdist_wheel"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python/
)

endif()
36 changes: 18 additions & 18 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include_directories(${TensorFlow_INCLUDE_DIR}/external/nsync/public)
# Get this location from the CMAKE variables passed during the cmake time
if (NOT DEFINED TF_SRC_DIR)
message(
FATAL_ERROR
FATAL_ERROR
"TensorFlow source directory.Use -DTF_SRC_DIR=<tf source directory>"
)
endif()
Expand All @@ -33,9 +33,9 @@ include_directories(${TensorFlow_SRC_DIR})
include_directories(${TensorFlow_SRC_DIR}/bazel-genfiles)

add_library(tensorflow_cc_lib SHARED IMPORTED)
set_target_properties(
tensorflow_cc_lib
PROPERTIES IMPORTED_LOCATION
set_target_properties(
tensorflow_cc_lib
PROPERTIES IMPORTED_LOCATION
${TensorFlow_SRC_DIR}/bazel-bin/tensorflow/libtensorflow_cc.so
)

Expand Down Expand Up @@ -63,16 +63,16 @@ message(STATUS "Shared Link Flags: ${CMAKE_SHARED_LINKER_FLAGS}")
add_executable(gtest_ngtf ${SRC})
message(STATUS "TensorFlow_SRC_DIR: ${TensorFlow_SRC_DIR}")

# The following custom commands are used to create symlinks for various
# The following custom commands are used to create symlinks for various
# input files needed by the unit test
add_custom_command(
add_custom_command(
TARGET gtest_ngtf
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/test_axpy.pbtxt
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/test_axpy.pbtxt
${CMAKE_CURRENT_BINARY_DIR}/test_axpy.pbtxt
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/test_axpy_launchop.pbtxt
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/test_axpy_launchop.pbtxt
${CMAKE_CURRENT_BINARY_DIR}/test_axpy_launchop.pbtxt
)

Expand All @@ -81,24 +81,24 @@ if (APPLE)
endif()

if (NOT UNIT_TEST_TF_CC_DIR)
add_custom_target(
add_custom_target(
build_tf_cc
COMMENT "Building TensorFlow C++ library"
COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/build_tf_cc.sh
${TensorFlow_SRC_DIR}
COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/build_tf_cc.sh
${TensorFlow_SRC_DIR}
${NGRAPH_TF_CXX11_ABI}
)

add_dependencies(gtest_ngtf build_tf_cc)
endif()

target_link_libraries(
gtest_ngtf
ngraph_bridge
gtest_ngtf
ngraph_bridge
ngraph_lib
libgtest
pthread
libgtest
pthread
tensorflow_framework_lib
tensorflow_cc_lib
)
Expand Down
2 changes: 1 addition & 1 deletion test/ci/docker/docker-scripts/run-ngraph-tf-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ cd "${bridge_dir}"

if [ ! -d "${ngraph_dist_dir}" ] ; then
( >&2 echo '***** Error: *****' )
( >&2 echo "ngraph_dist directory does not exist -- this likely indicatesa build failure: ${ngraph_dist_dir}" )
( >&2 echo "ngraph_dist directory does not exist -- this likely indicates a build failure: ${ngraph_dist_dir}" )
exit 1
fi

Expand Down
3 changes: 2 additions & 1 deletion third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ ExternalProject_Add(
ext_abseil
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
GIT_TAG f21d187b80e3b7f08fb279775ea9c8b48c636030
CMAKE_ARGS
CMAKE_ARGS
-DBUILD_TESTING=OFF
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/abseil/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/abseil/build"
INSTALL_COMMAND ""
Expand Down

0 comments on commit da0521b

Please sign in to comment.