1 add_definitions("-D_BSD_SOURCE") # for htole32()
2 add_definitions("-D_POSIX_C_SOURCE=2") # for getopt()
4 # Find packages needed to build library
5 find_package(libusb-1.0 REQUIRED)
6 include_directories(${LIBUSB_1_INCLUDE_DIRS})
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")
26 target_link_libraries(am7xxx ${LIBUSB_1_LIBRARIES})
27 target_link_libraries(am7xxx-static ${LIBUSB_1_LIBRARIES})
29 # Install the header files
30 install(FILES "am7xxx.h"
31 DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
33 if(UNIX AND NOT APPLE)
34 # Produce a pkg-config file for linking against the shared lib
35 configure_file ("libam7xxx.pc.in" "libam7xxx.pc" @ONLY)
36 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libam7xxx.pc"
37 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
41 add_executable(picoproj picoproj.c)
42 target_link_libraries(picoproj am7xxx)
43 install(TARGETS picoproj
44 DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")