catkin icon indicating copy to clipboard operation
catkin copied to clipboard

Does ros catkin build tool supports the target_compile_options

Open tareq97-zz opened this issue 3 years ago • 3 comments

I am trying to generate the LLVM bitcode for the ROS package. Tried to used the target_compile_options in the CMakeList.txt but it not emitting the llvm bitcode.

Is this option supported or not in the catkin build tool.

Note : Also as per the http://wiki.ros.org/catkin/CMakeLists.txt the option is not supported. Just wanted to confirm regarding this.

tareq97-zz avatar Jul 01 '21 13:07 tareq97-zz

catkin_tools just invokes cmake, so you should be able to do anything that you can do with cmake. catkin (this project) is a helper library that makes some parts of compiling projects easier, but not required.

Rayman avatar Jul 01 '21 13:07 Rayman

Ok the problem is that while building from catkin. It is using /usr/bin/c++ instead of clang++. Below is the cmake file which I am using to emit a llvm bitcode for a small sample ros package called testcrash. @Rayman can you please suggest if I am missing anything.

cmake_minimum_required(VERSION 2.8.3)
project(testcrash)
find_package(catkin REQUIRED roscpp std_msgs)
set(CMAKE_C_COMPILER clang++)
catkin_package()
add_executable(testcrash testcrash.cpp)
target_compile_options(testcrash PUBLIC ${CXXMAKE_CXX_FLAGS} -flto)
target_link_libraries(testcrash ${catkin_LIBRARIES})

tareq97-zz avatar Jul 01 '21 13:07 tareq97-zz

Probably set(CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable"), but these questions are more suitable for https://answers.ros.org/questions/

Rayman avatar Jul 02 '21 11:07 Rayman