diff --git a/ports/tensorflow-cc/CONTROL b/ports/tensorflow-cc/CONTROL index d422260e33bb20..392ce10136d039 100644 --- a/ports/tensorflow-cc/CONTROL +++ b/ports/tensorflow-cc/CONTROL @@ -1,4 +1,6 @@ Source: tensorflow-cc Version: 2.3.1 -Description: Library for computation using data flow graphs for scalable machine learning +Port-Version: 1 +Homepage: https://github.com/tensorflow/tensorflow +Description: Library for computation using data flow graphs for scalable machine learning (C++ API version) Supports: !(x86|arm|uwp) diff --git a/ports/tensorflow-cc/portfile.cmake b/ports/tensorflow-cc/portfile.cmake index 35dbb5d1b0d3ac..783fe8b70e459b 100644 --- a/ports/tensorflow-cc/portfile.cmake +++ b/ports/tensorflow-cc/portfile.cmake @@ -1,445 +1,10 @@ vcpkg_fail_port_install(ON_ARCH "x86" "arm" ON_TARGET "UWP") -set(TF_VERSION 2.3.1) -set(TF_VERSION_SHORT 2.3) - -vcpkg_find_acquire_program(BAZEL) -get_filename_component(BAZEL_DIR "${BAZEL}" DIRECTORY) -vcpkg_add_to_path(PREPEND ${BAZEL_DIR}) -set(ENV{BAZEL_BIN_PATH} "${BAZEL}") - -function(tensorflow_try_remove_recurse_wait PATH_TO_REMOVE) - file(REMOVE_RECURSE ${PATH_TO_REMOVE}) - if(EXISTS "${PATH_TO_REMOVE}") - vcpkg_execute_required_process(COMMAND ${CMAKE_COMMAND} -E sleep 5 WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-sleep-${TARGET_TRIPLET}) - file(REMOVE_RECURSE ${PATH_TO_REMOVE}) - endif() -endfunction() - -vcpkg_find_acquire_program(GIT) -get_filename_component(GIT_DIR "${GIT}" DIRECTORY) -vcpkg_add_to_path(PREPEND ${GIT_DIR}) - -if(CMAKE_HOST_WIN32) - vcpkg_acquire_msys(MSYS_ROOT PACKAGES bash unzip patch diffutils libintl gzip coreutils mingw-w64-x86_64-python-numpy) - vcpkg_add_to_path(${MSYS_ROOT}/usr/bin) - vcpkg_add_to_path(${MSYS_ROOT}/mingw64/bin) - set(BASH ${MSYS_ROOT}/usr/bin/bash.exe) - - set(ENV{BAZEL_SH} ${MSYS_ROOT}/usr/bin/bash.exe) - set(ENV{BAZEL_VC} $ENV{VCInstallDir}) - set(ENV{BAZEL_VC_FULL_VERSION} $ENV{VCToolsVersion}) - - set(PYTHON3 "${MSYS_ROOT}/mingw64/bin/python3.exe") - vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import site; print(site.getsitepackages()[0])" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pypath-${TARGET_TRIPLET} OUTPUT_VARIABLE PYTHON_LIB_PATH) -else() - vcpkg_find_acquire_program(PYTHON3) - get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) - vcpkg_add_to_path(PREPEND ${PYTHON3_DIR}) - - vcpkg_execute_required_process(COMMAND ${PYTHON3} -m pip install --user -U numpy WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pip-${TARGET_TRIPLET}) - vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import site; print(site.getusersitepackages())" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pypath-${TARGET_TRIPLET} OUTPUT_VARIABLE PYTHON_LIB_PATH) -endif() -set(ENV{PYTHON_BIN_PATH} "${PYTHON3}") -set(ENV{PYTHON_LIB_PATH} "${PYTHON_LIB_PATH}") - -# check if numpy can be loaded -vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import numpy" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-numpy-${TARGET_TRIPLET}) - -# tensorflow has long file names, which will not work on windows -set(ENV{TEST_TMPDIR} ${BUILDTREES_DIR}/.bzl) - -set(ENV{USE_DEFAULT_PYTHON_LIB_PATH} 1) -set(ENV{TF_NEED_KAFKA} 0) -set(ENV{TF_NEED_OPENCL_SYCL} 0) -set(ENV{TF_NEED_AWS} 0) -set(ENV{TF_NEED_GCP} 0) -set(ENV{TF_NEED_HDFS} 0) -set(ENV{TF_NEED_S3} 0) -set(ENV{TF_ENABLE_XLA} 0) -set(ENV{TF_NEED_GDR} 0) -set(ENV{TF_NEED_VERBS} 0) -set(ENV{TF_NEED_OPENCL} 0) -set(ENV{TF_NEED_MPI} 0) -set(ENV{TF_NEED_TENSORRT} 0) -set(ENV{TF_NEED_NGRAPH} 0) -set(ENV{TF_NEED_IGNITE} 0) -set(ENV{TF_NEED_ROCM} 0) -set(ENV{TF_SET_ANDROID_WORKSPACE} 0) -set(ENV{TF_DOWNLOAD_CLANG} 0) -set(ENV{TF_NCCL_VERSION} ${TF_VERSION_SHORT}) -set(ENV{NCCL_INSTALL_PATH} "") -set(ENV{CC_OPT_FLAGS} "/arch:AVX") -set(ENV{TF_NEED_CUDA} 0) -set(ENV{TF_CONFIGURE_IOS} 0) - -if(VCPKG_TARGET_IS_WINDOWS) - set(BAZEL_LIB_NAME tensorflow_cc.dll) - set(PLATFORM_SUFFIX windows) - set(STATIC_LINK_CMD static_link.bat) -elseif(VCPKG_TARGET_IS_OSX) - set(BAZEL_LIB_NAME libtensorflow_cc.dylib) - set(PLATFORM_SUFFIX macos) - set(STATIC_LINK_CMD sh static_link.sh) - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(TF_LIB_NAME "libtensorflow_cc.dylib") - set(TF_LIB_NAME_SHORT "libtensorflow_cc.2.dylib") - set(TF_LIB_NAME_FULL "libtensorflow_cc.${TF_VERSION}.dylib") - set(TF_FRAMEWORK_NAME "libtensorflow_framework.dylib") - set(TF_FRAMEWORK_NAME_SHORT "libtensorflow_framework.2.dylib") - set(TF_FRAMEWORK_NAME_FULL "libtensorflow_framework.${TF_VERSION}.dylib") - else() - set(TF_LIB_NAME "libtensorflow_cc.a") - set(TF_LIB_NAME_SHORT "libtensorflow_cc.2.a") - set(TF_LIB_NAME_FULL "libtensorflow_cc.${TF_VERSION}.a") - endif() -else() - set(BAZEL_LIB_NAME libtensorflow_cc.so) - set(PLATFORM_SUFFIX linux) - set(STATIC_LINK_CMD sh static_link.sh) - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(TF_LIB_NAME "libtensorflow_cc.so") - set(TF_LIB_NAME_SHORT "libtensorflow_cc.so.2") - set(TF_LIB_NAME_FULL "libtensorflow_cc.so.${TF_VERSION}") - set(TF_FRAMEWORK_NAME "libtensorflow_framework.so") - set(TF_FRAMEWORK_NAME_SHORT "libtensorflow_framework.so.2") - set(TF_FRAMEWORK_NAME_FULL "libtensorflow_framework.so.${TF_VERSION}") - else() - set(TF_LIB_NAME "libtensorflow_cc.a") - set(TF_LIB_NAME_SHORT "libtensorflow_cc.a.2") - set(TF_LIB_NAME_FULL "libtensorflow_cc.a.${TF_VERSION}") - endif() -endif() - -foreach(BUILD_TYPE dbg rel) - # prefer repeated source extraction here for each build type over extracting once above the loop and copying because users reported issues with copying symlinks - set(STATIC_ONLY_PATCHES) - set(LINUX_ONLY_PATCHES) - if(VCPKG_LIBRARY_LINKAGE STREQUAL static) - set(STATIC_ONLY_PATCHES change-macros-for-static-lib.patch) # there is no static build option - change macros via patch and link library manually at the end - endif() - if(VCPKG_TARGET_IS_LINUX) - set(LINUX_ONLY_PATCHES fix-linux-build.patch) - endif() - vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO tensorflow/tensorflow - REF "v${TF_VERSION}" - SHA512 e497ef4564f50abf9f918be4522cf702f4cf945cb1ebf83af1386ac4ddc7373b3ba70c7f803f8ca06faf2c6b5396e60b1e0e9b97bfbd667e733b08b6e6d70ef0 - HEAD_REF master - PATCHES - fix-build-error.patch # Fix namespace error - fix-dbg-build-errors.patch # Fix no return statement - fix-more-build-errors.patch # Fix no return statement - ${STATIC_ONLY_PATCHES} - ${LINUX_ONLY_PATCHES} - ) - - message(STATUS "Configuring TensorFlow (${BUILD_TYPE})") - tensorflow_try_remove_recurse_wait(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}) - file(RENAME ${SOURCE_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}) - set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}") - - vcpkg_execute_required_process( - COMMAND ${PYTHON3} ${SOURCE_PATH}/configure.py --workspace "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}" - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME config-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - - if(DEFINED ENV{BAZEL_CUSTOM_CACERTS}) - file(APPEND ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/.bazelrc "startup --host_jvm_args=-Djavax.net.ssl.trustStore='$ENV{BAZEL_CUSTOM_CACERTS}'\n") - message(STATUS "Using custom CA certificate store at: $ENV{BAZEL_CUSTOM_CACERTS}") - if(DEFINED ENV{BAZEL_CUSTOM_CACERTS_PASSWORD}) - file(APPEND ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/.bazelrc "startup --host_jvm_args=-Djavax.net.ssl.trustStorePassword='$ENV{BAZEL_CUSTOM_CACERTS_PASSWORD}'\n") - message(STATUS "Using supplied custom CA certificate store password.") - endif() - else() - if(DEFINED ENV{HTTPS_PROXY}) - message(STATUS "You are using HTTPS_PROXY. In case you encounter bazel certificate errors, you might want to set: BAZEL_CUSTOM_CACERTS=/path/to/trust.store (and optionally BAZEL_CUSTOM_CACERTS_PASSWORD), and to enable vcpkg to actually use it: VCPKG_KEEP_ENV_VARS=BAZEL_CUSTOM_CACERTS;BAZEL_CUSTOM_CACERTS_PASSWORD") - if(CMAKE_HOST_WIN32) - message(STATUS "(For BAZEL_CUSTOM_CACERTS please use forward slashes instead of backslashes on Windows systems.") - endif() - endif() - endif() - - message(STATUS "Warning: Building TensorFlow can take an hour or more.") - set(COPTS) - set(CXXOPTS) - set(LINKOPTS) - if(VCPKG_TARGET_IS_WINDOWS) - set(PLATFORM_COMMAND WINDOWS_COMMAND) - else() - set(PLATFORM_COMMAND UNIX_COMMAND) - endif() - if(BUILD_TYPE STREQUAL dbg) - if(VCPKG_TARGET_IS_WINDOWS) - set(BUILD_OPTS "--compilation_mode=dbg --features=fastbuild") # link with /DEBUG:FASTLINK instead of /DEBUG:FULL to avoid .pdb >4GB error - else() - set(BUILD_OPTS "--compilation_mode=dbg") - endif() - - separate_arguments(VCPKG_C_FLAGS ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS}) - separate_arguments(VCPKG_C_FLAGS_DEBUG ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS_DEBUG}) - foreach(OPT IN LISTS VCPKG_C_FLAGS VCPKG_C_FLAGS_DEBUG) - list(APPEND COPTS "--copt='${OPT}'") - endforeach() - separate_arguments(VCPKG_CXX_FLAGS ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS}) - separate_arguments(VCPKG_CXX_FLAGS_DEBUG ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS_DEBUG}) - foreach(OPT IN LISTS VCPKG_CXX_FLAGS VCPKG_CXX_FLAGS_DEBUG) - list(APPEND CXXOPTS "--cxxopt='${OPT}'") - endforeach() - separate_arguments(VCPKG_LINKER_FLAGS ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS}) - separate_arguments(VCPKG_LINKER_FLAGS_DEBUG ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS_DEBUG}) - foreach(OPT IN LISTS VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_DEBUG) - list(APPEND LINKOPTS "--linkopt='${OPT}'") - endforeach() - else() - set(BUILD_OPTS "--compilation_mode=opt") - - separate_arguments(VCPKG_C_FLAGS ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS}) - separate_arguments(VCPKG_C_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS_RELEASE}) - foreach(OPT IN LISTS VCPKG_C_FLAGS VCPKG_C_FLAGS_RELEASE) - list(APPEND COPTS "--copt='${OPT}'") - endforeach() - separate_arguments(VCPKG_CXX_FLAGS ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS}) - separate_arguments(VCPKG_CXX_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS_RELEASE}) - foreach(OPT IN LISTS VCPKG_CXX_FLAGS VCPKG_CXX_FLAGS_RELEASE) - list(APPEND CXXOPTS "--cxxopt='${OPT}'") - endforeach() - separate_arguments(VCPKG_LINKER_FLAGS ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS}) - separate_arguments(VCPKG_LINKER_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS_RELEASE}) - foreach(OPT IN LISTS VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE) - list(APPEND LINKOPTS "--linkopt='${OPT}'") - endforeach() - endif() - - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - if(VCPKG_TARGET_IS_WINDOWS) - list(JOIN COPTS " " COPTS) - list(JOIN CXXOPTS " " CXXOPTS) - list(JOIN LINKOPTS " " LINKOPTS) - vcpkg_execute_build_process( - COMMAND ${BASH} --noprofile --norc -c "'${BAZEL}' build --verbose_failures ${BUILD_OPTS} ${COPTS} ${CXXOPTS} ${LINKOPTS} --python_path='${PYTHON3}' --define=no_tensorflow_py_deps=true ///tensorflow:tensorflow_cc.dll ///tensorflow:install_headers" - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - else() - vcpkg_execute_build_process( - COMMAND ${BAZEL} build --verbose_failures ${BUILD_OPTS} --python_path=${PYTHON3} ${COPTS} ${CXXOPTS} ${LINKOPTS} --define=no_tensorflow_py_deps=true //tensorflow:${BAZEL_LIB_NAME} //tensorflow:install_headers - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - endif() - else() - if(VCPKG_TARGET_IS_WINDOWS) - if(VCPKG_CRT_LINKAGE STREQUAL static) - if(BUILD_TYPE STREQUAL dbg) - list(APPEND COPTS "--copt=-MTd") - else() - list(APPEND COPTS "--copt=-MT") - endif() - endif() - list(JOIN COPTS " " COPTS) - list(JOIN CXXOPTS " " CXXOPTS) - list(JOIN LINKOPTS " " LINKOPTS) - vcpkg_execute_build_process( - COMMAND ${BASH} --noprofile --norc -c "${BAZEL} build -s --verbose_failures ${BUILD_OPTS} --features=fully_static_link ${COPTS} ${CXXOPTS} ${LINKOPTS} --python_path='${PYTHON3}' --define=no_tensorflow_py_deps=true ///tensorflow:tensorflow_cc.dll ///tensorflow:install_headers" - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - else() - vcpkg_execute_build_process( - COMMAND ${BAZEL} build -s --verbose_failures ${BUILD_OPTS} ${COPTS} ${CXXOPTS} ${LINKOPTS} --python_path=${PYTHON3} --define=no_tensorflow_py_deps=true //tensorflow:${BAZEL_LIB_NAME} //tensorflow:install_headers - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - endif() - if(NOT VCPKG_TARGET_IS_OSX) - if(VCPKG_TARGET_IS_WINDOWS) - vcpkg_execute_build_process( - COMMAND ${PYTHON3} "${CMAKE_CURRENT_LIST_DIR}/convert_lib_params_${PLATFORM_SUFFIX}.py" - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow - LOGNAME postbuild1-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - else() - vcpkg_execute_build_process( - COMMAND ${PYTHON3} "${CMAKE_CURRENT_LIST_DIR}/convert_lib_params_${PLATFORM_SUFFIX}.py" "${TF_VERSION}" - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow - LOGNAME postbuild1-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - endif() - endif() - vcpkg_execute_build_process( - COMMAND ${PYTHON3} "${CMAKE_CURRENT_LIST_DIR}/generate_static_link_cmd_${PLATFORM_SUFFIX}.py" "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-${BUILD_TYPE}-err.log" # for some reason stdout of bazel ends up in stderr - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME postbuild2-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - vcpkg_execute_build_process( - COMMAND ${STATIC_LINK_CMD} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-${TARGET_TRIPLET}-${BUILD_TYPE} - LOGNAME postbuild3-${TARGET_TRIPLET}-${BUILD_TYPE} - ) - endif() - - if(BUILD_TYPE STREQUAL "dbg") - set(DIR_PREFIX "/debug") - else() - set(DIR_PREFIX "") - endif() - - if(VCPKG_TARGET_IS_WINDOWS) - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow_cc.dll DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/bin) - # rename before copy because after copy the file might be locked by anti-malware scanners for some time so that renaming fails - file(RENAME ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow_cc.dll.if.lib ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow_cc.lib) - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow_cc.lib DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib) - if(BUILD_TYPE STREQUAL dbg) - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow_cc.pdb DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/bin) - message(STATUS "Warning: debug information tensorflow_cc.pdb will be of limited use because only a reduced set could be produced due to the 4GB internal PDB file limit even on x64.") - endif() - else() - if(BUILD_TYPE STREQUAL dbg) - set(library_parts_variable TF_LIB_PARTS_DEBUG) - else() - set(library_parts_variable TF_LIB_PARTS_RELEASE) - endif() - set(${library_parts_variable}) - - # library might have been split because no more than 4GB are supported even on x64 Windows - foreach(PART_NO RANGE 1 100) - set(source "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow_cc-part${PART_NO}.lib") - if(EXISTS "${source}") - file(COPY "${source}" DESTINATION "${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib") - list(APPEND ${library_parts_variable} "tensorflow_cc-part${PART_NO}.lib") - else() - break() - endif() - endforeach() - endif() - else() - file(COPY - ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/${TF_LIB_NAME_FULL} - DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib - ) - - # Note: these use relative links - file(CREATE_LINK ${TF_LIB_NAME_FULL} - ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_LIB_NAME_SHORT} - SYMBOLIC - ) - file(CREATE_LINK ${TF_LIB_NAME_FULL} - ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_LIB_NAME} - SYMBOLIC - ) - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - file(COPY - ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/${TF_FRAMEWORK_NAME_FULL} - DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib - ) - file(CREATE_LINK - ${TF_FRAMEWORK_NAME_FULL} - ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_FRAMEWORK_NAME_SHORT} - SYMBOLIC - ) - file(CREATE_LINK - ${TF_FRAMEWORK_NAME_FULL} - ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_FRAMEWORK_NAME} - SYMBOLIC - ) - endif() - endif() -endforeach() - -file(COPY - ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/ - DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow-external -) - -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) - message(STATUS "Warning: Static TensorFlow build contains several external dependencies that may cause linking conflicts (for example, one cannot use both openssl and TensorFlow in the same project, since TensorFlow contains boringssl).") - if(VCPKG_TARGET_IS_WINDOWS) - message(STATUS "Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library, i.e., link using options '/WHOLEARCHIVE:tensorflow_cc-part1.lib /WHOLEARCHIVE:tensorflow_cc-part2.lib ...'") - else() - message(STATUS "Note: There is no separate libtensorflow_framework.a as it got merged into libtensorflow_cc.a to avoid linking conflicts.") - if(VCPKG_TARGET_IS_OSX) - message(STATUS "Note: Beside TensorFlow itself, you'll need to also pass its dependancies to the linker, for example '-ltensorflow_cc -framework CoreFoundation'") - message(STATUS "Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library: '-Wl,-force_load,path/to/libtensorflow_cc.a -framework CoreFoundation -framework Security [rest of linker arguments]'") - else() - message(STATUS "Note: Beside TensorFlow itself, you'll need to also pass its dependancies to the linker, for example '-ltensorflow_cc -lm -ldl -lpthread'") - message(STATUS "Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library: '-Wl,--whole-archive -ltensorflow_cc -Wl,--no-whole-archive [rest of linker arguments]'") - endif() - endif() - - configure_file( - ${CMAKE_CURRENT_LIST_DIR}/README-${PLATFORM_SUFFIX} - ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/README - COPYONLY) -endif() - -file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc) -file(RENAME ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/LICENSE ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/copyright) - - -# NOTE: if this port ever supports VCPKG_BUILD_TYPE, use that to set these. -set(TENSORFLOW_HAS_RELEASE ON) -set(TENSORFLOW_HAS_DEBUG ON) - -if(VCPKG_TARGET_IS_WINDOWS) - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - configure_file( - ${CMAKE_CURRENT_LIST_DIR}/tensorflow-cc-config-windows-dll.cmake.in - ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/tensorflow-cc-config.cmake - @ONLY) - else() - configure_file( - ${CMAKE_CURRENT_LIST_DIR}/tensorflow-cc-config-windows-lib.cmake.in - ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/tensorflow-cc-config.cmake - @ONLY) - - set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled) - - set(prefix [[${TENSORFLOW_INSTALL_PREFIX}]]) - - set(libs_to_link) - foreach(lib IN LISTS TF_LIB_PARTS_RELEASE) - list(APPEND libs_to_link "$<$:${prefix}/lib/${lib}>") - endforeach() - foreach(lib IN LISTS TF_LIB_PARTS_DEBUG) - list(APPEND libs_to_link "$<$:${prefix}/debug/lib/${lib}>") - endforeach() - if(TENSORFLOW_HAS_RELEASE) - set(TF_LIB_PARTS_DEFAULT ${TF_LIB_PARTS_RELEASE}) - set(prefix_DEFAULT "${prefix}") - elseif(TENSORFLOW_HAS_DEBUG) - set(TF_LIB_PARTS_DEFAULT ${TF_LIB_PARTS_DEBUG}) - set(prefix_DEFAULT "${prefix}/debug") - endif() - - foreach(lib IN LISTS TF_LIB_PARTS_DEFAULT) - list(APPEND libs_to_link - "$<$,$>>:${prefix}/lib/${lib}>") - endforeach() - - string(REPLACE ";" "\n\t\t" libs_to_link "${libs_to_link}") - file(APPEND ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/tensorflow-cc-config.cmake " -target_link_libraries(tensorflow_cc::tensorflow_cc - INTERFACE - ${libs_to_link} -)" - ) - endif() -else() - if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - configure_file( - ${CMAKE_CURRENT_LIST_DIR}/tensorflow-cc-config-shared.cmake.in - ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/tensorflow-cc-config.cmake - @ONLY) - else() - configure_file( - ${CMAKE_CURRENT_LIST_DIR}/tensorflow-cc-config-static.cmake.in - ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/tensorflow-cc-config.cmake - @ONLY) - endif() -endif() - -message(STATUS "You may want to delete ${CURRENT_BUILDTREES_DIR} and ${BUILDTREES_DIR}/.bzl to free diskspace.") +set(TF_LIB_SUFFIX "_cc") +set(TF_PORT_SUFFIX "-cc") +set(TF_INCLUDE_DIRS "${INSTALL_PREFIX}/${TARGET_TRIPLET}/include/tensorflow-external + ${INSTALL_PREFIX}/${TARGET_TRIPLET}/include/tensorflow-external/src") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tensorflow-common") +include(tensorflow-common) + +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/ DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow-external) diff --git a/ports/tensorflow-cc/tensorflow-cc-config-windows-dll.cmake.in b/ports/tensorflow-cc/tensorflow-cc-config-windows-dll.cmake.in deleted file mode 100644 index ed67e5ad407fae..00000000000000 --- a/ports/tensorflow-cc/tensorflow-cc-config-windows-dll.cmake.in +++ /dev/null @@ -1,56 +0,0 @@ -if(TARGET tensorflow_cc::tensorflow_cc) - return() -endif() - -add_library(tensorflow_cc::tensorflow_cc SHARED IMPORTED GLOBAL) - -# Compute the installation prefix from this tensorflow-cc-config.cmake file location. -# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow-cc -get_filename_component(TENSORFLOW_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) -# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet]/share -get_filename_component(TENSORFLOW_INSTALL_PREFIX "${TENSORFLOW_INSTALL_PREFIX}" DIRECTORY) -# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet] - -target_include_directories(tensorflow_cc::tensorflow_cc - INTERFACE - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external" - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external/src" -) - -if(@TENSORFLOW_HAS_RELEASE@) - set_target_properties(tensorflow_cc::tensorflow_cc - PROPERTIES - IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/bin/tensorflow_cc.dll" - IMPORTED_IMPLIB "${TENSORFLOW_INSTALL_PREFIX}/lib/tensorflow_cc.lib" - ) - - set_property(TARGET tensorflow_cc::tensorflow_cc - APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE - ) - set_target_properties(tensorflow_cc::tensorflow_cc - PROPERTIES - IMPORTED_LOCATION_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/bin/tensorflow_cc.dll" - IMPORTED_IMPLIB_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/lib/tensorflow_cc.lib" - ) -endif() - -if(@TENSORFLOW_HAS_DEBUG@) - if(NOT @TENSORFLOW_HAS_RELEASE@) - set_target_properties(tensorflow_cc::tensorflow_cc - PROPERTIES - IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/debug/bin/tensorflow_cc.dll" - IMPORTED_IMPLIB "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/tensorflow_cc.lib" - ) - endif() - - set_property(TARGET tensorflow_cc::tensorflow_cc - APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG - ) - set_target_properties(tensorflow_cc::tensorflow_cc - PROPERTIES - IMPORTED_LOCATION_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/bin/tensorflow_cc.dll" - IMPORTED_IMPLIB_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/tensorflow_cc.lib" - ) -endif() - -set(tensorflow_cc_FOUND TRUE) diff --git a/ports/tensorflow-cc/tensorflow-cc-config-windows-lib.cmake.in b/ports/tensorflow-cc/tensorflow-cc-config-windows-lib.cmake.in deleted file mode 100644 index 0eab84c7f025a9..00000000000000 --- a/ports/tensorflow-cc/tensorflow-cc-config-windows-lib.cmake.in +++ /dev/null @@ -1,19 +0,0 @@ -if(TARGET tensorflow_cc::tensorflow_cc) - return() -endif() - -set(tensorflow_cc_FOUND TRUE) - -# Compute the installation prefix from this tensorflow-cc-config.cmake file location. -# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow-cc -get_filename_component(TENSORFLOW_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) -# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet]/share -get_filename_component(TENSORFLOW_INSTALL_PREFIX "${TENSORFLOW_INSTALL_PREFIX}" DIRECTORY) -# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet] - -add_library(tensorflow_cc::tensorflow_cc INTERFACE IMPORTED GLOBAL) -target_include_directories(tensorflow_cc::tensorflow_cc - INTERFACE - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external" - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external/src" -) diff --git a/ports/tensorflow-common/CONTROL b/ports/tensorflow-common/CONTROL new file mode 100644 index 00000000000000..a5f0364afd17eb --- /dev/null +++ b/ports/tensorflow-common/CONTROL @@ -0,0 +1,6 @@ +Source: tensorflow-common +Version: 2.3.1 +Port-Version: 0 +Homepage: https://github.com/tensorflow/tensorflow +Description: This meta package holds common files for the C [tensorflow] and the C++ [tensorflow-cc] API version of TensorFlow but is not installable on its own. +Supports: false diff --git a/ports/tensorflow-cc/README-linux b/ports/tensorflow-common/README-linux similarity index 100% rename from ports/tensorflow-cc/README-linux rename to ports/tensorflow-common/README-linux diff --git a/ports/tensorflow-cc/README-macos b/ports/tensorflow-common/README-macos similarity index 100% rename from ports/tensorflow-cc/README-macos rename to ports/tensorflow-common/README-macos diff --git a/ports/tensorflow-cc/README-windows b/ports/tensorflow-common/README-windows similarity index 100% rename from ports/tensorflow-cc/README-windows rename to ports/tensorflow-common/README-windows diff --git a/ports/tensorflow-cc/change-macros-for-static-lib.patch b/ports/tensorflow-common/change-macros-for-static-lib.patch similarity index 100% rename from ports/tensorflow-cc/change-macros-for-static-lib.patch rename to ports/tensorflow-common/change-macros-for-static-lib.patch diff --git a/ports/tensorflow-cc/convert_lib_params_linux.py b/ports/tensorflow-common/convert_lib_params_linux.py similarity index 77% rename from ports/tensorflow-cc/convert_lib_params_linux.py rename to ports/tensorflow-common/convert_lib_params_linux.py index ba2c352701c36f..b24d45d634f3aa 100644 --- a/ports/tensorflow-cc/convert_lib_params_linux.py +++ b/ports/tensorflow-common/convert_lib_params_linux.py @@ -1,8 +1,9 @@ import sys version = sys.argv[1] +lib_suffix = "" if len(sys.argv) < 3 else sys.argv[2] -with open(f"libtensorflow_cc.a.{version}-2.params", "w") as f_out: +with open(f"libtensorflow{lib_suffix}.a.{version}-2.params", "w") as f_out: parts = [] with open(f"libtensorflow_framework.so.{version}-2.params", "r") as f_in: skip_next = False @@ -16,7 +17,7 @@ f_out.write(line) parts.append(line) parts = set(parts) - with open(f"libtensorflow_cc.so.{version}-2.params", "r") as f_in: + with open(f"libtensorflow{lib_suffix}.so.{version}-2.params", "r") as f_in: skip_next = False for line in f_in: if skip_next: diff --git a/ports/tensorflow-cc/convert_lib_params_windows.py b/ports/tensorflow-common/convert_lib_params_windows.py similarity index 72% rename from ports/tensorflow-cc/convert_lib_params_windows.py rename to ports/tensorflow-common/convert_lib_params_windows.py index 5fc2fdd68363cb..e150b4e5be525a 100644 --- a/ports/tensorflow-cc/convert_lib_params_windows.py +++ b/ports/tensorflow-common/convert_lib_params_windows.py @@ -1,11 +1,13 @@ import os import sys +lib_suffix = "" if len(sys.argv) < 2 else sys.argv[1] + file_no = 1 -with open("tensorflow_cc.dll-2.params", "r") as f_in: +with open(f"tensorflow{lib_suffix}.dll-2.params", "r") as f_in: lib_name = None acc_size = 0 - f_out = open("tensorflow_cc.lib-2.params-part1", "w") + f_out = open(f"tensorflow{lib_suffix}.lib-2.params-part1", "w") for line in f_in: if line.startswith("/OUT:"): lib_name = line @@ -18,10 +20,9 @@ # we need to split the library if it is >4GB, because it's not supported even on x64 Windows f_out.close() file_no += 1 - f_out = open(f"tensorflow_cc.lib-2.params-part{file_no}", "w") + f_out = open(f"tensorflow{lib_suffix}.lib-2.params-part{file_no}", "w") acc_size = 0 f_out.write(lib_name.replace(".dll", f"-part{file_no}.lib")) acc_size += size f_out.write(line) f_out.close() - diff --git a/ports/tensorflow-cc/fix-build-error.patch b/ports/tensorflow-common/fix-build-error.patch similarity index 100% rename from ports/tensorflow-cc/fix-build-error.patch rename to ports/tensorflow-common/fix-build-error.patch diff --git a/ports/tensorflow-cc/fix-dbg-build-errors.patch b/ports/tensorflow-common/fix-dbg-build-errors.patch similarity index 100% rename from ports/tensorflow-cc/fix-dbg-build-errors.patch rename to ports/tensorflow-common/fix-dbg-build-errors.patch diff --git a/ports/tensorflow-cc/fix-linux-build.patch b/ports/tensorflow-common/fix-linux-build.patch similarity index 75% rename from ports/tensorflow-cc/fix-linux-build.patch rename to ports/tensorflow-common/fix-linux-build.patch index 81a6a3be8c63fb..224f28fe339a9e 100644 --- a/ports/tensorflow-cc/fix-linux-build.patch +++ b/ports/tensorflow-common/fix-linux-build.patch @@ -62,3 +62,16 @@ diff --git a/tensorflow/core/kernels/data/experimental/snapshot_dataset_op.cc b/ // ==== Snapshot Implementation ==== /* The current snapshot on-disk layout is as follows: + +diff --git a/tensorflow/core/kernels/data/experimental/data_service_dataset_op.cc b/tensorflow/core/kernels/data/experimental/data_service_dataset_op.cc +--- a/tensorflow/core/kernels/data/experimental/data_service_dataset_op.cc ++++ b/tensorflow/core/kernels/data/experimental/data_service_dataset_op.cc +@@ -52,6 +52,8 @@ + /* static */ constexpr const char* const + DataServiceDatasetOp::kMaxOutstandingRequests; + /* static */ constexpr const char* const ++ DataServiceDatasetOp::kTaskRefreshIntervalHintMs; ++/* static */ constexpr const char* const + DataServiceDatasetOp::kIterationCounter; + /* static */ constexpr const char* const DataServiceDatasetOp::kOutputTypes; + /* static */ constexpr const char* const DataServiceDatasetOp::kOutputShapes; diff --git a/ports/tensorflow-cc/fix-more-build-errors.patch b/ports/tensorflow-common/fix-more-build-errors.patch similarity index 100% rename from ports/tensorflow-cc/fix-more-build-errors.patch rename to ports/tensorflow-common/fix-more-build-errors.patch diff --git a/ports/tensorflow-cc/generate_static_link_cmd_linux.py b/ports/tensorflow-common/generate_static_link_cmd_linux.py similarity index 80% rename from ports/tensorflow-cc/generate_static_link_cmd_linux.py rename to ports/tensorflow-common/generate_static_link_cmd_linux.py index 3b7c04f49c8747..34c8db13400919 100644 --- a/ports/tensorflow-cc/generate_static_link_cmd_linux.py +++ b/ports/tensorflow-common/generate_static_link_cmd_linux.py @@ -1,10 +1,11 @@ import re import sys +lib_suffix = "" if len(sys.argv) < 3 else sys.argv[2] with open(sys.argv[1], "r") as f_in: with open("static_link.sh", "w") as f_out: p_cd = re.compile("^\\((cd .*) && \\\\$") - p_linker = re.compile("^\\s*(.+)gcc.+(@bazel-out\\S+libtensorflow_cc\\.so\\.\\d\\.\\d\\.\\d-2\\.params).*") + p_linker = re.compile(fr"^\s*(.+)gcc.+(@bazel-out\S+libtensorflow{lib_suffix}\.so\.\d\.\d\.\d-2\.params).*") f_out.write("#!/bin/bash\n# note: ar/binutils version 2.27 required to support output files > 4GB\n") env = [] for line in f_in: diff --git a/ports/tensorflow-cc/generate_static_link_cmd_macos.py b/ports/tensorflow-common/generate_static_link_cmd_macos.py similarity index 87% rename from ports/tensorflow-cc/generate_static_link_cmd_macos.py rename to ports/tensorflow-common/generate_static_link_cmd_macos.py index f1dfbbc466fcc7..bb8f6faa21f43a 100644 --- a/ports/tensorflow-cc/generate_static_link_cmd_macos.py +++ b/ports/tensorflow-common/generate_static_link_cmd_macos.py @@ -1,10 +1,11 @@ import re import sys +lib_suffix = "" if len(sys.argv) < 3 else sys.argv[2] with open(sys.argv[1], "r") as f_in: with open("static_link.sh", "w") as f_out: p_cd = re.compile("^\\((cd .*) && \\\\$") - p_linker1 = re.compile("^.*cc_wrapper.sh.+-shared.+-o (bazel-out\\S+libtensorflow_cc\\.\\d\\.\\d\\.\\d\\.dylib)") + p_linker1 = re.compile(fr"^.*cc_wrapper.sh.+-shared.+-o (bazel-out\S+libtensorflow{lib_suffix}\.\d\.\d\.\d\.dylib)") p_linker2 = re.compile("^.*cc_wrapper.sh.+-shared.+-o (bazel-out\\S+libtensorflow_framework\\.\\d\\.\\d\\.\\d\\.dylib)") f_out.write("#!/bin/bash\n# note: ar/binutils version 2.27 required to support output files > 4GB\n") env = [] @@ -39,7 +40,7 @@ tmp = [t[16:] for t in tokens if t.startswith("-Wl,-force_load,")] old = set(parts) parts += [t for t in tmp if t not in old] - line = f"libtool -static -o {m2.group(1).replace('_framework', '_cc').replace('.dylib', '.a')} {' '.join(parts)}\n" + line = f"libtool -static -o {m2.group(1).replace('_framework', lib_suffix).replace('.dylib', '.a')} {' '.join(parts)}\n" f_out.write(line) break else: diff --git a/ports/tensorflow-cc/generate_static_link_cmd_windows.py b/ports/tensorflow-common/generate_static_link_cmd_windows.py similarity index 86% rename from ports/tensorflow-cc/generate_static_link_cmd_windows.py rename to ports/tensorflow-common/generate_static_link_cmd_windows.py index 363b3ad884f7f5..780334ad98ab83 100644 --- a/ports/tensorflow-cc/generate_static_link_cmd_windows.py +++ b/ports/tensorflow-common/generate_static_link_cmd_windows.py @@ -2,10 +2,11 @@ import re import sys +lib_suffix = "" if len(sys.argv) < 3 else sys.argv[2] with open(sys.argv[1], "r") as f_in: with open("static_link.bat", "w") as f_out: p_setenv = re.compile("^\s*(SET .+=.*)$") - p_linker = re.compile(".+link\\.exe.+tensorflow_cc\\.dll-2\\.params.*") + p_linker = re.compile(fr".+link\.exe.+tensorflow{lib_suffix}\.dll-2\.params.*") env = [] for line in f_in: if line.startswith("cd"): @@ -28,7 +29,7 @@ t = t[:-len("link.exe")] + "lib.exe\"" elif t == "/DLL" or t.lower()[1:].startswith("defaultlib:") or t.lower()[1:].startswith("ignore") or t.startswith("/OPT:") or t.startswith("/DEF:") or t.startswith("/DEBUG:") or t.startswith("/INCREMENTAL:"): continue - elif t[0] == '@' and t.endswith("tensorflow_cc.dll-2.params"): + elif t[0] == '@' and t.endswith(f"tensorflow{lib_suffix}.dll-2.params"): t = t[:-len("dll-2.params")] + "lib-2.params-part1" params_file = t[1:-len("-part1")] line += t + " " diff --git a/ports/tensorflow-common/portfile.cmake b/ports/tensorflow-common/portfile.cmake new file mode 100644 index 00000000000000..4d51544d829d29 --- /dev/null +++ b/ports/tensorflow-common/portfile.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This meta package holds common files for the C [tensorflow] and the C++ [tensorflow-cc] API version of TensorFlow but is not installable on its own.") diff --git a/ports/tensorflow-common/tensorflow-common.cmake b/ports/tensorflow-common/tensorflow-common.cmake new file mode 100644 index 00000000000000..1f9a7203c59f20 --- /dev/null +++ b/ports/tensorflow-common/tensorflow-common.cmake @@ -0,0 +1,439 @@ +set(TF_VERSION 2.3.1) +set(TF_VERSION_SHORT 2.3) + +vcpkg_find_acquire_program(BAZEL) +get_filename_component(BAZEL_DIR "${BAZEL}" DIRECTORY) +vcpkg_add_to_path(PREPEND ${BAZEL_DIR}) +set(ENV{BAZEL_BIN_PATH} "${BAZEL}") + +function(tensorflow_try_remove_recurse_wait PATH_TO_REMOVE) + file(REMOVE_RECURSE ${PATH_TO_REMOVE}) + if(EXISTS "${PATH_TO_REMOVE}") + vcpkg_execute_required_process(COMMAND ${CMAKE_COMMAND} -E sleep 5 WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-sleep-${TARGET_TRIPLET}) + file(REMOVE_RECURSE ${PATH_TO_REMOVE}) + endif() +endfunction() + +vcpkg_find_acquire_program(GIT) +get_filename_component(GIT_DIR "${GIT}" DIRECTORY) +vcpkg_add_to_path(PREPEND ${GIT_DIR}) + +if(CMAKE_HOST_WIN32) + vcpkg_acquire_msys(MSYS_ROOT PACKAGES bash unzip patch diffutils libintl gzip coreutils mingw-w64-x86_64-python-numpy) + vcpkg_add_to_path(${MSYS_ROOT}/usr/bin) + vcpkg_add_to_path(${MSYS_ROOT}/mingw64/bin) + set(BASH ${MSYS_ROOT}/usr/bin/bash.exe) + + set(ENV{BAZEL_SH} ${MSYS_ROOT}/usr/bin/bash.exe) + set(ENV{BAZEL_VC} $ENV{VCInstallDir}) + set(ENV{BAZEL_VC_FULL_VERSION} $ENV{VCToolsVersion}) + + set(PYTHON3 "${MSYS_ROOT}/mingw64/bin/python3.exe") + vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import site; print(site.getsitepackages()[0])" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pypath-${TARGET_TRIPLET} OUTPUT_VARIABLE PYTHON_LIB_PATH) +else() + vcpkg_find_acquire_program(PYTHON3) + get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) + vcpkg_add_to_path(PREPEND ${PYTHON3_DIR}) + + vcpkg_execute_required_process(COMMAND ${PYTHON3} -m pip install --user -U numpy WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pip-${TARGET_TRIPLET}) + vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import site; print(site.getusersitepackages())" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pypath-${TARGET_TRIPLET} OUTPUT_VARIABLE PYTHON_LIB_PATH) +endif() +set(ENV{PYTHON_BIN_PATH} "${PYTHON3}") +set(ENV{PYTHON_LIB_PATH} "${PYTHON_LIB_PATH}") + +# check if numpy can be loaded +vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import numpy" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-numpy-${TARGET_TRIPLET}) + +# tensorflow has long file names, which will not work on windows +set(ENV{TEST_TMPDIR} ${BUILDTREES_DIR}/.bzl) + +set(ENV{USE_DEFAULT_PYTHON_LIB_PATH} 1) +set(ENV{TF_NEED_KAFKA} 0) +set(ENV{TF_NEED_OPENCL_SYCL} 0) +set(ENV{TF_NEED_AWS} 0) +set(ENV{TF_NEED_GCP} 0) +set(ENV{TF_NEED_HDFS} 0) +set(ENV{TF_NEED_S3} 0) +set(ENV{TF_ENABLE_XLA} 0) +set(ENV{TF_NEED_GDR} 0) +set(ENV{TF_NEED_VERBS} 0) +set(ENV{TF_NEED_OPENCL} 0) +set(ENV{TF_NEED_MPI} 0) +set(ENV{TF_NEED_TENSORRT} 0) +set(ENV{TF_NEED_NGRAPH} 0) +set(ENV{TF_NEED_IGNITE} 0) +set(ENV{TF_NEED_ROCM} 0) +set(ENV{TF_SET_ANDROID_WORKSPACE} 0) +set(ENV{TF_DOWNLOAD_CLANG} 0) +set(ENV{TF_NCCL_VERSION} ${TF_VERSION_SHORT}) +set(ENV{NCCL_INSTALL_PATH} "") +set(ENV{CC_OPT_FLAGS} "/arch:AVX") +set(ENV{TF_NEED_CUDA} 0) +set(ENV{TF_CONFIGURE_IOS} 0) + +if(VCPKG_TARGET_IS_WINDOWS) + set(BAZEL_LIB_NAME tensorflow${TF_LIB_SUFFIX}.dll) + set(PLATFORM_SUFFIX windows) + set(STATIC_LINK_CMD static_link.bat) +elseif(VCPKG_TARGET_IS_OSX) + set(BAZEL_LIB_NAME libtensorflow${TF_LIB_SUFFIX}.dylib) + set(PLATFORM_SUFFIX macos) + set(STATIC_LINK_CMD sh static_link.sh) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + set(TF_LIB_NAME "libtensorflow${TF_LIB_SUFFIX}.dylib") + set(TF_LIB_NAME_SHORT "libtensorflow${TF_LIB_SUFFIX}.2.dylib") + set(TF_LIB_NAME_FULL "libtensorflow${TF_LIB_SUFFIX}.${TF_VERSION}.dylib") + set(TF_FRAMEWORK_NAME "libtensorflow_framework.dylib") + set(TF_FRAMEWORK_NAME_SHORT "libtensorflow_framework.2.dylib") + set(TF_FRAMEWORK_NAME_FULL "libtensorflow_framework.${TF_VERSION}.dylib") + else() + set(TF_LIB_NAME "libtensorflow${TF_LIB_SUFFIX}.a") + set(TF_LIB_NAME_SHORT "libtensorflow${TF_LIB_SUFFIX}.2.a") + set(TF_LIB_NAME_FULL "libtensorflow${TF_LIB_SUFFIX}.${TF_VERSION}.a") + endif() +else() + set(BAZEL_LIB_NAME libtensorflow${TF_LIB_SUFFIX}.so) + set(PLATFORM_SUFFIX linux) + set(STATIC_LINK_CMD sh static_link.sh) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + set(TF_LIB_NAME "libtensorflow${TF_LIB_SUFFIX}.so") + set(TF_LIB_NAME_SHORT "libtensorflow${TF_LIB_SUFFIX}.so.2") + set(TF_LIB_NAME_FULL "libtensorflow${TF_LIB_SUFFIX}.so.${TF_VERSION}") + set(TF_FRAMEWORK_NAME "libtensorflow_framework.so") + set(TF_FRAMEWORK_NAME_SHORT "libtensorflow_framework.so.2") + set(TF_FRAMEWORK_NAME_FULL "libtensorflow_framework.so.${TF_VERSION}") + else() + set(TF_LIB_NAME "libtensorflow${TF_LIB_SUFFIX}.a") + set(TF_LIB_NAME_SHORT "libtensorflow${TF_LIB_SUFFIX}.a.2") + set(TF_LIB_NAME_FULL "libtensorflow${TF_LIB_SUFFIX}.a.${TF_VERSION}") + endif() +endif() + +foreach(BUILD_TYPE dbg rel) + # prefer repeated source extraction here for each build type over extracting once above the loop and copying because users reported issues with copying symlinks + set(STATIC_ONLY_PATCHES) + set(LINUX_ONLY_PATCHES) + if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + set(STATIC_ONLY_PATCHES ../tensorflow-common/change-macros-for-static-lib.patch) # there is no static build option - change macros via patch and link library manually at the end + endif() + if(VCPKG_TARGET_IS_LINUX) + set(LINUX_ONLY_PATCHES ../tensorflow-common/fix-linux-build.patch) + endif() + vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO tensorflow/tensorflow + REF "v${TF_VERSION}" + SHA512 e497ef4564f50abf9f918be4522cf702f4cf945cb1ebf83af1386ac4ddc7373b3ba70c7f803f8ca06faf2c6b5396e60b1e0e9b97bfbd667e733b08b6e6d70ef0 + HEAD_REF master + PATCHES + ../tensorflow-common/fix-build-error.patch # Fix namespace error + ../tensorflow-common/fix-dbg-build-errors.patch # Fix no return statement + ../tensorflow-common/fix-more-build-errors.patch # Fix no return statement + ${STATIC_ONLY_PATCHES} + ${LINUX_ONLY_PATCHES} + ) + + message(STATUS "Configuring TensorFlow (${BUILD_TYPE})") + tensorflow_try_remove_recurse_wait(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}) + file(RENAME ${SOURCE_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}) + set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}") + + vcpkg_execute_required_process( + COMMAND ${PYTHON3} ${SOURCE_PATH}/configure.py --workspace "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}" + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME config-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + + if(DEFINED ENV{BAZEL_CUSTOM_CACERTS}) + file(APPEND ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/.bazelrc "startup --host_jvm_args=-Djavax.net.ssl.trustStore='$ENV{BAZEL_CUSTOM_CACERTS}'\n") + message(STATUS "Using custom CA certificate store at: $ENV{BAZEL_CUSTOM_CACERTS}") + if(DEFINED ENV{BAZEL_CUSTOM_CACERTS_PASSWORD}) + file(APPEND ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/.bazelrc "startup --host_jvm_args=-Djavax.net.ssl.trustStorePassword='$ENV{BAZEL_CUSTOM_CACERTS_PASSWORD}'\n") + message(STATUS "Using supplied custom CA certificate store password.") + endif() + else() + if(DEFINED ENV{HTTPS_PROXY}) + message(STATUS "You are using HTTPS_PROXY. In case you encounter bazel certificate errors, you might want to set: BAZEL_CUSTOM_CACERTS=/path/to/trust.store (and optionally BAZEL_CUSTOM_CACERTS_PASSWORD), and to enable vcpkg to actually use it: VCPKG_KEEP_ENV_VARS=BAZEL_CUSTOM_CACERTS;BAZEL_CUSTOM_CACERTS_PASSWORD") + if(CMAKE_HOST_WIN32) + message(STATUS "(For BAZEL_CUSTOM_CACERTS please use forward slashes instead of backslashes on Windows systems.") + endif() + endif() + endif() + + message(STATUS "Warning: Building TensorFlow can take an hour or more.") + set(COPTS) + set(CXXOPTS) + set(LINKOPTS) + if(VCPKG_TARGET_IS_WINDOWS) + set(PLATFORM_COMMAND WINDOWS_COMMAND) + else() + set(PLATFORM_COMMAND UNIX_COMMAND) + endif() + if(BUILD_TYPE STREQUAL dbg) + if(VCPKG_TARGET_IS_WINDOWS) + set(BUILD_OPTS "--compilation_mode=dbg --features=fastbuild") # link with /DEBUG:FASTLINK instead of /DEBUG:FULL to avoid .pdb >4GB error + else() + set(BUILD_OPTS "--compilation_mode=dbg") + endif() + + separate_arguments(VCPKG_C_FLAGS ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS}) + separate_arguments(VCPKG_C_FLAGS_DEBUG ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS_DEBUG}) + foreach(OPT IN LISTS VCPKG_C_FLAGS VCPKG_C_FLAGS_DEBUG) + list(APPEND COPTS "--copt='${OPT}'") + endforeach() + separate_arguments(VCPKG_CXX_FLAGS ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS}) + separate_arguments(VCPKG_CXX_FLAGS_DEBUG ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS_DEBUG}) + foreach(OPT IN LISTS VCPKG_CXX_FLAGS VCPKG_CXX_FLAGS_DEBUG) + list(APPEND CXXOPTS "--cxxopt='${OPT}'") + endforeach() + separate_arguments(VCPKG_LINKER_FLAGS ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS}) + separate_arguments(VCPKG_LINKER_FLAGS_DEBUG ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS_DEBUG}) + foreach(OPT IN LISTS VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_DEBUG) + list(APPEND LINKOPTS "--linkopt='${OPT}'") + endforeach() + else() + set(BUILD_OPTS "--compilation_mode=opt") + + separate_arguments(VCPKG_C_FLAGS ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS}) + separate_arguments(VCPKG_C_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS_RELEASE}) + foreach(OPT IN LISTS VCPKG_C_FLAGS VCPKG_C_FLAGS_RELEASE) + list(APPEND COPTS "--copt='${OPT}'") + endforeach() + separate_arguments(VCPKG_CXX_FLAGS ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS}) + separate_arguments(VCPKG_CXX_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_CXX_FLAGS_RELEASE}) + foreach(OPT IN LISTS VCPKG_CXX_FLAGS VCPKG_CXX_FLAGS_RELEASE) + list(APPEND CXXOPTS "--cxxopt='${OPT}'") + endforeach() + separate_arguments(VCPKG_LINKER_FLAGS ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS}) + separate_arguments(VCPKG_LINKER_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_LINKER_FLAGS_RELEASE}) + foreach(OPT IN LISTS VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE) + list(APPEND LINKOPTS "--linkopt='${OPT}'") + endforeach() + endif() + + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + if(VCPKG_TARGET_IS_WINDOWS) + list(JOIN COPTS " " COPTS) + list(JOIN CXXOPTS " " CXXOPTS) + list(JOIN LINKOPTS " " LINKOPTS) + vcpkg_execute_build_process( + COMMAND ${BASH} --noprofile --norc -c "'${BAZEL}' build --verbose_failures ${BUILD_OPTS} ${COPTS} ${CXXOPTS} ${LINKOPTS} --python_path='${PYTHON3}' --define=no_tensorflow_py_deps=true ///tensorflow:${BAZEL_LIB_NAME} ///tensorflow:install_headers" + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + else() + vcpkg_execute_build_process( + COMMAND ${BAZEL} build --verbose_failures ${BUILD_OPTS} --python_path=${PYTHON3} ${COPTS} ${CXXOPTS} ${LINKOPTS} --define=no_tensorflow_py_deps=true //tensorflow:${BAZEL_LIB_NAME} //tensorflow:install_headers + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + endif() + else() + if(VCPKG_TARGET_IS_WINDOWS) + if(VCPKG_CRT_LINKAGE STREQUAL static) + if(BUILD_TYPE STREQUAL dbg) + list(APPEND COPTS "--copt=-MTd") + else() + list(APPEND COPTS "--copt=-MT") + endif() + endif() + list(JOIN COPTS " " COPTS) + list(JOIN CXXOPTS " " CXXOPTS) + list(JOIN LINKOPTS " " LINKOPTS) + vcpkg_execute_build_process( + COMMAND ${BASH} --noprofile --norc -c "${BAZEL} build -s --verbose_failures ${BUILD_OPTS} --features=fully_static_link ${COPTS} ${CXXOPTS} ${LINKOPTS} --python_path='${PYTHON3}' --define=no_tensorflow_py_deps=true ///tensorflow:${BAZEL_LIB_NAME} ///tensorflow:install_headers" + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + else() + vcpkg_execute_build_process( + COMMAND ${BAZEL} build -s --verbose_failures ${BUILD_OPTS} ${COPTS} ${CXXOPTS} ${LINKOPTS} --python_path=${PYTHON3} --define=no_tensorflow_py_deps=true //tensorflow:${BAZEL_LIB_NAME} //tensorflow:install_headers + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME build-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + endif() + if(NOT VCPKG_TARGET_IS_OSX) + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_execute_build_process( + COMMAND ${PYTHON3} "${CMAKE_CURRENT_LIST_DIR}/convert_lib_params_${PLATFORM_SUFFIX}.py" ${TF_LIB_SUFFIX} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow + LOGNAME postbuild1-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + else() + vcpkg_execute_build_process( + COMMAND ${PYTHON3} "${CMAKE_CURRENT_LIST_DIR}/convert_lib_params_${PLATFORM_SUFFIX}.py" ${TF_VERSION} ${TF_LIB_SUFFIX} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow + LOGNAME postbuild1-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + endif() + endif() + # for some reason stdout of bazel ends up in stderr, so use err log file in the following command + vcpkg_execute_build_process( + COMMAND ${PYTHON3} "${CMAKE_CURRENT_LIST_DIR}/generate_static_link_cmd_${PLATFORM_SUFFIX}.py" "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-${BUILD_TYPE}-err.log" ${TF_LIB_SUFFIX} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME postbuild2-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + vcpkg_execute_build_process( + COMMAND ${STATIC_LINK_CMD} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-${TARGET_TRIPLET}-${BUILD_TYPE} + LOGNAME postbuild3-${TARGET_TRIPLET}-${BUILD_TYPE} + ) + endif() + + if(BUILD_TYPE STREQUAL "dbg") + set(DIR_PREFIX "/debug") + else() + set(DIR_PREFIX "") + endif() + + if(VCPKG_TARGET_IS_WINDOWS) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow${TF_LIB_SUFFIX}.dll DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/bin) + # rename before copy because after copy the file might be locked by anti-malware scanners for some time so that renaming fails + file(RENAME ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow${TF_LIB_SUFFIX}.dll.if.lib ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow${TF_LIB_SUFFIX}.lib) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow${TF_LIB_SUFFIX}.lib DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib) + if(BUILD_TYPE STREQUAL dbg) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow${TF_LIB_SUFFIX}.pdb DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/bin) + message(STATUS "Warning: debug information tensorflow${TF_LIB_SUFFIX}.pdb will be of limited use because only a reduced set could be produced due to the 4GB internal PDB file limit even on x64.") + endif() + else() + if(BUILD_TYPE STREQUAL dbg) + set(library_parts_variable TF_LIB_PARTS_DEBUG) + else() + set(library_parts_variable TF_LIB_PARTS_RELEASE) + endif() + set(${library_parts_variable}) + + # library might have been split because no more than 4GB are supported even on x64 Windows + foreach(PART_NO RANGE 1 100) + set(source "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/tensorflow${TF_LIB_SUFFIX}-part${PART_NO}.lib") + if(EXISTS "${source}") + file(COPY "${source}" DESTINATION "${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib") + list(APPEND ${library_parts_variable} "tensorflow${TF_LIB_SUFFIX}-part${PART_NO}.lib") + else() + break() + endif() + endforeach() + endif() + else() + file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/${TF_LIB_NAME_FULL} + DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib + ) + + # Note: these use relative links + file(CREATE_LINK ${TF_LIB_NAME_FULL} + ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_LIB_NAME_SHORT} + SYMBOLIC + ) + file(CREATE_LINK ${TF_LIB_NAME_FULL} + ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_LIB_NAME} + SYMBOLIC + ) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/bazel-bin/tensorflow/${TF_FRAMEWORK_NAME_FULL} + DESTINATION ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib + ) + file(CREATE_LINK + ${TF_FRAMEWORK_NAME_FULL} + ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_FRAMEWORK_NAME_SHORT} + SYMBOLIC + ) + file(CREATE_LINK + ${TF_FRAMEWORK_NAME_FULL} + ${CURRENT_PACKAGES_DIR}${DIR_PREFIX}/lib/${TF_FRAMEWORK_NAME} + SYMBOLIC + ) + endif() + endif() +endforeach() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + message(STATUS "Warning: Static TensorFlow build contains several external dependencies that may cause linking conflicts (for example, one cannot use both openssl and TensorFlow in the same project, since TensorFlow contains boringssl).") + if(VCPKG_TARGET_IS_WINDOWS) + message(STATUS "Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library, i.e., link using options '/WHOLEARCHIVE:tensorflow${TF_LIB_SUFFIX}-part1.lib /WHOLEARCHIVE:tensorflow${TF_LIB_SUFFIX}-part2.lib ...'") + else() + message(STATUS "Note: There is no separate libtensorflow_framework.a as it got merged into libtensorflow${TF_LIB_SUFFIX}.a to avoid linking conflicts.") + if(VCPKG_TARGET_IS_OSX) + message(STATUS "Note: Beside TensorFlow itself, you'll need to also pass its dependancies to the linker, for example '-ltensorflow${TF_LIB_SUFFIX} -framework CoreFoundation'") + message(STATUS "Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library: '-Wl,-force_load,path/to/libtensorflow${TF_LIB_SUFFIX}.a -framework CoreFoundation -framework Security [rest of linker arguments]'") + else() + message(STATUS "Note: Beside TensorFlow itself, you'll need to also pass its dependancies to the linker, for example '-ltensorflow${TF_LIB_SUFFIX} -lm -ldl -lpthread'") + message(STATUS "Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library: '-Wl,--whole-archive -ltensorflow${TF_LIB_SUFFIX} -Wl,--no-whole-archive [rest of linker arguments]'") + endif() + endif() + + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/README-${PLATFORM_SUFFIX} + ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/README + COPYONLY) +endif() + +file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/LICENSE ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/copyright) + + +# NOTE: if this port ever supports VCPKG_BUILD_TYPE, use that to set these. +set(TENSORFLOW_HAS_RELEASE ON) +set(TENSORFLOW_HAS_DEBUG ON) + +if(VCPKG_TARGET_IS_WINDOWS) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/tensorflow-config-windows-dll.cmake.in + ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/tensorflow${TF_PORT_SUFFIX}-config.cmake + @ONLY) + else() + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/tensorflow-config-windows-lib.cmake.in + ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/tensorflow${TF_PORT_SUFFIX}-config.cmake + @ONLY) + + set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled) + + set(prefix [[${TENSORFLOW_INSTALL_PREFIX}]]) + + set(libs_to_link) + foreach(lib IN LISTS TF_LIB_PARTS_RELEASE) + list(APPEND libs_to_link "$<$:${prefix}/lib/${lib}>") + endforeach() + foreach(lib IN LISTS TF_LIB_PARTS_DEBUG) + list(APPEND libs_to_link "$<$:${prefix}/debug/lib/${lib}>") + endforeach() + if(TENSORFLOW_HAS_RELEASE) + set(TF_LIB_PARTS_DEFAULT ${TF_LIB_PARTS_RELEASE}) + set(prefix_DEFAULT "${prefix}") + elseif(TENSORFLOW_HAS_DEBUG) + set(TF_LIB_PARTS_DEFAULT ${TF_LIB_PARTS_DEBUG}) + set(prefix_DEFAULT "${prefix}/debug") + endif() + + foreach(lib IN LISTS TF_LIB_PARTS_DEFAULT) + list(APPEND libs_to_link + "$<$,$>>:${prefix}/lib/${lib}>") + endforeach() + + string(REPLACE ";" "\n\t\t" libs_to_link "${libs_to_link}") + file(APPEND ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/tensorflow${TF_PORT_SUFFIX}-config.cmake " +target_link_libraries(tensorflow${TF_LIB_SUFFIX}::tensorflow${TF_LIB_SUFFIX} + INTERFACE + ${libs_to_link} +)" + ) + endif() +else() + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/tensorflow-config-shared.cmake.in + ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/tensorflow${TF_PORT_SUFFIX}-config.cmake + @ONLY) + else() + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/tensorflow-config-static.cmake.in + ${CURRENT_PACKAGES_DIR}/share/tensorflow${TF_PORT_SUFFIX}/tensorflow${TF_PORT_SUFFIX}-config.cmake + @ONLY) + endif() +endif() + +message(STATUS "You may want to delete ${CURRENT_BUILDTREES_DIR} and ${BUILDTREES_DIR}/.bzl to free diskspace.") diff --git a/ports/tensorflow-cc/tensorflow-cc-config-shared.cmake.in b/ports/tensorflow-common/tensorflow-config-shared.cmake.in similarity index 50% rename from ports/tensorflow-cc/tensorflow-cc-config-shared.cmake.in rename to ports/tensorflow-common/tensorflow-config-shared.cmake.in index 98149e0004805f..df4ad83b670979 100644 --- a/ports/tensorflow-cc/tensorflow-cc-config-shared.cmake.in +++ b/ports/tensorflow-common/tensorflow-config-shared.cmake.in @@ -1,55 +1,52 @@ -if(TARGET tensorflow_cc::tensorflow_cc OR TARGET tensorflow_cc::tensorflow_framework) - if(NOT (TARGET tensorflow_cc::tensorflow_cc AND TARGET tensorflow_cc::tensorflow_framework)) +if(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ OR TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework) + if(NOT (TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ AND TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework)) message(FATAL_ERROR "Some (but not all) targets in this config.cmake were already defined.") endif() return() endif() -add_library(tensorflow_cc::tensorflow_cc SHARED IMPORTED GLOBAL) -add_library(tensorflow_cc::tensorflow_framework SHARED IMPORTED GLOBAL) +add_library(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ SHARED IMPORTED GLOBAL) +add_library(tensorflow@TF_LIB_SUFFIX@::tensorflow_framework SHARED IMPORTED GLOBAL) -# Compute the installation prefix from this tensorflow-cc-config.cmake file location. -# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow-cc +# Compute the installation prefix from this tensorflow@TF_PORT_SUFFIX@-config.cmake file location. +# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow@TF_PORT_SUFFIX@ get_filename_component(TENSORFLOW_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) # TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet]/share get_filename_component(TENSORFLOW_INSTALL_PREFIX "${TENSORFLOW_INSTALL_PREFIX}" DIRECTORY) # TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet] -target_include_directories(tensorflow_cc::tensorflow_cc +target_include_directories(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ INTERFACE - "${TENSORFLOW_INSTALL_PREFIX}/include" - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external" - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external/src" + @TF_INCLUDE_DIRS@ ) -target_include_directories(tensorflow_cc::tensorflow_framework +target_include_directories(tensorflow@TF_LIB_SUFFIX@::tensorflow_framework INTERFACE - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external" - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external/src" + @TF_INCLUDE_DIRS@ ) if(@TENSORFLOW_HAS_RELEASE@) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/lib/@TF_LIB_NAME@" ) - set_property(TARGET tensorflow_cc::tensorflow_framework + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework PROPERTY IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/lib/@TF_FRAMEWORK_NAME@" ) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE ) - set_property(TARGET tensorflow_cc::tensorflow_framework + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE ) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/lib/@TF_LIB_NAME@" ) - set_property(TARGET tensorflow_cc::tensorflow_framework + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework PROPERTY IMPORTED_LOCATION_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/lib/@TF_FRAMEWORK_NAME@" ) @@ -57,32 +54,32 @@ endif() if(@TENSORFLOW_HAS_DEBUG) if(NOT @TENSORFLOW_HAS_RELEASE) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/@TF_LIB_NAME@" ) - set_property(TARGET tensorflow_cc::tensorflow_framework + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework PROPERTY IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/@TF_FRAMEWORK_NAME@" ) endif() - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG ) - set_property(TARGET tensorflow_cc::tensorflow_framework + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG ) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/@TF_LIB_NAME@" ) - set_property(TARGET tensorflow_cc::tensorflow_framework + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow_framework PROPERTY IMPORTED_LOCATION_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/@TF_FRAMEWORK_NAME@" ) endif() -set(tensorflow_cc_FOUND TRUE) +set(tensorflow@TF_LIB_SUFFIX@_FOUND TRUE) set(tensorflow_framework_FOUND TRUE) diff --git a/ports/tensorflow-cc/tensorflow-cc-config-static.cmake.in b/ports/tensorflow-common/tensorflow-config-static.cmake.in similarity index 53% rename from ports/tensorflow-cc/tensorflow-cc-config-static.cmake.in rename to ports/tensorflow-common/tensorflow-config-static.cmake.in index 7f017147065649..bd8510c5e8edd7 100644 --- a/ports/tensorflow-cc/tensorflow-cc-config-static.cmake.in +++ b/ports/tensorflow-common/tensorflow-config-static.cmake.in @@ -1,34 +1,33 @@ -if(TARGET tensorflow_cc::tensorflow_cc) +if(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@) return() endif() -add_library(tensorflow_cc::tensorflow_cc STATIC IMPORTED GLOBAL) +add_library(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ STATIC IMPORTED GLOBAL) -# Compute the installation prefix from this tensorflow-cc-config.cmake file location. -# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow-cc +# Compute the installation prefix from this tensorflow@TF_PORT_SUFFIX@-config.cmake file location. +# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow@TF_PORT_SUFFIX@ get_filename_component(TENSORFLOW_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) # TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet]/share get_filename_component(TENSORFLOW_INSTALL_PREFIX "${TENSORFLOW_INSTALL_PREFIX}" DIRECTORY) # TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet] -target_include_directories(tensorflow_cc::tensorflow_cc +target_include_directories(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ INTERFACE - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external" - "${TENSORFLOW_INSTALL_PREFIX}/include/tensorflow-external/src" + @TF_INCLUDE_DIRS@ ) if(@TENSORFLOW_HAS_RELEASE@) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/lib/@TF_LIB_NAME@" ) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE ) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/lib/@TF_LIB_NAME@" ) @@ -36,21 +35,21 @@ endif() if(@TENSORFLOW_HAS_DEBUG@) if(NOT @TENSORFLOW_HAS_RELEASE@) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/@TF_LIB_NAME@" ) endif() - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG ) - set_property(TARGET tensorflow_cc::tensorflow_cc + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ PROPERTY IMPORTED_LOCATION_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/@TF_LIB_NAME@" ) endif() -set(tensorflow_cc_FOUND TRUE) +set(tensorflow@TF_LIB_SUFFIX@_FOUND TRUE) diff --git a/ports/tensorflow-common/tensorflow-config-windows-dll.cmake.in b/ports/tensorflow-common/tensorflow-config-windows-dll.cmake.in new file mode 100644 index 00000000000000..1c3cfa23eeed8c --- /dev/null +++ b/ports/tensorflow-common/tensorflow-config-windows-dll.cmake.in @@ -0,0 +1,55 @@ +if(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@) + return() +endif() + +add_library(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ SHARED IMPORTED GLOBAL) + +# Compute the installation prefix from this tensorflow@TF_PORT_SUFFIX@-config.cmake file location. +# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow@TF_PORT_SUFFIX@ +get_filename_component(TENSORFLOW_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) +# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet]/share +get_filename_component(TENSORFLOW_INSTALL_PREFIX "${TENSORFLOW_INSTALL_PREFIX}" DIRECTORY) +# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet] + +target_include_directories(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + INTERFACE + @TF_INCLUDE_DIRS@ +) + +if(@TENSORFLOW_HAS_RELEASE@) + set_target_properties(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + PROPERTIES + IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/bin/tensorflow@TF_LIB_SUFFIX@.dll" + IMPORTED_IMPLIB "${TENSORFLOW_INSTALL_PREFIX}/lib/tensorflow@TF_LIB_SUFFIX@.lib" + ) + + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE + ) + set_target_properties(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + PROPERTIES + IMPORTED_LOCATION_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/bin/tensorflow@TF_LIB_SUFFIX@.dll" + IMPORTED_IMPLIB_RELEASE "${TENSORFLOW_INSTALL_PREFIX}/lib/tensorflow@TF_LIB_SUFFIX@.lib" + ) +endif() + +if(@TENSORFLOW_HAS_DEBUG@) + if(NOT @TENSORFLOW_HAS_RELEASE@) + set_target_properties(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + PROPERTIES + IMPORTED_LOCATION "${TENSORFLOW_INSTALL_PREFIX}/debug/bin/tensorflow@TF_LIB_SUFFIX@.dll" + IMPORTED_IMPLIB "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/tensorflow@TF_LIB_SUFFIX@.lib" + ) + endif() + + set_property(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG + ) + set_target_properties(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + PROPERTIES + IMPORTED_LOCATION_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/bin/tensorflow@TF_LIB_SUFFIX@.dll" + IMPORTED_IMPLIB_DEBUG "${TENSORFLOW_INSTALL_PREFIX}/debug/lib/tensorflow@TF_LIB_SUFFIX@.lib" + ) +endif() + +set(tensorflow@TF_LIB_SUFFIX@_FOUND TRUE) diff --git a/ports/tensorflow-common/tensorflow-config-windows-lib.cmake.in b/ports/tensorflow-common/tensorflow-config-windows-lib.cmake.in new file mode 100644 index 00000000000000..00382b187cb1e6 --- /dev/null +++ b/ports/tensorflow-common/tensorflow-config-windows-lib.cmake.in @@ -0,0 +1,18 @@ +if(TARGET tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@) + return() +endif() + +set(tensorflow@TF_LIB_SUFFIX@_FOUND TRUE) + +# Compute the installation prefix from this tensorflow@TF_PORT_SUFFIX@-config.cmake file location. +# CMAKE_CURRENT_LIST_DIR = [vcpkg_installed_dir]/[target_triplet]/share/tensorflow@TF_PORT_SUFFIX@ +get_filename_component(TENSORFLOW_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) +# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet]/share +get_filename_component(TENSORFLOW_INSTALL_PREFIX "${TENSORFLOW_INSTALL_PREFIX}" DIRECTORY) +# TENSORFLOW_INSTALL_PREFIX = [vcpkg_installed_dir]/[target_triplet] + +add_library(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ INTERFACE IMPORTED GLOBAL) +target_include_directories(tensorflow@TF_LIB_SUFFIX@::tensorflow@TF_LIB_SUFFIX@ + INTERFACE + @TF_INCLUDE_DIRS@ +) diff --git a/ports/tensorflow/CONTROL b/ports/tensorflow/CONTROL new file mode 100644 index 00000000000000..0f775ae8d9d46a --- /dev/null +++ b/ports/tensorflow/CONTROL @@ -0,0 +1,6 @@ +Source: tensorflow +Version: 2.3.1 +Port-Version: 0 +Homepage: https://github.com/tensorflow/tensorflow +Description: Library for computation using data flow graphs for scalable machine learning (C API version) +Supports: !(x86|arm|uwp) diff --git a/ports/tensorflow/portfile.cmake b/ports/tensorflow/portfile.cmake new file mode 100644 index 00000000000000..f3a43d24c2c370 --- /dev/null +++ b/ports/tensorflow/portfile.cmake @@ -0,0 +1,19 @@ +vcpkg_fail_port_install(ON_ARCH "x86" "arm" ON_TARGET "uwp") + +set(TF_LIB_SUFFIX "") +set(TF_PORT_SUFFIX "") +set(TF_INCLUDE_DIRS "${INSTALL_PREFIX}/${TARGET_TRIPLET}/include") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tensorflow-common") +include(tensorflow-common) + +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/c_api.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/c_api_experimental.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/tensor_interface.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/tf_attrtype.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/tf_datatype.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/tf_file_statistics.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/tf_status.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/tf_tensor.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/eager/c_api.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c/eager) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/eager/c_api_experimental.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c/eager) +file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/include/tensorflow/c/eager/dlpack.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow/c/eager)