1 add_definitions("-D_DEFAULT_SOURCE") # for htole32()
2 add_definitions("-D_POSIX_C_SOURCE=200112L") # for nanosleep() and lroundf()
4 # Find packages needed to build library
5 find_package(libusb-1.0 REQUIRED)
6 include_directories(${LIBUSB_1_INCLUDE_DIRS})
8 set(SRC am7xxx.c serialize.c tools.c)
11 add_library(am7xxx SHARED ${SRC})
12 set_target_properties(am7xxx PROPERTIES
13 VERSION ${PROJECT_VER}
14 SOVERSION ${PROJECT_APIVER})
15 install(TARGETS am7xxx
16 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
18 add_library(am7xxx-static STATIC ${SRC})
19 set_target_properties(am7xxx-static PROPERTIES OUTPUT_NAME am7xxx)
20 if(UNIX AND NOT APPLE)
21 set_target_properties(am7xxx-static PROPERTIES COMPILE_FLAGS "-fPIC")
23 install(TARGETS am7xxx-static
24 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
27 find_library(MATH_LIB m)
29 # not needed on windows
33 target_link_libraries(am7xxx ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
34 target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
36 # Install the header files
37 install(FILES "am7xxx.h"
38 DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
40 if(UNIX AND NOT APPLE)
41 # Produce a pkg-config file for linking against the shared lib
42 configure_file("libam7xxx.pc.in" "libam7xxx.pc" @ONLY)
43 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libam7xxx.pc"
44 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")