HACKING.asciidoc: update Windows cross-build section to use libav10
[libam7xxx.git] / src / CMakeLists.txt
1 add_definitions("-D_BSD_SOURCE") # for htole32()
2 add_definitions("-D_POSIX_C_SOURCE=199309L") # for nanosleep()
3
4 # Find packages needed to build library
5 find_package(libusb-1.0 REQUIRED)
6 include_directories(${LIBUSB_1_INCLUDE_DIRS})
7
8 set(SRC am7xxx.c serialize.c tools.c)
9
10 # Build the library
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")
17
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")
22 endif()
23 install(TARGETS am7xxx-static
24    DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
25
26 if(NOT WIN32)
27   find_library(MATH_LIB m)
28 else()
29   # not needed on windows
30   set(MATH_LIB "")
31 endif()
32
33 target_link_libraries(am7xxx ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
34 target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
35
36 # Install the header files
37 install(FILES "am7xxx.h"
38   DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
39
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")
45 endif()