如何将CMAKE_GENERATOR传递给CMake外部项目?

时间:2017-09-19 14:11:12

标签: c++ visual-studio-2015 tensorflow cmake msbuild

我正在尝试将TensorFlow CMake构建编译为Windows上的外部项目。这需要64位工具链在编译期间不会耗尽内存。但是,即使顶级项目的CMAKE_GENERATORVisual Studio 14 2015 Win64,并且通过CMAKE_GENERATOR变量传递给外部项目,32位工具链也用于编译外部项目项目。

我观察到:当构建开始时,64位MSBuild进程产生以按预期方式驱动主项目。这可以在任务管理器中看到。但是,在构建TensorFlow外部项目时,外部项目的MSBuild (32 bit)进程启动。编译器稍后失败并显示error: c1060: compiler is out of heap space

TensorFlow外部项目的CMake代码是

ExternalProject_Add(TensorFlow
  GIT_REPOSITORY ${TensorFlow_REPOSITORY}
  SOURCE_DIR ${TensorFlow_SOURCE_DIR}
  SOURCE_SUBDIR tensorflow/contrib/cmake
  BINARY_DIR ${TensorFlow_BINARY_DIR}
  CMAKE_GENERATOR ${CMAKE_GENERATOR}
  CMAKE_ARGS
    --no-warn-unused-cli
    -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
    -DSWIG_EXECUTABLE:FILEPATH=${SWIG_EXECUTABLE}
    -DPYTHON_EXEUTABLE:FILEPATH=${PYTHON_EXECUTABLE}
    -DPYTHON_LIBRARIES:LIST=${PYTHON_LIBRARIES}
    -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX
  UPDATE_COMMAND ""
  DEPENDS ${TensorFlow_DEPENDENCIES}
)

TensorFlow配置阶段的输出是

Creating directories for 'TensorFlow'
Performing download step (git clone) for 'TensorFlow'
Cloning into 'TensorFlow'...
Checking out files: 100% (7280/7280), done.
Already on 'master'
Your branch is up-to-date with 'origin/master'.
No update step for 'TensorFlow'
No patch step for 'TensorFlow'
Performing configure step for 'TensorFlow'
Not searching for unused variables given on the command line.
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- wor
ks
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed
-- Performing Test COMPILER_OPT_WIN_CPU_SIMD_SUPPORTED
-- Performing Test COMPILER_OPT_WIN_CPU_SIMD_SUPPORTED - Success
-- Found PythonInterp: C:/Users/kasper/Anaconda3/python.exe (found version "3.5.2")
-- Found PythonLibs: C:/Users/kasper/Anaconda3/libs/python35.lib (found version "3.5.2")
-- Found SWIG: C:/Development/build/t/SWIG/swig.exe (found version "3.0.10")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Development/build/t/TensorFlow-build

然后将message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR")添加到顶级TensorFlow CMakeLists.txt并在cmake .目录中运行TensorFlow-build

-- CMAKE_GENERATOR: Visual Studio 14 2015 Win64
-- Configuring done
-- Generating done

TensorFlow外部项目CMAKE_GENERATOR的值为 Visual Studio 14 2015 Win64。我也尝试将-G ${CMAKE_GENERATOR}添加到CMAKE_ARGS但无济于事。外部项目启动时,任务管理器仍显示MSBuild (32 bit)Microsoft Compiler/Linker Driver (32 bit)

可以在此处找到代码:https://github.com/kaspermarstal/TensorFlowImageFilter

我错过了什么?

0 个答案:

没有答案