DuckQueen
DuckQueen

Reputation: 810

How to translate CMake command into bash\cmd and pass it as argument in other cmake command?

I want to embed GSL as external project.

ExternalProject_Add(
        gsl
        GIT_REPOSITORY git://git.savannah.gnu.org/gsl.git
        DOWNLOAD_DIR external/gsl
        SOURCE_DIR external/gsl
        PATCH_COMMAND file(COPY external/gsl/contrib/CMakeLists.txt external/gsl/contrib/ ) 
        CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
        BINARY_DIR ./
        INSTALL_DIR ./
    )

Yet file(COPY external/gsl/contrib/CMakeLists.txt external/gsl/contrib/ ) is CMake command (that could generally work on any platform). I wonder how to translate it into cmd to be able to call it in PATCH_COMMAND in crossplatform manner without creating platform dependent logic?

Upvotes: 0

Views: 190

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 66288

CMake implements a predefined set of portable commands available through invocation

cmake -E <command> <args>

For example, file(COPY) cmake command has command-line equivalent

cmake -E COPY <file> <destination>

For more information, see documentation about cmake command line tool.

If there is no command-line equvalent for some cmake command(s), one may store required sequence of the commands in file, and perform these commands with

cmake -P <script>

Upvotes: 1

Related Questions