📖
Wiki
Back to my personal website
  • Home
  • Equipment and Devices
    • 3D Printer
    • Laser Cutter
    • Motion Capture System
    • Sensors
      • RGB-D Cameras
      • Velodyne LiDAR
      • Zed Camera
      • RealSense D435i
      • IMU
    • eGPU
    • Nvidia AGX Xavier
    • CPU Benchmark
    • Installation Checklist
  • Development
    • Linux
      • Shell
      • GDB
      • Git
      • Tmux
      • Network
      • Tricks
      • Debug FAQ
    • CMake
      • Catkin Tools
      • CMakeLists
      • CMake Variables
      • CMake Commands
      • CMake: find_package()
    • ROS
      • Gazebo
      • wstool
      • roslaunch
      • rosbag
      • multi-threaded spinner
    • ROS2
      • Convert ROS1 bag to ROS2 bag
    • C++
      • C++ 11
      • C++ Examples
      • C++ Debug
      • Factory Method
      • Timing
    • Google Tools
      • GLog
      • GFlags
      • GTest
      • Style Guide
      • Clang Format
    • PCL
      • Point Type
      • Methods
      • Architecture
      • Code Explained
    • Open3D
      • Python API
      • Registration
      • Visualization
      • Tools
    • OpenCV
      • Documentation
      • Modules
    • Other Libraries
      • Eigen
      • Ceres
      • g2o
      • GTSAM
    • Website
  • Algorithm
    • SLAM
      • K-D Tree
      • Octree
      • Bag of Words
      • Distance Measures
      • Coordinate Systems
      • LOAM
      • Iterative Closest Point
      • Generalized ICP
      • Mahalanobis Distance
    • Computer Science
      • Computational Model
      • Sorting
      • Analysis
      • Complexity Classes (P, NP)
      • Divide and Conquer
      • Greedy Algorithm
      • Dynamic Programming
      • Tree
      • Graph
    • Computer Vision
      • Camera Models
      • Distortion
      • Motion Models
      • Shutter
      • Image Sensors
      • Epipolar Geometry
      • Multiple-View Geometry
    • Datasets
      • RGB-D Datasets
      • Point Cloud Datasets
      • LiDAR SLAM Datasets
  • Math
    • Optimization
      • Convex Optimization
      • Descent Methods
    • Probability
      • Moment
      • Covariance Matrix
      • Stochastic Process
    • Topology
      • References
      • Concepts
      • Topological Spaces
      • Representation of Rotations
      • Representation of 3-sphere
    • Algebra
      • Linear Algebra
      • Matrix Factorization
      • Condition Number
      • Matrix Lie Group
    • Differential Geometry
      • Manifold
      • Submanifold
      • Quotient Manifolds
      • Tangent Space
  • Quadrotor
    • PX4 Development
    • Companion Computer
    • Drone Hardware
    • Propeller Lock
    • Debug
  • Favorites
    • Bookmarks
Powered by GitBook
On this page
  • Variables that Provide Information
  • Variables that Change Behavior
  • Variables that Describe the System
  • Variables that Control the Build
  • Variables for Languages

Was this helpful?

  1. Development
  2. CMake

CMake Variables

Variables that Provide Information

  • CMAKE_CURRENT_SOURCE_DIR The path to the source directory currently being processed.

  • CMAKE_CURRENT_BINARY_DIR The path to the binary directory currently being processed.

  • CMAKE_SOURCE_DIR The path to the top level of the source tree.

  • CMAKE_BINARY_DIR The path to the binary directory currently being processed.

    • for an in-source build, this would be the same as CMAKE_SOURCE_DIR

    • for an out-of-source build, this would be at ./build folder

  • PROJECT_SOURCE_DIR Top level source directory for the current project.

  • PROJECT_BINARY_DIR Full path to build directory for project.

  • <PROJECT-NAME>_SOURCE_DIR Top level source directory for the named project.

  • <PROJECT-NAME>_BINARY_DIR Top level binary directory for the named project.

  • PROJECT_VERSION Value given to the VERSION option of the most recent call to the project() command, if any.

  • CMAKE_VERSION

  • CMAKE_COMMAND The full path to the cmake executable.

  • CMAKE_GENERATOR The generator used to build the project.

# ~/catkin_ws/src/example_pkg
message(${CMAKE_CURRENT_SOURCE_DIR})
message(${CMAKE_SOURCE_DIR})
message(${PROJECT_SOURCE_DIR})

# ~/catkin_ws/build/example_pkg
message(${CMAKE_CURRENT_BINARY_DIR})
message(${CMAKE_BINARY_DIR})
message(${PROJECT_BINARY_DIR})

Variables that Change Behavior

  • CMAKE_BUILD_TYPE Specifies the build type on single-configuration generators.

    • Can be set to Debug, Release, RelWithDebInfo, MinSizeRel, ...

  • CMAKE_CONFIGURATION_TYPES Specifies the available build types on multi-config generators.

  • CMAKE_MODULE_PATH List of directories to search for CMake modules.

    • Commands like include() and find_package() search for files in directories listed by this variable before checking the default modules that come with CMake.

  • CMAKE_INSTALL_PREFIX Install directory used by install.

    • If “make install” is invoked or INSTALL is built, this directory is prepended onto all install directories.

    • This variable defaults to /usr/local on UNIX and c:/Program Files on Windows.

CMAKE_XXX_PATH

By default it is empty, it is intended to be set by the project.

  • CMAKE_PREFIX_PATH Path used for searching by FIND_XXX(), with appropriate suffixes added.

    • a.k.a. CATKIN_DEVEL_PREFIX in earlier CMake versions; set to catkin_ws/devel for example.

    • It contains the “base” directories, the FIND_XXX() commands append appropriate subdirectories to the base directories.

      • FIND_PROGRAM() adds /bin to each of the directories in the path,

      • FIND_LIBRARY() appends /lib to each of the directories, and

      • FIND_FILE() and FIND_PATH() append /include.

  • CMAKE_IGNORE_PATH Path to be ignored by FIND_XXX() commands.

    • This is useful in cross-compiled environments where some system directories contain incompatible but possibly linkable libraries.

  • CMAKE_INCLUDE_PATH Path used for searching by FIND_FILE() and FIND_PATH().

  • CMAKE_LIBRARY_PATH Path used for searching by FIND_LIBRARY().

  • CMAKE_PROGRAM_PATH Path used for searching by FIND_PROGRAM().

CMAKE_SYSTEM_XXX_PATH

By default it contains the standard directories for the current system. It is NOT intended to be modified by the project.

  • CMAKE_SYSTEM_IGNORE_PATH

  • CMAKE_SYSTEM_INCLUDE_PATH

  • CMAKE_SYSTEM_LIBRARY_PATH

  • CMAKE_SYSTEM_PREFIX_PATH

  • CMAKE_SYSTEM_PROGRAM_PATH

message("${CMAKE_BUILD_TYPE}")  # add "" to prevent error from empty variable
message("${CMAKE_CONFIGURATION_TYPES}")
message("${CMAKE_MODULE_PATH}")
message("${CMAKE_INSTALL_PREFIX}")

Variables that Describe the System

  • CMAKE_HOST_SYSTEM

  • CMAKE_SYSTEM_NAME

  • UNIX or CMAKE_HOST_UNIX

  • WIN32 or CMAKE_HOST_WIN32

  • MSVC, MSVC_VERSION

  • ENV: Access environment variables.

    • Use the syntax $ENV{VAR} to read environment variable VAR.

    • See also the set() command to set ENV{VAR}.

Variables that Control the Build

  • EXECUTABLE_OUTPUT_PATH

  • LIBRARY_OUTPUT_PATH

  • CMAKE_RUNTIME_OUTPUT_DIRECTORY Where to put all the RUNTIME targets when built.

    • This variable is used to initialize the RUNTIME_OUTPUT_DIRECTORY property on all the targets.

    • See that target property for additional information.

Variables for Languages

  • CMAKE_<LANG>_COMPILER The full path to the compiler for LANG.

    • CMAKE_CXX_COMPILER, CMAKE_C_COMPILER

  • CMAKE_<LANG>_FLAGS Flags for all build types.

    • CMAKE_CXX_FLAGS, CMAKE_C_FLAGS

    • CMAKE_<LANG>_FLAGS_RELEASE Flags for Release build type or configuration.

  • CMAKE_CXX_STANDARD New in version 3.1. Default value for CXX_STANDARD property of targets.

  • CMAKE_CUDA_STANDARDNew in version 3.8. Default value for CUDA_STANDARD property of targets.

PreviousCMakeListsNextCMake Commands

Last updated 3 years ago

Was this helpful?