xref: /freebsd/contrib/libcbor/src/CMakeLists.txt (revision 3332f1b444d4a73238e9f59cca27bfc95fe936bd)
1set(SOURCES cbor.c cbor/streaming.c cbor/internal/encoders.c cbor/internal/builder_callbacks.c cbor/internal/loaders.c cbor/internal/memory_utils.c cbor/internal/stack.c cbor/internal/unicode.c cbor/encoding.c cbor/serialization.c cbor/arrays.c cbor/common.c cbor/floats_ctrls.c cbor/bytestrings.c cbor/callbacks.c cbor/strings.c cbor/maps.c cbor/tags.c cbor/ints.c)
2
3include(GNUInstallDirs)
4set(CMAKE_SKIP_BUILD_RPATH FALSE)
5
6if (CBOR_CUSTOM_ALLOC)
7    LIST(APPEND SOURCES allocators.c)
8endif(CBOR_CUSTOM_ALLOC)
9
10if (NOT DEFINED CMAKE_MACOSX_RPATH)
11	set(CMAKE_MACOSX_RPATH 0)
12endif()
13
14add_library(cbor ${SOURCES})
15target_include_directories(cbor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
16
17include(GenerateExportHeader)
18generate_export_header(cbor EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h)
19target_include_directories(cbor PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
20install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cbor)
21
22if (NOT ${CBOR_VERSION_MAJOR} EQUAL 0)
23	MESSAGE(FATAL_ERROR "Change the shared library version scheme to reflect https://github.com/PJK/libcbor/issues/52.")
24endif()
25
26set_target_properties(cbor PROPERTIES
27		VERSION ${CBOR_VERSION}
28		MACHO_COMPATIBILITY_VERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.0
29		SOVERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR})
30
31configure_file(libcbor.pc.in libcbor.pc @ONLY)
32
33# http://www.cmake.org/Wiki/CMake:Install_Commands
34install(TARGETS cbor
35	ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
36	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
37	RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
38
39install(DIRECTORY cbor DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
40                FILES_MATCHING PATTERN "*.h")
41
42install(FILES cbor.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
43
44install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libcbor.pc"
45	DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig")
46