1 add_definitions("-D_BSD_SOURCE") # for htole32()
3 # Find packages needed to build library
4 find_package(libusb-1.0 REQUIRED)
5 include_directories(${LIBUSB_1_INCLUDE_DIRS})
7 set(SRC am7xxx.c serialize.c)
10 add_library(am7xxx SHARED ${SRC})
11 set_target_properties(am7xxx PROPERTIES
12 VERSION ${PROJECT_VER}
13 SOVERSION ${PROJECT_APIVER})
14 install(TARGETS am7xxx
15 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
17 add_library(am7xxx-static STATIC ${SRC})
18 set_target_properties(am7xxx-static PROPERTIES OUTPUT_NAME am7xxx)
19 if(UNIX AND NOT APPLE)
20 set_target_properties(am7xxx-static PROPERTIES COMPILE_FLAGS "-fPIC")
22 install(TARGETS am7xxx-static
23 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
26 find_library(MATH_LIB m)
28 # not needed on windows
32 target_link_libraries(am7xxx ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
33 target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
35 # Install the header files
36 install(FILES "am7xxx.h"
37 DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
39 if(UNIX AND NOT APPLE)
40 # Produce a pkg-config file for linking against the shared lib
41 configure_file("libam7xxx.pc.in" "libam7xxx.pc" @ONLY)
42 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libam7xxx.pc"
43 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")