@@ -1600,6 +1600,65 @@ void CMakePrinter::print_meta_config_file(const path &fn) const
16001600 }
16011601 }
16021602
1603+ // copy deps
1604+ if (cc->local_settings .use_cache )
1605+ {
1606+ config_section_title (ctx, " custom actions for dummy target" );
1607+
1608+ ctx.addLine (" # copy dependencies" );
1609+ ctx.addLine (" if (CPPAN_USE_CACHE)" );
1610+ ctx.increaseIndent ();
1611+
1612+ // no copy for non local builds
1613+ if (cc->internal_options .current_package .empty ())
1614+ {
1615+ ctx.addLine (" if (NOT COPY_LIBRARIES_TO_OUTPUT)" );
1616+ ctx.increaseIndent ();
1617+ ctx.addLine (" set(output_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})" );
1618+ ctx.addLine (" if (MSVC OR XCODE)" );
1619+ ctx.addLine (" set(output_dir ${output_dir}/$<CONFIG>)" );
1620+ ctx.addLine (" endif()" );
1621+ ctx.addLine (" if (CPPAN_BUILD_OUTPUT_DIR)" );
1622+ ctx.addLine (" set(output_dir ${CPPAN_BUILD_OUTPUT_DIR})" );
1623+ ctx.addLine (" endif()" );
1624+ ctx.addLine ();
1625+
1626+ Packages copy_deps;
1627+ gather_copy_deps (ctx, rd[d].dependencies , copy_deps);
1628+ for (auto &dp : copy_deps)
1629+ {
1630+ auto &p = dp.second ;
1631+ // do not copy static only projects
1632+ if (rd[p].config ->getDefaultProject ().static_only ||
1633+ !rd[p].config ->getDefaultProject ().copy_to_output_dir )
1634+ continue ;
1635+
1636+ ctx.addLine (" get_target_property(type " + p.target_name + " TYPE)" );
1637+ ctx.addLine (" if (NOT ${type} STREQUAL STATIC_LIBRARY)" );
1638+ ctx.increaseIndent ();
1639+ ctx.addLine (" add_custom_command(TARGET " + cppan_dummy_target + " POST_BUILD" );
1640+ ctx.increaseIndent ();
1641+ ctx.addLine (" COMMAND ${CMAKE_COMMAND} -E copy_if_different" );
1642+ ctx.increaseIndent ();
1643+ ctx.addLine (" $<TARGET_FILE:" + p.target_name + " > ${output_dir}/$<TARGET_FILE_NAME:" + p.target_name + " >" );
1644+ ctx.decreaseIndent ();
1645+ ctx.decreaseIndent ();
1646+ ctx.addLine (" )" );
1647+ ctx.decreaseIndent ();
1648+ ctx.addLine (" endif()" );
1649+ ctx.addLine ();
1650+ }
1651+
1652+ ctx.decreaseIndent ();
1653+ ctx.addLine (" endif()" );
1654+ ctx.addLine ();
1655+ }
1656+
1657+ ctx.decreaseIndent ();
1658+ ctx.addLine (" endif()" );
1659+ ctx.addLine ();
1660+ }
1661+
16031662 ctx.emptyLines (1 );
16041663 ctx.addLine (config_delimeter);
16051664 ctx.addLine ();
@@ -1917,45 +1976,6 @@ set_target_properties(run-cppan PROPERTIES
19171976 }
19181977 }
19191978
1920- // copy deps
1921- // no copy for non local builds
1922- if (cc->internal_options .current_package .empty ())
1923- {
1924- ctx.addLine (" if (CPPAN_BUILD_SHARED_LIBS)" );
1925- ctx.increaseIndent ();
1926- ctx.addLine (" set(output_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})" );
1927- ctx.addLine (" if (MSVC OR XCODE)" );
1928- ctx.addLine (" set(output_dir ${output_dir}/$<CONFIG>)" );
1929- ctx.addLine (" endif()" );
1930- ctx.addLine (" if (CPPAN_BUILD_OUTPUT_DIR)" );
1931- ctx.addLine (" set(output_dir ${CPPAN_BUILD_OUTPUT_DIR})" );
1932- ctx.addLine (" endif()" );
1933- ctx.addLine ();
1934-
1935- Packages copy_deps;
1936- gather_copy_deps (ctx, rd[d].dependencies , copy_deps);
1937- for (auto &dp : copy_deps)
1938- {
1939- auto &p = dp.second ;
1940- // do not copy static only projects
1941- if ( rd[p].config ->getDefaultProject ().static_only ||
1942- !rd[p].config ->getDefaultProject ().copy_to_output_dir )
1943- continue ;
1944- ctx.addLine (" add_custom_command(TARGET " + cppan_dummy_target + " POST_BUILD" );
1945- ctx.increaseIndent ();
1946- ctx.addLine (" COMMAND ${CMAKE_COMMAND} -E copy_if_different" );
1947- ctx.increaseIndent ();
1948- ctx.addLine (" $<TARGET_FILE:" + p.target_name + " > ${output_dir}/$<TARGET_FILE_NAME:" + p.target_name + " >" );
1949- ctx.decreaseIndent ();
1950- ctx.decreaseIndent ();
1951- ctx.addLine (" )" );
1952- }
1953-
1954- ctx.decreaseIndent ();
1955- ctx.addLine (" endif()" );
1956- ctx.addLine ();
1957- }
1958-
19591979 ctx.decreaseIndent ();
19601980 ctx.addLine (" endif()" );
19611981 ctx.addLine ();
0 commit comments