在Windows上的其他构建目录中运行cmake

时间:2018-11-21 19:19:18

标签: c++ cmake

我使用cmake ..运行CMake,以使其将所有生成的文件输出到另一个目录中。这在Ubuntu上运行良好,但是在尝试运行Windows 10时却无法运行。从根项目目录运行cmake .似乎在两种平台上均能正常工作。 Windows上cmake ..的输出是:

PS D:\Development\cpp\hello-vulkan\build> cmake ..
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.16299.0 to target Windows 10.0.17134.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!

在此处指定CMakeLists.txt:

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
cmake_minimum_required(VERSION 3.10)
project(hello_vulkan)

# Download and setup GLFW
set(GLFW_DIR        ${PROJECT_SOURCE_DIR}/lib/glfw)
set(GLFW_BINARY_DIR ${GLFW_DIR}/bin)
ExternalProject_Add(
    glfw
    PREFIX         ${GLFW_DIR}
    GIT_REPOSITORY https://github.com/glfw/glfw.git
    GIT_TAG        3.2.1
    INSTALL_DIR    ${GLFW_BINARY_DIR}
    CMAKE_ARGS     -DCMAKE_INSTALL_PREFIX=${GLFW_BINARY_DIR}
)

# Link Vulkan and GLFW
set(VULKAN_DIR      ${PROJECT_SOURCE_DIR}/lib/vulkan)
include_directories(${VULKAN_DIR}/include)
link_directories(
    ${VULKAN_DIR}/lib
    ${GLFW_BINARY_DIR}
)

# Setup project
set(CMAKE_CXX_STANDARD             17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH         ${PROJECT_SOURCE_DIR}/build/)
set(SOURCES                        source/main.cpp)

add_executable(hello_vulkan ${SOURCES})
add_dependencies(hello_vulkan glfw)

从Windows上的其他目录运行时,有什么想法可以使其正常工作吗?

编辑: 这是Ubuntu上cmake ..的输出:

cmake ..
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/Development/cpp/hello-vulkan/build

0 个答案:

没有答案