2
發現當我運行此:cmake -G "Visual Studio 15 2017 Win64"
的CMake:編譯器不能在Windows
我有這樣的輸出:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "C:/Users/ce/type/CMakeFiles/CMakeOutput.log".
See also "C:/Users/ce/type/CMakeFiles/CMakeError.log".
這是我CMakeLists(我已刪除了無用的東西的爲例)
cmake_minimum_required(VERSION 3.4)
project(type)
option(BUILD_CLIENT "Build Client" ON)
option(BUILD_SERVER "Build Server" ON)
set(CLIENT_NAME "type_client")
set(SERVER_NAME "type_server")
set(CLIENT_SRCDIR "client/src/")
set(SERVER_SRCDIR "server/src/")
set(INC_DIR_CLIENT "client/includes")
set(INC_DIR_SERVER "server/includes")
set(INC_DIR_DLLOADER "DLLoader/")
set(INC_DIR_ECS "ecs/")
set(INC_DIR_PROTOCOL "protocol/")
set(LIB_LINKS "-ldl -lpthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CLIENT_SOURCE_FILES
${CLIENT_SRCDIR}main.cpp)
set(SERVER_SOURCE_FILES
${SERVER_SRCDIR}main.cpp)
set(SERVER_SOURCE_FILES_SYSTEMS)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
if(WIN32)
set(SFML_ROOT "dependancies/windows/SFML-2.4.1")
elseif(UNIX)
set(SFML_ROOT "dependancies/linux/SFML-2.4.1")
endif()
find_package(SFML 2 REQUIRED system window graphics network audio)
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
if(WIN32)
include_directories(${INC_DIR_DLLOADER}/win)
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
include_directories(${INC_DIR_DLLOADER}/linux)
set(SFML_ROOT "dependancies/SFML-2.4.1")
endif()
include_directories(${SFML_INCLUDE_DIR})
if(BUILD_CLIENT)
add_executable(${CLIENT_NAME} ${CLIENT_SOURCE_FILES})
target_link_libraries(${CLIENT_NAME} ${SFML_LIBRARIES} ${LIB_LINKS})
endif()
if(BUILD_SERVER)
if(WIN32)
add_executable(${SERVER_NAME} ${SERVER_SOURCE_FILES}
${SERVER_SOURCE_FILES_SYSTEMS} ${SERVER_SOURCE_FILES_WIN})
target_link_libraries(${SERVER_NAME} -lws2_32)
elseif(UNIX)
add_executable(${SERVER_NAME} ${SERVER_SOURCE_FILES}
${SERVER_SOURCE_FILES_SYSTEMS} ${SERVER_SOURCE_FILES_LINUX})
target_link_libraries(${SERVER_NAME} ${LIB_LINKS})
endif()
endif()
我用Visual Studio安裝了C++編譯器,所以我不明白爲什麼編譯器沒有被檢測到。