Skip to content

Commit

Permalink
CMake: add install option.
Browse files Browse the repository at this point in the history
  • Loading branch information
wo80 committed Mar 17, 2024
1 parent e99e7d5 commit 13ef54a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,46 @@ if(VAMPSDK_BUILD_SIMPLE_HOST)
target_link_libraries(vamp-simple-host PRIVATE vamp-hostsdk ${LIBSNDFILE_LIBRARY})
target_include_directories(vamp-simple-host PRIVATE ${LIBSNDFILE_INCLUDE_DIR})
endif()

# install

option(VAMPSDK_ENABLE_INSTALL "Enable to add install directives" ON)

if(VAMPSDK_ENABLE_INSTALL)
include(GNUInstallDirs)

install(TARGETS vamp-sdk vamp-hostsdk EXPORT VampSdkTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

file (GLOB VAMP_HEADERS "vamp/*.h")
install (FILES ${VAMP_HEADERS} DESTINATION include/vamp)

file (GLOB VAMP_SDK_HEADERS "vamp-sdk/*.h")
install (FILES ${VAMP_SDK_HEADERS} DESTINATION include/vamp-sdk)

file (GLOB VAMP_HOSTSDK_HEADERS "vamp-hostsdk/*.h")
install (FILES ${VAMP_HOSTSDK_HEADERS} DESTINATION include/vamp-hostsdk)

# The following code for installing the pc files could be simplified
# in case support for native configure/make was dropped.

macro(configure_pc_file file)
file(READ "pkgconfig/${file}.in" FILE_CONTENT)
string(REPLACE "%PREFIX%" "@prefix@" FILE_CONTENT "${FILE_CONTENT}" )
file(WRITE "${CMAKE_BINARY_DIR}/${file}.in" "${FILE_CONTENT}")
configure_file("${CMAKE_BINARY_DIR}/${file}.in" ${file} @ONLY)
endmacro()

set(prefix ${CMAKE_INSTALL_PREFIX})
configure_pc_file(vamp.pc)
configure_pc_file(vamp-sdk.pc)
configure_pc_file(vamp-hostsdk.pc)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/vamp.pc
${CMAKE_CURRENT_BINARY_DIR}/vamp-sdk.pc
${CMAKE_CURRENT_BINARY_DIR}/vamp-hostsdk.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()

0 comments on commit 13ef54a

Please sign in to comment.