1set(SOURCES cbor.c allocators.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) 4include(JoinPaths) 5include(CheckFunctionExists) 6set(CMAKE_SKIP_BUILD_RPATH FALSE) 7 8if (NOT DEFINED CMAKE_MACOSX_RPATH) 9 set(CMAKE_MACOSX_RPATH 0) 10endif() 11 12add_library(cbor ${SOURCES}) 13target_include_directories(cbor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 14 15# Explicitly link math.h if necessary 16check_function_exists(ldexp LDEXP_AVAILABLE) 17if (NOT LDEXP_AVAILABLE) 18 target_link_libraries(cbor m) 19endif() 20 21include(GenerateExportHeader) 22generate_export_header(cbor EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h) 23target_include_directories(cbor PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) 24install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cbor) 25 26if (NOT ${CBOR_VERSION_MAJOR} EQUAL 0) 27 MESSAGE(FATAL_ERROR "Change the shared library version scheme to reflect https://github.com/PJK/libcbor/issues/52.") 28endif() 29 30set_target_properties(cbor PROPERTIES 31 VERSION ${CBOR_VERSION} 32 MACHO_COMPATIBILITY_VERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.0 33 SOVERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}) 34 35join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") 36join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") 37configure_file(libcbor.pc.in libcbor.pc @ONLY) 38 39# http://www.cmake.org/Wiki/CMake:Install_Commands 40install(TARGETS cbor 41 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 42 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 43 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 44 45install(DIRECTORY cbor DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 46 FILES_MATCHING PATTERN "*.h") 47 48install(FILES cbor.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 49 50install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libcbor.pc" 51 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 52