Clion Add External Library May 2026
vcpkg install sdl2 Then in CMake:
find_package(SDL2 CONFIG REQUIRED) target_link_libraries(my_game PRIVATE SDL2::SDL2) clion add external library
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? vcpkg install sdl2 Then in CMake: find_package(SDL2 CONFIG
find_package(Boost 1.75 REQUIRED COMPONENTS filesystem system) if(Boost_FOUND) target_link_libraries(my_app PRIVATE Boost::filesystem Boost::system) endif() CMake will automatically search standard system paths, or paths you hint via -DCMAKE_PREFIX_PATH . Not every library provides CMake configs. For those, you can use pkg-config (common on Linux): Or point and click in the settings
vcpkg install fmt And use it in CMake like magic:
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.