Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-source build with CMake #788

Open
chvillanuevap opened this issue May 22, 2015 · 5 comments
Open

In-source build with CMake #788

chvillanuevap opened this issue May 22, 2015 · 5 comments

Comments

@chvillanuevap
Copy link
Contributor

I'm trying to add the package Armadillo to HashStack. Here is how the package looks so far:

extends: [cmake_package]

defaults:
  relocatable: false

sources:
- key: tar.gz:mmkq6ev7pr6ftdvflnzhdwm7zy2j744g
  url: http://sourceforge.net/projects/arma/files/armadillo-5.100.2.tar.gz

I was able to build this correctly in Mac OS X Yosemite.

However, after reading the README file in Armadillo, I noticed they recommend performing an in-source build because out-of-source is not supported. I then attempted to modify my package in accordance with the cmake_package.yaml package to allow for an out-of-source build, but encountered some difficulties.

Using the default cmake_package.yaml configuration, I get the following build script:

set -e
export HDIST_IN_BUILD=yes
export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | sed -E "s/([0-9]+\.[0-9]+).*/\1/")
mkdir -p _build
cd _build
(
export CPPFLAGS="-I${CMAKE_DIR}/include"
export LDFLAGS="-L${CMAKE_DIR}/lib "
${CMAKE} -DCMAKE_INSTALL_PREFIX:PATH="${ARTIFACT}" \
  -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
  -DCMAKE_INSTALL_RPATH:STRING="${ARTIFACT}/lib" \
  -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
  -DCMAKE_BUILD_TYPE:STRING=Release \
  -DCMAKE_PREFIX_PATH="${CMAKE_DIR}" \
  ..
)
${CMAKE} --build . -- -j ${HASHDIST_CPU_COUNT}
make install

First of all, why does cmake get invoked twice?

Second, there seems to be an inconsistency between the setup_builddir build stage and the configure build stage. In setup_builddir I can get rid of the bash handler, and prevent the directory _build from being created. However, then build_in_source in the configure build stage must be set to true as well, otherwise everything breaks.

I think setup_builddir and configure should be merged. If build_in_source is set to true, then create a directory and build from there.

@certik
Copy link
Member

certik commented May 22, 2015

I agree, it should do it automatically, just setting build_in_source: true should be enough.

@chvillanuevap
Copy link
Contributor Author

I may try playing with this. Do you know why it gets invoked twice in the build script?

@certik
Copy link
Member

certik commented May 22, 2015

Yes --- the first time is the configure phase, the second time is the build phase (cmake --build . essentially calls make, unless you configured it to use some other build system). The advantage of this is that cmake then work out of the box with any build system, not just make.

@chvillanuevap
Copy link
Contributor Author

Got it! Thanks a lot for clarifying that. I will try to merge setup_builddir and configure.

@chvillanuevap
Copy link
Contributor Author

I created a pull request here: #790

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants