能否让catkin build取消指定编译器
时间: 2023-05-26 15:04:00 浏览: 61
不太清楚您在使用哪种编译器,但是如果您想使用系统默认的编译器,您可以在您的ROS工作空间根目录(即包含src/的目录)下添加以下CMakeLists.txt文件,并将编译器设置为空:
```
cmake_minimum_required(VERSION 2.8.3)
project(your_project)
# Set C++11 as the default C++ standard
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
# Set the default compiler to use
set(CMAKE_C_COMPILER "" CACHE STRING "C compiler" FORCE)
set(CMAKE_CXX_COMPILER "" CACHE STRING "C++ compiler" FORCE)
# Load the catkin and cmake modules required for building packages
find_package(catkin REQUIRED COMPONENTS
YOUR_REQUIRED_ROS_PACKAGES
)
# Declare your package dependencies
catkin_package(
INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME}_core
CATKIN_DEPENDS
YOUR_DEPENDENCIES
DEPENDS
SYSTEM
)
# Add the include directories for your target libraries
include_directories(
include
${catkin_INCLUDE_DIRS}
)
# Add your source files here
add_library(${PROJECT_NAME}_core
src/your_source.cpp
)
# Link against any other required libraries
target_link_libraries(${PROJECT_NAME}_core
${catkin_LIBRARIES}
)
# Install the library headers
install(
DIRECTORY include/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
)
# Install the library
install(
TARGETS ${PROJECT_NAME}_core
EXPORT ${PROJECT_NAME}_targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# Export the configuration for the package
install(
EXPORT ${PROJECT_NAME}_targets
FILE ${PROJECT_NAME}_targets.cmake
DESTINATION lib/cmake/${PROJECT_NAME}
)
```
请注意,这里假设您已经使用catkin_init_workspace和catkin_make或catkin build创建了ROS工作空间。将上述文件保存为CMakeLists.txt并放在您的ROS工作空间根目录下,然后使用catkin build编译您的ROS软件包时,catkin build将使用系统默认的C和C++编译器。