am7xxx: add support for Philips/Sagemcom PicoPix 2330
[libam7xxx.git] / src / CMakeLists.txt
1 add_definitions("-D_BSD_SOURCE") # for htole32()
2
3 # Find packages needed to build library
4 find_package(libusb-1.0 REQUIRED)
5 include_directories(${LIBUSB_1_INCLUDE_DIRS})
6
7 set(SRC am7xxx.c serialize.c)
8
9 # Build the library
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")
16
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")
21 endif()
22 install(TARGETS am7xxx-static
23    DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
24
25 if(NOT WIN32)
26   find_library(MATH_LIB m)
27 else()
28   # not needed on windows
29   set(MATH_LIB "")
30 endif()
31
32 target_link_libraries(am7xxx ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
33 target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
34
35 # Install the header files
36 install(FILES "am7xxx.h"
37   DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
38
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")
44 endif()