So from the reddit post, I got to https://godbolt.org/z/WseTsM8YG and I decided I'd try my hand at making a multi-file project on godbolt from scratch. However, something seems to be wrong. My project: https://godbolt.org/z/7asGz3Wov
Seems that main.cpp
can't see the header.h
file for some reason. I added each file separately, and they appear to be in the same directory as shown here:
I even attempted to add the current directory to the include list (which shouldn't be necessary) with the -I.
command line switch. Not surprisingly, it didn't work.
My original CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.5)
project(main.exe VERSION 1.0 LANGUAGES CXX)
add_executable(main main.cpp source1.cpp source2.cpp)
I then changed to align with the reddit example:
cmake_minimum_required(VERSION 3.5)
#project(main.exe VERSION 1.0 LANGUAGES CXX)
add_executable(main main.cpp source1.cpp source2.cpp)
target_link_libraries(main)
That didn't do anything either.
It would appear the files are not located in the same directory. What magic am I missing to do that?