Last active
September 18, 2022 16:49
-
-
Save bjoernsauer/85308853c50bcef4f1ee362633e219a8 to your computer and use it in GitHub Desktop.
CMake install with Configuration Directory CMake. Shows how to use the install() command to install into a directory that includes the current configuration type as subfolder. For Example lib/MyLibrary/Release or lib/MyLibrary/Debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project(cmake-install) | |
cmake_minimum_required(VERSION 3.12) | |
add_library(MyLibrary main.cpp) | |
target_include_directories(MyLibrary | |
PRIVATE | |
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> | |
PUBLIC | |
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | |
$<INSTALL_INTERFACE:include>) | |
include(GNUInstallDirs) | |
install(TARGETS MyLibrary | |
EXPORT MyLibraryExports | |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/MyLibrary/$<CONFIG> | |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/MyLibrary/$<CONFIG> | |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/MyLibrary/$<CONFIG>) | |
install(EXPORT MyLibraryExports DESTINATION lib/MyLibrary/cmake) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment