Skip to content

Commit

Permalink
Merge pull request #15 from wo80/feature/cmake-install
Browse files Browse the repository at this point in the history
Add cmake install option
  • Loading branch information
cannam authored Mar 18, 2024
2 parents 63e0c3b + 13ef54a commit d7ceb7d
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ if(VAMPSDK_BUILD_EXAMPLE_PLUGINS)
add_library(vamp-example-plugins SHARED ${sources_plugins})
set_target_properties(vamp-example-plugins PROPERTIES PREFIX "") # remove lib* prefix
target_link_libraries(vamp-example-plugins PRIVATE vamp-sdk)
endif()
if(MSVC)
set_target_properties(vamp-example-plugins PROPERTIES LINK_FLAGS /EXPORT:vampGetPluginDescriptor)
else()
if(APPLE)
set_target_properties(vamp-example-plugins PROPERTIES LINK_FLAGS "-exported_symbols_list ${CMAKE_SOURCE_DIR}/vamp-plugin.list")
else()
set_target_properties(vamp-example-plugins PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/vamp-plugin.map")
endif(APPLE)
endif(APPLE)
endif(MSVC)
endif()

# simple host
option(VAMPSDK_BUILD_SIMPLE_HOST "Build simple host" OFF)
Expand All @@ -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 d7ceb7d

Please sign in to comment.