In addition to the accepted answer: An important detail is to place target_link_libraries
after the add_executable
and find_package
lines, so all linked components are known.
More Related Contents:
- What is the proper way to use `pkg-config` from `cmake`?
- Using CMake with GNU Make: How can I see the exact commands?
- Looking for a ‘cmake clean’ command to clear up CMake output
- How to modify environment variables passed to custom CMake target?
- Compile with /MT instead of /MD using CMake
- Copy file from source directory to binary directory using CMake
- Find package Eigen3 for CMake
- CMake share library with multiple executables
- Listing include_directories in CMake
- Recursive list of LINK_LIBRARIES in CMake
- CMake – linking to library downloaded from ExternalProject_add()
- Building a tool immediately so it can be used later in same CMake run
- How to instruct CMake to use the build architecture compiler
- What is a CMake generator?
- Add Source in a subdirectory to a cmake project
- Correct way to use third-party libraries in cmake project
- CMake compare to empty string with STREQUAL failed
- How to detect if current scope has a parent in CMake?
- CMake how to set the build directory to be different than source directory
- How to always run command when building regardless of any dependency?
- how to add prebuilt object files to executable in cmake
- How to run ctest after building my project with cmake
- How do I include a literal double quote in a custom CMake command?
- Check CMake Cache Variable in Toolchain File
- How to tell CMake to use relative paths
- Postpone making custom target until install
- Specifying build directory within CMakeLists file
- How to list all CMake build options and their default values?
- Passing an argument to CMAKE via command prompt
- CMake: how to change compiler for individual target