| 1 |
# Includes |
| 2 |
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} |
| 3 |
${CMAKE_CURRENT_SOURCE_DIR} |
| 4 |
) |
| 5 |
|
| 6 |
# Version information |
| 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 |
| 12 |
) |
| 13 |
if (${GIT_DESCRIBE_RESULT} STREQUAL 0) |
| 14 |
set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) |
| 15 |
endif () |
| 16 |
message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}") |
| 17 |
|
| 18 |
configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY) |
| 19 |
|
| 20 |
if (MSVC) |
| 21 |
# Disable some overly-verbose warnings activated by -Wall |
| 22 |
|
| 23 |
# '<name>': function not inlined |
| 24 |
add_compile_options(/wd4710) |
| 25 |
|
| 26 |
# function '<name>' selected for automatic inline expansion |
| 27 |
add_compile_options(/wd4711) |
| 28 |
|
| 29 |
# Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified |
| 30 |
add_compile_options(/wd5045) |
| 31 |
|
| 32 |
# '<type>': '4' bytes padding added after data member '<name>' |
| 33 |
add_compile_options(/wd4820) |
| 34 |
|
| 35 |
# conversion from '<type1>' to '<type2>', possible loss of data |
| 36 |
add_compile_options(/wd4242 /wd4244 /wd4267) |
| 37 |
|
| 38 |
# Disable warning on unsafe string functions |
| 39 |
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) |
| 40 |
|
| 41 |
if (MSVC_VERSION GREATER_EQUAL 1913) |
| 42 |
# Disable warnings from system headers |
| 43 |
add_compile_options(/external:anglebrackets /external:W0) |
| 44 |
endif () |
| 45 |
endif () |
| 46 |
|
| 47 |
# Targets |
| 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") |
| 50 |
|
| 51 |
# Shared library |
| 52 |
if (SHAREDLIBS) |
| 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}) |
| 59 |
install(TARGETS ftdi1 |
| 60 |
RUNTIME DESTINATION bin |
| 61 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 62 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 63 |
) |
| 64 |
endif () |
| 65 |
|
| 66 |
# Static library |
| 67 |
if (STATICLIBS) |
| 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} |
| 74 |
COMPONENT staticlibs |
| 75 |
) |
| 76 |
endif () |
| 77 |
|
| 78 |
install(FILES ${c_headers} |
| 79 |
DESTINATION include/${PROJECT_NAME} |
| 80 |
COMPONENT headers |
| 81 |
) |