Finding linked library in executableEdit




  • Popular build system backend.
  • Used to for building project with toolchain that isn't supported by autotools or CMake.
  • to override the variable pass "VAR=VALUE" after make command. If you set in before the command it will just override the env variable.
  • GNU make reference


  • repository
  • Small and fast build system like Makefile
  • Can be generated by CMake




  • packager for CMake
  • Using with CMake
  • building target "package" will create the package.


  • Makefile
  • Visual Studio
  • Ninja
  • Xcode

selecting filesEdit

  • Use aux_source_directory() to select all the supported source file
  • Use "file()" function to select particular files
    • GLOB: just wildcard target directory
    • GLOB_RECURSE: wildcard file recursively

Uninstall commandEdit

Using DEdit

Running external program Edit

  • If it wanted to be run in CMakeLists.txt parse time, use execute_process()
    • use OUTPUT_STRIP_TRAILING_WHITESPACE for unwanted newline
  • If you want to have a code generator use add_custom_command()
  • If you want custom command in Makefile use add_custom_target()

Build type Edit

    • DEBUG

Generating File Edit

  • use file() function's WRITE and APPEND.
    • WRITE: like > redirect. clear file and write the passed string.
    • APPEND: like >> redirect. append the passed string to the file.
    • '\n' works as a new line.
  • If you want configuration file like autotools use configure_file()
    • "@VAR@" will be replace by CMake variable "${VAR}"

naming styleEdit

  • use camel case.
  • case
    • function name: lower
    • variable name: upper


  • enabling default variants
    • write variants to "/opt/local/etc/macports/variants.conf"
    • +universal: build universal binary
    • +no_x11: don't use x11
    • +quartz: use quartz as a rendering backend
  • universal binary
    • set "universal_archs" variable to change the architectures
    • ppc, ppc64: deprecated architecture. used in old Mac OS X
    • i386: IA32
    • x86_64: amd64
  • changing compiler
    • add configure.compiler=$CC