I have a root cmake which produces me main binary with precompiled headers:
cmake_minimum_required(VERSION 3.16)
project(main_app)
add_executable( main_app src/main_app.cpp )
target_precompile_headers( main_app PUBLIC src/pch.h )
set( CMAKE_PCH_INSTANTIATE_TEMPLATES ON )
target_link_libraries( main_app boost_random )
add_subdirectory( tests )
I have also ‘tests’ subdirectory which has it’s own CMakeLists.txt and I am trying to rely on the target that is in the root directory to use already generated precompiled headers like this:
...
target_precompile_headers( some_test REUSE_FROM main_app )
...
But I am receiving an error that says in general that it could not find target ‘main_app’.
When I am doing that from the same CMakeLists.txt, everything is working, but I do not know how to rely on the target that is in the root/upper directory. Please advice how to resolve this issue, thanks in advance