This is part of the linuxcnc
project, I pick these codes out, and make a library
which provides cmake configs for find_package
. This might probably ease the way
we use this interpreter.
Currently I have built this library and the SAI
which is the stand alone
interpreter, and export them to install.
An example to use this library,
See https://github.com/windsgo/rs274-sai-compile-example
Use the Makefile provided.
-
Modify the
boost_root
andinstall_dir
in the Makefile -
Build it
make
- install
make install
- run
sai
test
./test.sh
- configure
You need to set your own variable and prefix in the following command
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${install_dir} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBOOST_ROOT=__YOUR_PREFIX_1__/lib
- build
cmake --build build -j8
- install
cmake --install build
- run test
./test.sh
- When you use this library, define the
EMC2_DEFAULT_TOOLTABLE
while compiling if your src uses this defination. which should be the path ofsim.tbl
relative to the excutable file.
# like this in your CMakeLists.txt, for example the `sai`
target_compile_definitions(sai
PRIVATE
EMC2_DEFAULT_TOOLTABLE="${PROJECT_SOURCE_DIR}/sim.tbl"
)
I have the following code in CMakeLists.txt:
set_target_properties(rs274
INSTALL_RPATH ${Boost_LIBRARY_DIRS}
)
-
What does it do?
Set
INSTALL_RPATH
property to let the INSTALLED library have the search path oflibboost_python27.so
at runtime. -
Why I add this?
When an excutable or another library links to the
INSTALLED TARGET
rs274
dynamically, even though the excutable may link to libboost_python27,librs274.so
need to know where to search forlibboost_python27
itself ! -
To Mention:
This should be done, since
libboost_python27
is often not a system lib higher thanUbuntu20.04
, it needs to be set according to different systems. So this lib is recommanded to compile each time on a new operating system.However, it can also be used if
LD_LIBRARY_PATH
is set proporly or thelibboost_python27
path is included in/etc/ld.so.conf
.I do this just to make runtime easier for compile test.