Clion Add External Library __exclusive__ -

include(FetchContent) FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG master ) FetchContent_MakeAvailable(fmt) target_link_libraries(my_app PRIVATE fmt::fmt)

When you reload CMake in CLion, it will clone fmt , build it, and link it—all automatically.

Example: Adding the popular fmt library: clion add external library

add_library(imported_mylib STATIC IMPORTED) set_target_properties(imported_mylib PROPERTIES IMPORTED_LOCATION "/path/to/libmylib.a" INTERFACE_INCLUDE_DIRECTORIES "/path/to/include" ) target_link_libraries(my_app PRIVATE imported_mylib) Best for: Popular libraries like Boost, OpenCV, Qt, or anything that provides a CMake config file.

By Alex Mitchell | Estimated read time: 8 minutes Do you manually edit CMakeLists

If you’re using , JetBrains’ powerful cross-platform IDE, you have several excellent—and sometimes confusing—options. Do you manually edit CMakeLists.txt ? Use find_package ? Or point and click in the settings?

find_package(PkgConfig REQUIRED) pkg_check_modules(LIBUSB REQUIRED libusb-1.0) target_link_libraries(my_app PRIVATE $LIBUSB_LIBRARIES) target_include_directories(my_app PRIVATE $LIBUSB_INCLUDE_DIRS) Best for: Automatically downloading libraries from GitHub during configuration. it will clone fmt

This is a game-changer. No more manual downloads. CLion will fetch the library directly from Git or HTTP.