加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 4.85 KB
一键复制 编辑 原始数据 按行查看 历史
neargye 提交于 2019-12-04 16:28 . update to tf v1.15.0
cmake_minimum_required(VERSION 3.6)
project(hello_tf)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_VERBOSE_MAKEFILE ON)
add_compile_options(-Wall -Wextra -pedantic-errors -Werror)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/W4 /WX)
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11)
add_compile_options(/permissive-)
endif()
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow)
make_directory(${CMAKE_SOURCE_DIR}/tensorflow)
endif()
if(UNIX AND NOT APPLE)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow)
make_directory(${CMAKE_SOURCE_DIR}/tensorflow)
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow/lib/libtensorflow.so)
file(
DOWNLOAD
https://github.com/Neargye/tensorflow/releases/download/v1.15.0/libtensorflow-cpu-linux-x86_64-1.15.0.tar.gz ${CMAKE_SOURCE_DIR}/tensorflow/linux.tar.gz
STATUS
status
LOG
log
)
list(GET status 0 status_code)
list(GET status 1 status_string)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "error downloading tensorflow lib: ${status_string}" "${log}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvzf ${CMAKE_SOURCE_DIR}/tensorflow/linux.tar.gz WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tensorflow)
file(REMOVE ${CMAKE_SOURCE_DIR}/tensorflow/linux.tar.gz)
endif()
elseif(APPLE)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow)
make_directory(${CMAKE_SOURCE_DIR}/tensorflow)
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow/lib/libtensorflow.so)
file(
DOWNLOAD
https://github.com/Neargye/tensorflow/releases/download/v1.15.0/libtensorflow-cpu-darwin-x86_64-1.15.0.tar.gz ${CMAKE_SOURCE_DIR}/tensorflow/darwin.tar.gz
STATUS
status
LOG
log
)
list(GET status 0 status_code)
list(GET status 1 status_string)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "error downloading tensorflow lib: ${status_string}" "${log}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvzf ${CMAKE_SOURCE_DIR}/tensorflow/darwin.tar.gz WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tensorflow)
file(REMOVE ${CMAKE_SOURCE_DIR}/tensorflow/darwin.tar.gz)
endif()
elseif(WIN32)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow)
make_directory(${CMAKE_SOURCE_DIR}/tensorflow)
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/tensorflow/lib/tensorflow.dll)
file(
DOWNLOAD
https://github.com/Neargye/tensorflow/releases/download/v1.15.0/libtensorflow-cpu-windows-x86_64-1.15.0.zip ${CMAKE_SOURCE_DIR}/tensorflow/windows.zip
STATUS
status
LOG
log
)
list(GET status 0 status_code)
list(GET status 1 status_string)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "error downloading tensorflow lib: ${status_string}" "${log}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvzf ${CMAKE_SOURCE_DIR}/tensorflow/windows.zip WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tensorflow)
file(REMOVE ${CMAKE_SOURCE_DIR}/tensorflow/windows.zip)
endif()
configure_file(tensorflow/lib/tensorflow.dll ${CMAKE_CURRENT_BINARY_DIR}/tensorflow.dll COPYONLY)
configure_file(tensorflow/lib/tensorflow.dll ${CMAKE_CURRENT_BINARY_DIR}/test/tensorflow.dll COPYONLY)
endif()
include_directories(tensorflow/include)
include_directories(src/3rdparty/scope_guard/include)
link_directories(${CMAKE_SOURCE_DIR}/tensorflow/lib)
add_executable(hello_tf src/hello_tf.cpp)
target_link_libraries(hello_tf tensorflow)
add_executable(session_run src/session_run.cpp src/tf_utils.cpp src/tf_utils.hpp)
target_link_libraries(session_run tensorflow)
add_executable(load_graph src/load_graph.cpp)
target_link_libraries(load_graph tensorflow)
add_executable(interface src/interface.cpp src/tf_utils.cpp src/tf_utils.hpp)
target_link_libraries(interface tensorflow)
add_executable(graph_info src/graph_info.cpp src/tf_utils.cpp src/tf_utils.hpp)
target_link_libraries(graph_info tensorflow)
add_executable(create_tensor src/create_tensor.cpp)
target_link_libraries(create_tensor tensorflow)
add_executable(tensor_info src/tensor_info.cpp src/tf_utils.cpp src/tf_utils.hpp)
target_link_libraries(tensor_info tensorflow)
add_executable(allocate_tensor src/allocate_tensor.cpp)
target_link_libraries(allocate_tensor tensorflow)
add_executable(batch_interface src/batch_interface.cpp src/tf_utils.cpp src/tf_utils.hpp)
target_link_libraries(batch_interface tensorflow)
configure_file(models/graph.pb ${CMAKE_CURRENT_BINARY_DIR}/graph.pb COPYONLY)
enable_testing()
add_subdirectory(test)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化