In CMake, the `install` command is used to specify how to install targets such as executables, libraries, or archives. The parameters RUNTIME, LIBRARY, and ARCHIVE define how different types of output are installed. Below is an explanation of each type and a simple example to demonstrate their use.
cmake_minimum_required(VERSION 3.10)
project(MyProject)
add_library(my_shared_lib SHARED src/my_shared_lib.cpp)
add_library(my_static_lib STATIC src/my_static_lib.cpp)
add_executable(my_executable src/main.cpp)
install(TARGETS my_shared_lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static)
install(TARGETS my_static_lib
ARCHIVE DESTINATION lib/static)
install(TARGETS my_executable
RUNTIME DESTINATION bin)
This configuration example specifies the installation locations for a shared library, a static library, and an executable. The shared and static libraries are directed to the `lib` and `lib/static` directories, while the executable is installed to the `bin` directory.
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?