Skip to content

Instantly share code, notes, and snippets.

@JohnCoconut
Last active April 1, 2020 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnCoconut/f5f4377d7b8768567c5dcc190e20be63 to your computer and use it in GitHub Desktop.
Save JohnCoconut/f5f4377d7b8768567c5dcc190e20be63 to your computer and use it in GitHub Desktop.
cmake cheat sheet

add compile options

if (MSVC)
    # warning level 4 and all warnings as errors
    add_compile_options(/W4 /WX)
else()
    # lots of warnings and all warnings as errors
    add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()

target compile features

target_compile_features(mylib PRIVATE cxx_constexpr)
target_compile_features(mylib PUBLIC cxx_std_11)

pkg-config

find_package(PkgConfig)
pkg_check_modules(GTKMM3 REQUIRED gtkmm-3.0)

add_executable(app main.cpp)
target_include_directories(app PRIVATE ${GTKMM3_INCLUDE_DIRS})
target_link_libraries(app ${GTKMM3_LIBRARIES})

sanitizer

 target_link_options(app PRIVATE -fsanitize=address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment