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

Allow for better integration of native builds using cmake #556

Closed
trink opened this issue Sep 11, 2014 · 1 comment
Closed

Allow for better integration of native builds using cmake #556

trink opened this issue Sep 11, 2014 · 1 comment
Labels
A-linkage Area: linker issues, dylib, cdylib, shared libraries, so

Comments

@trink
Copy link

trink commented Sep 11, 2014

Desired Use

Something like this would allow complete control of the build using only a cross platform cmake script:
build_unix = ["cmake $CARGO_ROOT", "make"]
bulid_windows = ["cmake -G "MinGW Makefiles" $CARGO_ROOT", "mingw32-make"]

  1. support for platform specific build commands For native builds pass additional build variables in the environment #553
  2. allow the variables to be used in the build command (would need a new $CARGO_ROOT variable)
  3. set the current working directory to the $OUT_DIR when invoking the build commands to contain all cmake build files/directories there

Current Use

I am using cmake to check system dependencies and bootstrap/install the required c libraries but have to do something like the following:

[package]
build = "./build.sh"
...
#!/bin/bash
ROOT=$PWD
cd $OUT_DIR

cmake -DCMAKE_BUILD_TYPE=release $ROOT
CMAKE_RET=$?
if [ $CMAKE_RET -ne 0 ]; then
    exit $CMAKE_RET
fi

make
MAKE_RET=$?
if [ $MAKE_RET -ne 0 ]; then
    exit $MAKE_RET
fi

cp $OUT_DIR/lib/* $OUT_DIR
exit $?
  1. save off the root directory and change into $OUT_DIR
  2. cargo does not expose the profile being built so in this case release is always used For native builds pass additional build variables in the environment #553
  3. cmake will perform the installs for me using $OUT_DIR as the prefix, however this puts my libs in $OUT_DIR/lib (they are managed via externalproject_add so I cannot easily alter the install hierarchy)
  4. manually move the libs into $OUT_DIR because the -L cannot be altered Let Cargo packages modify the state of the build environment for other (non dependent) packages. #95 (comment) (this could also be done by the cmake wrapper script)
@alexcrichton alexcrichton added the A-linkage Area: linker issues, dylib, cdylib, shared libraries, so label Oct 13, 2014
@alexcrichton
Copy link
Member

While not fully implemented in Cargo itself, now that #792 is landed I'm going to close this. Crates can now have build dependencies (in the build-dependencies array) and something like a cmake-friendly crate can grow in the ecosystem over time, making the build script for a package quite small!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linker issues, dylib, cdylib, shared libraries, so
Projects
None yet
Development

No branches or pull requests

2 participants