ros2 / rmw_dps

Implementation of the ROS Middleware (rmw) Interface using Intel's Distributed Publish & Subscribe.
Apache License 2.0
23 stars 8 forks source link

Pass CMake compiler and flags to DPS library. #33

Closed malsbat closed 5 years ago

malsbat commented 5 years ago

Signed-off-by: Todd Malsbary todd.malsbary@intel.com

malsbat commented 5 years ago

@alsora, this should complete the work needed for issue #8.

alsora commented 5 years ago

Hi @malsbat thanks for the update.

I just tested this branch.

It works if in the toolchainfile.cmake no flags are set. In this case I correctly get a cross-compiled DPS library.

However, if I have flags I get errors. I think that the problem is due to how the flags are parsed in the SConstruct file. From what I have seen, the problem is only with the CFLAGS (I think that the CXXFLAGS are just ignored).

This is my usual cross-compilation CFLAGS

set(CMAKE_C_FLAGS "$ENV{CMAKE_C_FLAGS} $ENV{TARGET_C_FLAGS}" CACHE STRING "" FORCE)

Where

export CMAKE_C_FLAGS=""
export TARGET_C_FLAGS="-mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -w -O2 -Wl,-rpath-link=/root/ws/install/lib"

This results in this error

stderr: dps_for_iot_cmake_module
arm-linux-gnueabihf-gcc-6: error: -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -w -O2 -Wl,-rpath-link=/root/ws/install/lib: No such file or directory scons: [build/obj/doc/tutorial/tutorial.o] Error 1 make[2]: [dps_for_iot/src/dps_for_iot-stamp/dps_for_iot-build] Error 2 make[1]: [CMakeFiles/dps_for_iot.dir/all] Error 2 make: [all] Error 2

If I change the env variables:

export CMAKE_C_FLAGS=""
export TARGET_C_FLAGS="-mcpu=cortex-a7"

I get

arm-linux-gnueabihf-gcc-6: error: -mcpu=cortex-a7: No such file or directory

And lastly

export CMAKE_C_FLAGS=""
export TARGET_C_FLAGS=""

arm-linux-gnueabihf-gcc-6: error: : No such file or directory

Note how also the last example does not work due to the whitespace between the two empty environment variables.

The only thing that works is

set(CMAKE_C_FLAGS "")
malsbat commented 5 years ago

@alsora, thanks for trying this out. Travis appears stuck at the moment, but https://github.com/intel/dps-for-iot/pull/108 should fix your issue with the flags.

The CXXFLAGS appears to be ignored because it only affects the dps-for-iot bindings, which rmw_dps does not build.

alsora commented 5 years ago

Tested with https://github.com/intel/dps-for-iot/pull/108 and it works perfectly now!