1 add_definitions("-D_DEFAULT_SOURCE") # for htole32()
2 add_definitions("-D_POSIX_C_SOURCE=200112L") # for nanosleep() and lroundf()
4 # Express a preference for C99 format strings when using MinGW, see:
5 # https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/
6 add_definitions("-D__USE_MINGW_ANSI_STDIO=1")
8 # Find packages needed to build library
9 find_package(libusb-1.0 REQUIRED)
10 include_directories(${LIBUSB_1_INCLUDE_DIRS})
12 set(SRC am7xxx.c serialize.c tools.c)
15 add_library(am7xxx SHARED ${SRC})
16 set_target_properties(am7xxx PROPERTIES
17 VERSION ${PROJECT_VER}
18 SOVERSION ${PROJECT_APIVER})
19 install(TARGETS am7xxx
20 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
22 add_library(am7xxx-static STATIC ${SRC})
23 set_target_properties(am7xxx-static PROPERTIES OUTPUT_NAME am7xxx)
24 if(UNIX AND NOT APPLE)
25 set_target_properties(am7xxx-static PROPERTIES COMPILE_FLAGS "-fPIC")
27 install(TARGETS am7xxx-static
28 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
31 find_library(MATH_LIB m)
33 # not needed on windows
37 target_link_libraries(am7xxx ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
38 target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
40 # Install the header files
41 install(FILES "am7xxx.h"
42 DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
44 if(UNIX AND NOT APPLE)
45 # Produce a pkg-config file for linking against the shared lib
46 configure_file("libam7xxx.pc.in" "libam7xxx.pc" @ONLY)
47 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libam7xxx.pc"
48 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")