symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.41k stars 145 forks source link

Building and installing w/ `python3 -m pip install .` does not install slam headers and libraries. #323

Open arbor-arthur opened 1 year ago

arbor-arthur commented 1 year ago

Describe the bug After installing symforce with python3 -m pip install ., my C++ program has an error using #include <symforce/slam/imu_preintegration/imu_factor.h> because the slam subdirectory is not installed. Libraries are also missing.

To Reproduce Clone the symforce repository, cd into it, and run python3 -m pip install . to install. On my computer this installs headers into /Library/Frameworks/Python.framework/Versions/3.9/include and libraries into /Library/Frameworks/Python.framework/Versions/3.9/lib/.

Make a file test.cc

#include <symforce/slam/imu_preintegration/imu_factor.h>
int main() {
    return 0;
}

Try building the test program with the flags that have otherwise worked for me.

clang test.cc -std=c++17 -DSPDLOG_FMT_EXTERNAL=1 -I/usr/local/include/eigen3 -I/Library/Frameworks/Python.framework/Versions/3.9/include
test.cc:1:10: fatal error: 'symforce/slam/imu_preintegration/imu_factor.h' file not found

I was able to fix this issue by adding the following lines to symforce/slam/CMakeLists.txt:

# ------------------------------------------------------------------------------
# install

install(TARGETS symforce_slam DESTINATION lib)
install(DIRECTORY ./ DESTINATION include/symforce/slam FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")

Expected behavior All standard Symforce libraries and headers should be installed when running a build/install command.

Environment (please complete the following information):

Additional context cmake version 3.26.3

chao-qu-skydio commented 1 year ago

This is also fixed in the current master. We might put out a new release that addresses all these issues.