Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ endforeach()

include(FindPkgConfig)
include(RelativeFileMacro)
include(GNUInstallDirs)

# Make sure CMAKE_INSTALL_LIBDIR is defined for all systems
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
Expand Down Expand Up @@ -373,6 +374,8 @@ set_property(TARGET suscan PROPERTY SOVERSION ${SUSCAN_ABI})
set_property(TARGET suscan PROPERTY COMPILE_FLAGS "${SIGUTILS_SPC_CFLAGS}")
set_property(TARGET suscan PROPERTY LINK_FLAGS "${SIGUTILS_SPC_LDFLAGS}")

set_property(TARGET suscan PROPERTY EXPORT_NAME suscan)

# Required dependencies
if(APPLE)
# Required to retrieve bundle path
Expand All @@ -389,6 +392,11 @@ if(WIN32)
endif()
endif()

target_include_directories(suscan INTERFACE
$<INSTALL_INTERFACE:include>/${CMAKE_PROJECT_NAME}
$<INSTALL_INTERFACE:include>/${CMAKE_PROJECT_NAME}/util
)

target_link_libraries(suscan m ${SIGUTILS_LIBRARIES})

target_include_directories(suscan SYSTEM PUBLIC ${SNDFILE_INCLUDE_DIRS})
Expand Down Expand Up @@ -417,6 +425,24 @@ if(VOLK_FOUND)
link_directories(${VOLK_LIBRARY_DIRS})
endif()

# export module
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(INSTALL_EXPORTS_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})

include(CMakePackageConfigHelpers)

configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/suscanConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/suscanConfig.cmake
INSTALL_DESTINATION ${INSTALL_EXPORTS_DIR}
PATH_VARS INCLUDE_INSTALL_DIR)

write_basic_package_version_file(
${CMAKE_BINARY_DIR}/suscanConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

install(
FILES ${ANALYZER_LIB_HEADERS}
DESTINATION include/suscan/analyzer)
Expand Down Expand Up @@ -457,7 +483,17 @@ install(
FILES src/suscan.h
DESTINATION include/suscan)

install(TARGETS suscan DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/suscanConfig.cmake
${CMAKE_BINARY_DIR}/suscanConfigVersion.cmake
DESTINATION ${INSTALL_EXPORTS_DIR})

install(EXPORT suscan-export
FILE suscanTargets.cmake
NAMESPACE suscan::
DESTINATION ${INSTALL_EXPORTS_DIR})

install(TARGETS suscan EXPORT suscan-export DESTINATION ${CMAKE_INSTALL_LIBDIR})

########################### Suscan test executable ############################
set(SUSCAN_HEADERS ${SRCDIR}/suscan.h)
Expand Down
5 changes: 5 additions & 0 deletions cmake/suscanConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")

check_required_components("@PROJECT_NAME@")
8 changes: 8 additions & 0 deletions doc/test/project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.20.0)
project(suscanTestPrj)

find_package(suscan REQUIRED)

add_executable(suscantest test.c)

target_link_libraries(suscantest suscan::suscan)
14 changes: 14 additions & 0 deletions doc/test/project/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Created by happycactus on 21/06/23.
//
#include <suscan/suscan.h>
#include <suscan/analyzer/version.h>

#include <stdio.h>

int main(int argc, char *argv[])
{
printf("suscan version: %s ABI: %d\n", suscan_api_version(),suscan_abi_version());

return 0;
}