Professional Documents
Culture Documents
cmake_minimum_required(VERSION 2.4.6)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
IF(DEFINED BUILD_NO_CLANG)
option(BUILD_NO_CLANG "Do not use the Clang compiler." OFF)
ENDIF(DEFINED BUILD_NO_CLANG)
# Detect ROS
set(ROS_ROOT $ENV{ROS_ROOT})
set(ROS_ROOT_DEFINED FALSE)
if(DEFINED ROS_ROOT)
message("ROS detected.")
set(ROS_ROOT_DEFINED TRUE)
endif(DEFINED ROS_ROOT)
# Set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# Set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
if(BUILD_WITH_ROS)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
set(ROS_BUILD_TYPE RelWithDebInfo CACHE STRING "Built type for ROS")
rosbuild_init()
if(serial_FOUND)
include_directories(${serial_INCLUDE_DIRS})
list(APPEND UBLOX_LINK_LIBS ${serial_LIBRARIES})
if(UNIX AND NOT APPLE)
list(APPEND UBLOX_LINK_LIBS rt)
endif(UNIX AND NOT APPLE)
else(serial_FOUND)
message(FATAL_ERROR "Serial library was not found.")
endif(serial_FOUND)
endif(BUILD_WITH_ROS)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
if(BUILD_WITH_ROS)
rosbuild_add_executable(ublox_node src/ublox_node.cc)
target_link_libraries(ublox_node ublox)
endif(BUILD_WITH_ROS)
## Build Examples
# If asked to
option(UBLOX_BUILD_EXAMPLES "Build uBlox examples?" OFF)
IF(UBLOX_BUILD_EXAMPLES)
# Compile the ublox Test program
add_executable(ublox_example examples/ublox_example.cpp)
# Link the Test program to the ublox library
target_link_libraries(ublox_example ublox ${UBLOX_LINK_LIBS})
# Compile the ublox Test program
add_executable(assist_example examples/assist_example.cpp)
# Link the Test program to the ublox library
target_link_libraries(assist_example ublox ${UBLOX_LINK_LIBS})
# Compile the ublox Test program
add_executable(record_pseudoranges examples/record_pseudoranges.cpp)
# Link the Test program to the ublox library
target_link_libraries(record_pseudoranges ublox ${UBLOX_LINK_LIBS})
ENDIF(UBLOX_BUILD_EXAMPLES)
## Build tests
# If asked to
IF(UBLOX_BUILD_TESTS)
ENDIF(UBLOX_BUILD_TESTS)
INSTALL(TARGETS ublox
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
IF(NOT CMAKE_FIND_INSTALL_PATH)
set(CMAKE_FIND_INSTALL_PATH ${CMAKE_ROOT})
ENDIF(NOT CMAKE_FIND_INSTALL_PATH)
IF (UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "uninstall package"
COMMAND xargs ARGS rm < install_manifest.txt
TARGET uninstall
)
ELSE(UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "uninstall only implemented in unix"
TARGET uninstall
)
ENDIF(UNIX)
ENDIF(NOT UBLOX_DONT_CONFIGURE_INSTALL AND NOT BUILD_WITH_ROS)