Compile-time wildcards in cmake install targets

后端 未结 2 624
夕颜
夕颜 2021-01-06 20:54

I\'m new to cmake and I\'m finding it very frustrating. I am trying to use wildcards in file paths that are evaluated when the build runs, not when the build is generated.

相关标签:
2条回答
  • 2021-01-06 21:18

    you can use install(SCRIPT swigInstaller.cmake) or install(DIRECTORY) both of which supports doing file globing at install time. You can read more about the install command at:

    http://cmake.org/cmake/help/cmake-2-8-docs.html#command:install

    0 讨论(0)
  • 2021-01-06 21:43

    Assuming that the Java wrappers are located in the current binary directory, you can use the following install command to copy the Java files upon install:

    install(
        CODE "file( GLOB _GeneratedJavaSources \"${CMAKE_CURRENT_BINARY_DIR}/*.java\" )"
        CODE "file( INSTALL \${_GeneratedJavaSources} DESTINATION \"$ENV{HOME}\" )"
    )
    

    The CODE form of the install command is used to execute two CMake commands upon running the install target. The first one collects all generated Java files in a helper variable. The second one uses the INSTALL form of the file command to copy the files.

    0 讨论(0)
提交回复
热议问题