As a continuation of my other article incorporating CMake as a makefile generator, here are some references I used for getting a handle on how to build a set of CMakeLists.txt files to manage a project containing a library shared by two applications.
- Tutorial: Managing Compiler Warnings with CMake - But how do you manage the very compiler-specific flags in CMake? How do you prevent your header files from leaking warnings into other projects?
- cmake.org tutorial
- Reference Guide - direct from cmake.org
- CMake Community Wiki
- wxWiki - using CMake to include wxWidgets in projects - see below for sample
- stack overflow - Questions tagged [cmake] - the popular entries
- stack overflow - Multiple sub-projects depending on the same library - primary source for skeleton entries for a project with inter-dependent apps and libraries.
- stack overflow - CMake: Static library with multiple projects - Normally, when CMake projects have to cooperate, it's beneficial to make them part of the same buildsystem using add_subdirectory(). That way, CMake can track dependency between their targets, automatically resolve references to logical target names etc.
- Typical Linux Project using CMake - goes into detail for a project with libraries and applications, including external dependencis
- CMake Dependencies Done Right - mechanisms to evolve a CMake file - depend on defining a proper dependency tree for all libraries and executables
- stack overflow - CMake: Project structure with unit tests
- Basic CMake C++ project structure - includes an example of ExternalProject_Add - also with style notes in one of the answers
- stack overflow - CMake Setting up Release and Debug version and Flags 'cmake -DCMAKE_BUILD_TYPE=Release .. ', 'cmake -DCMAKE_BUILD_TYPE=Debug .. '
- How to configure a C/C++ project with Eclipse and CMake - manual mechanism when not using the wizard from the gui - talks about debug/release versions - something which isn't intuitively obvious when using the gui wizard for importing a CMake progject
- It's Time To Do CMake Right - Pablo Arias - Build Requirements vs Usage Requirements - defines public, private, interface plus additional concepts
- Mirko Kiefer's Blog - CMake by Example - a few twists on the simple CMake files with a focus on the 'install' concept
- CMake Examples on github. There is something to be learned from each example [added 2019/0917]
- CMake – Properties and Options - conditionals - which shares an example with CMAKE compile options
- dendisuhubdy / libtorch_examples - has an example of how to use custom commands [could be used with my libs-build]
- 2020/02/25 CMake is not a build system - brief walk through of key features.
- 2021/05/23 Effective Modern CMake - many 'thou shalts', but few examples on what it means, other than that, effective starting point on the research journey
wxWidgets inclusion with CMake
project(myGreatProject) cmake_minimum_required(VERSION 2.aux_source_directory(. SRC_LIST) set(wxWidgets_CONFIGURATION mswu) find_package(wxWidgets COMPONENTS core base REQUIRED) include(${wxWidgets_USE_FILE}) add_executable(${PROJECT_NAME} ${SRC_LIST}) target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})
Random note:
${CMAKE_SOURCE_DIR}, ${CMAKE_BINARY_DIR}
Generator for ninja:
cmake -G Ninja.