How to copy the dll's using cmake?


I have to copy dll's to a folder while building my solution. The structure of cmake as follows:

D:/src/cmakeLists.txt D:/target/runtime/bin D:/repos/stable/compiler/xyz.dll

So, i want to copy xyz.dll to "D:/target/runtime/bin" . I did as follows in cmake:

add_custom_command(TARGET performance POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/libs/xyz.dll" $<TARGET_FILE_DIR:performance>)

But it did not copied any dll. So, suggest me how do i achieve it. I am not much familiar with cmake .So, please suggest.


I use the <a href="https://cmake.org/cmake/help/v3.4/command/configure_file.html" rel="nofollow">configure_file()</a> command for that purpose. It copies the file during the cmake generate step.

Try something like

configure_file("${PROJECT_SOURCE_DIR}/libs/xyz.dll" $<TARGET_FILE_DIR:performance> COPYONLY)


  • Trap memory accesses inside a standard executable built with MinGW
  • preg_match for mysql date format
  • How do add anchor in the image dynamically
  • MS Access - For each occurence of a given variable, increase a “count” value by one?
  • Scala simplify nested monads
  • How to convert efficiently binary string to binary byte array in Java?
  • Wix - How to get user input from a previously installed msi?
  • ASP.NET Identity Is default ApplicationUserManager implementing IUserEmailStore?
  • How do I turn on cost controls on BigQuery?
  • What regular expression does a browsers use for HTML5 input type=url?
  • meld on OS X 10.7 doesn't work?
  • How to create custom font family with bold font
  • Create Expression from a given Type
  • Read certain line in text file and display the next
  • Go Flush() doesn't work
  • iOS notifications sporadic (FMX)
  • When to use inputRef.current instead of this.inputRef React.js?
  • Simulating a FULL OUTER JOIN in Access
  • how to animate two continuous popup windows with jquery mobile?
  • jquery: Disable/Enable button not working after reset
  • Python: Why am I getting a UnicodeDecodeError?
  • NextJS auth with an external server
  • Javascript getting the value of an input in a table [duplicate]
  • Authorization Policies/Gates for Laravel 5.3 web app consuming own API w/ Passport
  • Customize jQuery submenu positioning
  • android 3G signal strength
  • How to add multiple legend titles (columns) in ggplot
  • Javascript / jQuery not executing in IE until the body of the page is moused over
  • Php artisan optimize is failing on production server
  • How does the dispatcher work when mixing sync/async with serial/concurrent queue?
  • “Cannot open log for source” - Windows 7 - .NET web service - event log
  • How to join two tables from different databases
  • how to specify different css for ie
  • I am consuming a WCF service that requires headers from a .NET 2 website. How can I programmatically
  • Stacked bar chart with continuous time-axis as x-axis
  • Why isn't stemDocument stemming?
  • Apple Mach-O Linker error (“duplicate symbol”)
  • Excel VBA : conditional formatting of sheet1 cells from sheet2 values in excel 2007