Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is INSTALL_DIR useful for in ExternalProject_Add command?

I don't understand the usage of INSTALL_DIR in ExternalProject_Add command. I try to use it but it does not seem to work. Here is an example of a CMakeLists.txt, using Eigen library which compiles quickly:

cmake_minimum_required (VERSION 2.6)
project (example CXX)
include(ExternalProject)
include(ProcessorCount)
set(CMAKE_VERBOSE_MAKEFILE ON)
ProcessorCount(N)
if(NOT N EQUAL 0)
   set(CMAKE_BUILD_FLAGS -j${N})
endif()
ExternalProject_Add
(
    mylib
    PREFIX myprefix
    DOWNLOAD_COMMAND wget http://bitbucket.org/eigen/eigen/get/3.2.4.tar.gz && tar xvzf 3.2.4.tar.gz -C mylib --strip-components=1
)

I chose the following project hierarchy:

project
    CMakeLists.txt
    build/

From build repository, I type:

cmake ..
make

The installation process fails with the following message:

file cannot create directory: /usr/local/include/eigen3.
Maybe need administrative privileges.

As far as I understand, it means that I need to define a "prefix" during the configuration step:

cmake -D CMAKE_INSTALL_PREFIX=$INSTALL_DIR ..

But, the INSTALL_DIR variable is already defined in the ExternalProject_Add command. However, I get the same error when I modify the value of INSTALL_DIR by adding

INSTALL_DIR myprefix/src/install

in the ExternalProject_Add command.

So, what is INSTALL_DIR useful for? What am I doing wrong?

Of course, I know how to provide my own configuration command to add a prefix and solve the problem. But it is not my question. My question is: if I have to do that, what is the purpose of INSTALL_DIR?

like image 773
Aleph Avatar asked Apr 09 '15 08:04

Aleph


1 Answers

From what I found in this discussion https://www.mail-archive.com/[email protected]/msg51663.html (scroll to the end of the page to navigate through the thread messages) it is indeed pretty common thing to use CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/contrib

Furthermore, lurking through the ExternalProject.cmake module I found out that the only effect setting this directory has is that CMake will create directory specified in INSTALL_DIR before doing anything else.

Also, it will set the property that you can gather through ExternalProject_Get_Property(${project_name} install_dir) command.

And that's pretty much it.

// As of CMake version 3.2.2

like image 155
Vitalii Minnakhmetov Avatar answered Sep 20 '22 16:09

Vitalii Minnakhmetov