'Setting up cmake with a projects

Im following the popular cpu emulation series by Dave Poo on Youtube. Im on the second episode where we integarate googletest. Im getting all kind of errors but the most not understandable one is a "Cannot find source file".

This is the CMakeLists file

cmake_minimum_required(VERSION 3.23)

project(ProjectName)

include(FetchContent)
FetchContent_Declare(
  googletest
  # Specify the commit you depend on and update it regularly.
  URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Now simply link against gtest or gtest_main as needed. Eg
add_executable( M6502test main.cpp)
#target_link_libraries(M6502test gtest)
#target_link_libraries(M6502test M6502lib)

I have commented out the link_libaries since they are causing errors aswell. The structure of the project is 2 folders M6502lib and M6502test. The first one has the actual code in a header file while the latter has a main function. CmakeList file is on the same level as the FOLDERS not the files.

I havent been able to set up googleset for a whole day so other info on the how I should do it would be great as I am getting loads of other errors.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source