cmake 2

cmake 2

use pkg-config in cmake

example

if($ENV{ROS_DISTRO} STREQUAL jade)
  message(STATUS "ROS_DISTRO is jade")
  find_package(PkgConfig REQUIRED)
  pkg_search_module(eigen3 REQUIRED eigen3)
  message(STATUS "eigen3_INCLUDE_DIRS " ${eigen3_INCLUDE_DIRS})
else()
  find_package(Eigen3 REQUIRED)
  message(STATUS "EIGEN3_INCLUDE_DIRS " ${EIGEN3_INCLUDE_DIRS})
endif()

see also and ref.
https://cmake.org/cmake/help/v3.0/module/FindPkgConfig.html

cmake link directories

example

message(STATUS "catkin_make LD_LIBRARY_PATH " $ENV{LD_LIBRARY_PATH})
link_directories($ENV{LD_LIBRARY_PATH})
set(LIBS
  # ros
  ${catkin_LIBRARIES}
  pcl_ros_tf
  # no ros
  ${PCL_LIBRARIES}
  ${octomap_LIBRARIES}
  boost_system)