📖
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

Was this helpful?

  1. Development
  2. CMake

CMake Commands

CMake Commands

Starting from v3.0, CMake commands are all in lower case SET() --> set()

Common

  • message([<mode>] "message to display" ...)

  • set(<variable> <value> [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])

  • unset(<variable> [CACHE | PARENT_SCOPE])

  • option(<option_variable> "help string describing option" [initial value])

  • export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])

  • install(TARGETS targets... [EXPORT <export-name>] [...])

  • file(WRITE filename "message to write"... ) also READ/APPEND/...

  • list(APPEND <list> [<element> ...]) also LENGTH/FIND/INSERT/REMOVE/SORT...

  • string(REGEX REPLACE <regular_expression> <replace_expression> <output variable> <input> [<input>...])also FIND/COMPARE/LENGTH/TOLOWER...

message("words to user")
message(STATUS ${PROJECT_SOURCE_DIR})  # may be ignored by catkin build
# mode: (none), STATUS, WARNING, AUTHOR_WARNING, SEND_ERROR, FATAL_ERROR, DEPRECATION

set(CMAKE_BUILD_TYPE Release)  # Debug RelWithDebInfo MinSizeRel
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

unset(ENV{LD_LIBRARY_PATH}) # <variable> can be an environment variable

option(BUILD_DOC "Build documentation" ON) 
# can be overwritten by "cmake -DBUILD_DOC=OFF .."

export(TARGETS ${TEASERPP_EXPORTED_TARGETS} FILE teaserpp-exports.cmake)

install(FILES cmake/teaserppConfig.cmake
        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/teaserpp)

file(STRINGS myfile.txt myfile)
# stores a list in the variable “myfile” 
# in which each item is a line from the input file.

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")

Flow Control

  • if(), elseif(), else(), endif()

  • while(), endwhile()

  • foreach(), endforeach()

  • macro(), endmacro()

  • function(), endfunction()

  • break(), return()

  • enable_language(<lang> [OPTIONAL] )

  • enable_testing()

Build Target

  • find_file (<VAR> name1 [path1 path2 ...])

  • find_library (<VAR> name1 [path1 path2 ...])

  • find_package(<package> [version] [EXACT] [QUIET] [MODULE] [REQUIRED] [[COMPONENTS] [components...]] [OPTIONAL_COMPONENTS components...] [NO_POLICY_SCOPE])

  • find_path (<VAR> name1 [path1 path2 ...])

  • find_program (<VAR> name1 [path1 path2 ...])

  • add_compile_options(<option> ...)

  • add_definitions(-DFOO -DBAR ...): Adds -D define flags to the compilation of source files.

  • add_dependencies(<target> [<target-dependency>]...)

  • add_executable(<name> source1 [source2 ...])

  • add_library(<name> [STATIC | SHARED | MODULE] source1 [source2 ...])

  • add_subdirectory()

  • add_test()

  • include_directories() for all build targets

  • target_include_directories() for a specific build target

  • target_link_libraries() link to a specific target

    • Header-only libraries (e.g., Eigen3) are not needed to be linked here.

    • target_link_directories() is not encouraged to use

Build Dependencies

  • configure_file(<input> <output> [...]) Copy a file to another location and modify its contents.

  • execute_process(COMMAND <cmd1> [args1...]] [WORKING_DIRECTORY <directory>] [...])

  • include(<file|module>[...]) Load and run CMake code from a file or module.

cmake_minimum_required(VERSION 3.10)

project(tinyply-download NONE)

include(ExternalProject)
ExternalProject_Add(pmc
        GIT_REPOSITORY    https://github.com/jingnanshi/tinyply.git
        GIT_TAG           0b9fff8e8bd4d37256554fe40cf76b2f3134377b
        SOURCE_DIR        "${CMAKE_CURRENT_BINARY_DIR}/tinyply-src"
        BINARY_DIR        "${CMAKE_CURRENT_BINARY_DIR}/tinyply-build"
        CONFIGURE_COMMAND ""
        BUILD_COMMAND     ""
        INSTALL_COMMAND   ""
        TEST_COMMAND      ""
        )
PreviousCMake VariablesNextCMake: find_package()

Last updated 3 years ago

Was this helpful?