[CMake] Copy file from Source to Build dir based on CMAKE_CFG_INTDIR

Michael Jackson mike.jackson at bluequartz.net
Thu Aug 23 13:47:18 EDT 2018


I would like to copy some files from my source dir into my binary RUNTIME_DIR based on the current configuration being compiled. For generators like “makefiles” and “ninja” this is easy and straight forward. I am having an issue getting my head wrapped around how to use CMAKE_CFG_INTDIR properly.

 

I know I can’t do this a cmake time so I tried the following:

 

During CMake time write out another CMake file:

 

  file(APPEND "${PYSIMPL_SCRIPT_COPY_RULE}" 

    "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different

      \"${SIMPLPyBind11_SOURCE_DIR}/../Testing/${script}\" 

      \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/\${CMAKE_CFG_INTDIR}/python/site-packages/${script}\")\n"

  )

 

Which creates entries like this in the written .cmake file:

 

execute_process(COMMAND C:/DREAM3D_SDK/cmake-3.12.0-rc2-win64-x64/bin/cmake.exe -E copy_if_different

      "C:/Users/mjackson/DREAM3D-Dev/DREAM3D/ExternalProjects/SIMPL/Wrapping/Python/Pybind11/../Testing/AbstractFilterTest.py" 

      "C:/Users/mjackson/DREAM3D-Dev/DREAM3D-Builds/x64/Bin/${CMAKE_CFG_INTDIR}/python/site-packages/AbstractFilterTest.py")

 

Which does not work. The files end up in ${BUILD_DIR}/Bin/python/site-packages/. I need them to end up in ${BUILD_DIR}/Bin/Release/python/site-packages for a Release build. Same for Debug…

 

Could someone tell me what I am doing wrong or the proper way to go about this? I am about ready to write a simple C++ program to do the copy for me (which seems ludicrous to have to do..)

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] mike.jackson at bluequartz.net

[w] www.bluequartz.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180823/8a7b6ac7/attachment.html>


More information about the CMake mailing list