Skip to content

Commit

Permalink
Added FindGflags directly to this repo
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcoleman committed Dec 5, 2015
1 parent 81bd51c commit e3332ee
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Expand Up @@ -2,9 +2,10 @@ cmake_minimum_required(VERSION 2.8.3)
project(ros_control_boilerplate)

# C++ 11
#set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}")

find_package(catkin REQUIRED COMPONENTS
cmake_modules
hardware_interface
controller_manager
roscpp
Expand All @@ -16,9 +17,9 @@ find_package(catkin REQUIRED COMPONENTS
transmission_interface
control_toolbox
std_msgs
cmake_modules
)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(Gflags REQUIRED)

## System dependencies are found with CMake's conventions
Expand Down
52 changes: 52 additions & 0 deletions cmake/FindGflags.cmake
@@ -0,0 +1,52 @@
###############################################################################
#
# CMake script for finding the GFlags library.
#
# https://gflags.github.io/gflags/
#
# Redistribution and use is allowed according to the terms of the 3-clause BSD
# license.
#
# Input variables:
#
# - Gflags_FIND_REQUIRED: throws an error if gflags is not found but it is required
#
# Output variables:
#
# - Gflags_FOUND: Boolean that indicates if the package was found
# - Gflags_LIBRARIES: Package libraries
# - Gflags_INCLUDE_DIRS: Absolute path to package headers
#
# Example usage:
#
# find_package(Gflags REQUIRED)
#
# include_directories(
# ${Gflags_INCLUDE_DIRS}
# )
#
# add_executable(main src/main.cpp)
# target_link_libraries(main
# ${Gflags_LIBRARIES}
# )
###############################################################################


find_path(Gflags_INCLUDE_PATH gflags/gflags.h)

find_library(Gflags_LIBRARY NAMES gflags libgflags)

if(Gflags_INCLUDE_PATH AND Gflags_LIBRARY)
set(Gflags_FOUND TRUE)
endif(Gflags_INCLUDE_PATH AND Gflags_LIBRARY)

if(Gflags_FOUND)
message(STATUS "Found gflags: ${Gflags_LIBRARY}")
# Output variables
set(Gflags_INCLUDE_DIRS ${Gflags_INCLUDE_DIR})
set(Gflags_LIBRARIES ${Gflags_LIBRARY})
else(Gflags_FOUND)
if(Gflags_FIND_REQUIRED)
message(FATAL_ERROR "Could not find gflags library.")
endif(Gflags_FIND_REQUIRED)
endif(Gflags_FOUND)

0 comments on commit e3332ee

Please sign in to comment.