2 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_CURRENT_SOURCE_DIR}
7 set(SNAPSHOT_VERSION "unknown")
8 execute_process(COMMAND git describe
9 OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT
10 RESULT_VARIABLE GIT_DESCRIBE_RESULT
11 OUTPUT_STRIP_TRAILING_WHITESPACE
13 if (${GIT_DESCRIBE_RESULT} STREQUAL 0)
14 set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT})
16 message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}")
18 configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY)
21 # Disable some overly-verbose warnings activated by -Wall
23 # '<name>': function not inlined
24 add_compile_options(/wd4710)
26 # function '<name>' selected for automatic inline expansion
27 add_compile_options(/wd4711)
29 # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
30 add_compile_options(/wd5045)
32 # '<type>': '4' bytes padding added after data member '<name>'
33 add_compile_options(/wd4820)
35 # conversion from '<type1>' to '<type2>', possible loss of data
36 add_compile_options(/wd4242 /wd4244 /wd4267)
38 # Disable warning on unsafe string functions
39 add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
41 if (MSVC_VERSION GREATER_EQUAL 1913)
42 # Disable warnings from system headers
43 add_compile_options(/external:anglebrackets /external:W0)
48 set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources")
49 set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers")
53 add_library(ftdi1 SHARED ${c_sources})
54 math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases
55 set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2)
56 # Prevent clobbering each other during the build
57 set_target_properties(ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1)
58 target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES})
60 RUNTIME DESTINATION bin
61 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
62 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
68 add_library(ftdi1-static STATIC ${c_sources})
69 target_link_libraries(ftdi1-static ${LIBUSB_LIBRARIES})
70 set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1")
71 set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
72 install(TARGETS ftdi1-static
73 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
78 install(FILES ${c_headers}
79 DESTINATION include/${PROJECT_NAME}