cmake_minimum_required(VERSION 3.14)
project(my_project)

# GoogleTest requires at least C++11
set(CMAKE_CXX_STANDARD 17)

include(FetchContent)
FetchContent_Declare(
  googletest
  URL https://github.com/google/googletest/archive/refs/tags/release-1.10.0.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

enable_testing()

add_custom_command(
  OUTPUT mock.h mock.o
  COMMAND mimicc++ ${CMAKE_CXX_FLAGS} -c -o mock.o --hout=mock.h ${CMAKE_CURRENT_SOURCE_DIR}/foo.h
  DEPENDS foo.h
)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_executable(
  mimicc_test
  mimicc_test.cpp
  mock.o
)
target_link_libraries(
  mimicc_test
  gtest_main
)

include(GoogleTest)
gtest_discover_tests(mimicc_test)
