Skip to content

Allow for better integration of native builds using cmake #556

@trink

Description

@trink

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linker issues, dylib, cdylib, shared libraries, so

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions