I am trying to get a development environment up and running with Visual Studio 2017 Professional using Cmake/Clang as the build systmem.
I made a simple hello world main.cpp along with the CMakeLists.txt that goes along with it. I tested it on my linux system and it builds fine and executes.
I opened the root folder for the project using Visual Studio 2017 and it imports the cmake stuff when it opens. I noticed the cmake seemed to be functioning correctly and output everything it normally would output on the linux side. This was on the lower window where VS2017 shows build output.
However, when I go to rebuild under the Cmake menu option in Visual Studio I get the following error: Error 'Z:/Path/To/Proj/vstest/src/main.cpp', needed by 'CMakeFiles/interface.dir/src/main.cpp.obj', missing and no known rule to make it
My Z: drive is a mapped drive to the linux machine and it is functioning properly. Make is installed on all machines. Im guessing something simple that is assumed on linux is not being assumed in the visual studio environment. Anyone got any idea what that may be?
Relevant Files
main.cpp:
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(test)
#Compiler Definition
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
if(7.0.0 VERSION_GREATER_EQUAL CMAKE_CXX_COMPILER_VERSION)
message( FATAL_ERROR "must have clang version 7.0.0 or greater." )
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
if(8.0.0 VERSION_GREATER_EQUAL CMAKE_CXX_COMPILER_VERSION)
message( FATAL_ERROR "must have gcc version 8.0.0 or greater." )
endif()
endif()
#Enforce Build Folder use
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please make a build directory.")
endif()
string(ASCII 27 Esc)
message(STATUS "Starting Build Sequence")
#Create Build Options
#packageing options
#Source
set(TEST_SOURCE_FILES src/main.cpp)
add_executable(test ${TEST_SOURCE_FILES})
#compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -std=c++17 -pedantic -U_FORTIFY_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wall -ansi -pedantic -U_FORTIFY_SOURCE")
Directory Structure:
Path To Proj
|_vstest
|_.vs
|_build
|_src
|_include(empty)
|_main.cpp
|_CMakeLists.txt
Aucun commentaire:
Enregistrer un commentaire