2

I want to use ExternalProject_Add function to install cmake enabled projects. I need to control the building and installation processes. More specifically, I want that cmake build and install in specific directories.

There is an option to select a path where to put the source directory: SOURCE_DIR. Is there something equivalent for BUILD_DIR and INSTALL_DIR? I did not see anything alike.

There is a PREFIX option:

Root dir for entire project

What does it mean exactly? An how does cmake's ExternalProject_Add do the installation?

Edit:

This work, but I have no control over source directory and it does not install the library:

ExternalProject_Add(
    wjelement-project

    GIT_REPOSITORY "https://github.com/netmail-open/wjelement.git"
    GIT_TAG "v1.2"

    UPDATE_COMMAND ""
    PATCH_COMMAND ""
    TEST_COMMAND ""
    INSTALL_COMMAND ""  

    #SOURCE_DIR "${MY_SOURCE_ROOT}/wjelement"
    BINARY_DIR "${MY_BUILD_DIR}/wjelement"
    INSTALL_DIR "${CCT_INSTALL_DIR}/wjelement"   
)
  • If I uncomment SOURCE_DIR, it does not clone from GIT_CLONE but try to get source from SOURCE_DIR (and it fails because that's not what I expected...)
  • If I comment INSTALL_COMMAND "", then it try to install in C:/Program Files/wjelement, the default (apparently) and not in INSTALL_DIR
  • default path for source files seem to be ${CMAKE_BINARY_DIR}/wjelement-project-prefix/src

Another Stackoverflow question report problem (or at least non intuitive behavior) with INSTALL_DIR.

RAM
  • 2,257
  • 2
  • 19
  • 41
jvtrudel
  • 1,235
  • 3
  • 15
  • 28
  • [Documentation](https://cmake.org/cmake/help/v3.7/module/ExternalProject.html) describes both `BUILD_DIR` and `INSTALL_DIR` options. Also, here you may read about relation between `PREFIX` and default value for the options. – Tsyvarev Mar 16 '17 at 19:30
  • There is indeed an ````INSTALL_DIR````. I did not notice it. But there is no ````BUILD_DIR````. I think that ````BINARY_DIR```` is the command I am looking for. – jvtrudel Mar 16 '17 at 19:39
  • Where could I read about relation between ````PREFIX```` and default value for the options? – jvtrudel Mar 16 '17 at 19:40
  • Sorry, I actually meant `BINARY_DIR`. As for relations with `PREFIX`, there is line `INSTALL_DIR = `. – Tsyvarev Mar 16 '17 at 19:44
  • can't make it work with ````INSTALL_DIR```` and ````SOURCE_DIR```` . I'll edit my question to add what I tried and what goes wrong. – jvtrudel Mar 16 '17 at 19:58
  • First of all, which CMake version do you use? ExternalProject has different behavior for different versions. – Tsyvarev Mar 16 '17 at 20:31
  • CMAKE_VERSION = 3.6.2 – jvtrudel Mar 16 '17 at 21:03
  • 1
    `default path for source files seem ...` - This is referred as *DOWNLOAD_DIR* in documentation. From this directory `git clone` is executed. After the clone, subdirectory `wjelement` will contain sources, and referred as (default) *SOURCE_DIR*. So you observe exactly this behavior. As for `INSTALL_DIR` you found the proper question. – Tsyvarev Mar 16 '17 at 21:28

0 Answers0