15d3e7166SEd Masteset(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) 210ff414cSEd Maste 35d3e7166SEd Masteinclude(JoinPaths) 45d3e7166SEd Masteinclude(CheckFunctionExists) 510ff414cSEd Masteset(CMAKE_SKIP_BUILD_RPATH FALSE) 610ff414cSEd Maste 710ff414cSEd Masteif (NOT DEFINED CMAKE_MACOSX_RPATH) 810ff414cSEd Maste set(CMAKE_MACOSX_RPATH 0) 910ff414cSEd Masteendif() 1010ff414cSEd Maste 1110ff414cSEd Masteadd_library(cbor ${SOURCES}) 1210ff414cSEd Mastetarget_include_directories(cbor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 1310ff414cSEd Maste 145d3e7166SEd Maste# Explicitly link math.h if necessary 155d3e7166SEd Mastecheck_function_exists(ldexp LDEXP_AVAILABLE) 165d3e7166SEd Masteif (NOT LDEXP_AVAILABLE) 175d3e7166SEd Maste target_link_libraries(cbor m) 185d3e7166SEd Masteendif() 195d3e7166SEd Maste 2010ff414cSEd Masteinclude(GenerateExportHeader) 2110ff414cSEd Mastegenerate_export_header(cbor EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h) 2210ff414cSEd Mastetarget_include_directories(cbor PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) 2310ff414cSEd Masteinstall(FILES ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cbor) 2410ff414cSEd Maste 2510ff414cSEd Masteif (NOT ${CBOR_VERSION_MAJOR} EQUAL 0) 2610ff414cSEd Maste MESSAGE(FATAL_ERROR "Change the shared library version scheme to reflect https://github.com/PJK/libcbor/issues/52.") 2710ff414cSEd Masteendif() 2810ff414cSEd Maste 2910ff414cSEd Masteset_target_properties(cbor PROPERTIES 3010ff414cSEd Maste VERSION ${CBOR_VERSION} 3110ff414cSEd Maste MACHO_COMPATIBILITY_VERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.0 3210ff414cSEd Maste SOVERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}) 3310ff414cSEd Maste 345d3e7166SEd Mastejoin_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") 355d3e7166SEd Mastejoin_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") 3610ff414cSEd Masteconfigure_file(libcbor.pc.in libcbor.pc @ONLY) 3710ff414cSEd Maste 3810ff414cSEd Maste# http://www.cmake.org/Wiki/CMake:Install_Commands 3910ff414cSEd Masteinstall(TARGETS cbor 4010ff414cSEd Maste ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 4110ff414cSEd Maste LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 4210ff414cSEd Maste RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 4310ff414cSEd Maste 4410ff414cSEd Masteinstall(DIRECTORY cbor DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 4510ff414cSEd Maste FILES_MATCHING PATTERN "*.h") 4610ff414cSEd Maste 4710ff414cSEd Masteinstall(FILES cbor.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 4810ff414cSEd Maste 4910ff414cSEd Masteinstall(FILES "${CMAKE_CURRENT_BINARY_DIR}/libcbor.pc" 505d3e7166SEd Maste DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 51*abd87254SEd Maste 52*abd87254SEd Masteinclude(CMakePackageConfigHelpers) 53*abd87254SEd Masteconfigure_package_config_file( 54*abd87254SEd Maste libcborConfig.cmake.in 55*abd87254SEd Maste ${CMAKE_CURRENT_BINARY_DIR}/libcborConfig.cmake 56*abd87254SEd Maste INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libcbor 57*abd87254SEd Maste PATH_VARS CMAKE_INSTALL_INCLUDEDIR 58*abd87254SEd Maste) 59*abd87254SEd Mastewrite_basic_package_version_file( 60*abd87254SEd Maste ${CMAKE_CURRENT_BINARY_DIR}/libcborConfigVersion.cmake 61*abd87254SEd Maste VERSION ${CBOR_VERSION} 62*abd87254SEd Maste COMPATIBILITY SameMajorVersion 63*abd87254SEd Maste) 64*abd87254SEd Masteinstall( 65*abd87254SEd Maste FILES 66*abd87254SEd Maste ${CMAKE_CURRENT_BINARY_DIR}/libcborConfig.cmake 67*abd87254SEd Maste ${CMAKE_CURRENT_BINARY_DIR}/libcborConfigVersion.cmake 68*abd87254SEd Maste DESTINATION 69*abd87254SEd Maste ${CMAKE_INSTALL_LIBDIR}/cmake/libcbor 70*abd87254SEd Maste ) 71