[CMake] Copy file from Source to Build dir based on CMAKE_CFG_INTDIR
Michael Jackson
mike.jackson at bluequartz.net
Thu Aug 23 14:59:57 EDT 2018
Hmm, That works great for MSVC compiles but not so great when I use ninja or makefiles (any of the single config generators). I was looking through the generator expressions on the Cmake doc site but didn't really come across anything that seems like it would get me what is needed. I guess I just put in:
If(MSVC or Xcode)
Do this
Else()
Do that
Endif().
Seems like this should just not be needed...
--
Mike Jackson
On 8/23/18, 1:59 PM, "Robert Maynard" <robert.maynard at kitware.com> wrote:
You can use `file(GENERATE` and the `$<CONFIG>` generator expression.
Here is an example:
https://gitlab.kitware.com/cmake/cmake/blob/v3.12.1/Tests/CudaOnly/ExportPTX/CMakeLists.txt#L13
On Thu, Aug 23, 2018 at 1:47 PM Michael Jackson
<mike.jackson at bluequartz.net> wrote:
>
> 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
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list