diff --git a/lib/TargetSetup.cmake b/lib/TargetSetup.cmake index 48541f0..4699e3d 100644 --- a/lib/TargetSetup.cmake +++ b/lib/TargetSetup.cmake @@ -36,7 +36,7 @@ function(myx_target_setup NAME) endif() if(ARG_PCH) - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16 AND PROJECT_IS_TOP_LEVEL OR MYX_USE_LOCAL_DIRECTORIES) target_precompile_headers(${NAME} PRIVATE ${ARG_PCH}) else() target_compile_options(${NAME} PRIVATE -include ${ARG_PCH})