From: Shawn Hoffman <godisgovernm...@gmail.com> --- CMakeLists.txt | 228 +++++++++++++------------- doc/CMakeLists.txt | 2 +- examples/CMakeLists.txt | 8 +- examples/cmake_example/CMakeLists.txt | 14 +- ftdi_eeprom/CMakeLists.txt | 48 +++--- ftdipp/CMakeLists.txt | 30 ++-- packages/CMakeLists.txt | 16 +- python/CMakeLists.txt | 106 ++++++------ python/examples/CMakeLists.txt | 6 +- src/CMakeLists.txt | 46 +++--- 10 files changed, 257 insertions(+), 247 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ce1ad4..67ddb4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,9 @@ endif() # CMake if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE RelWithDebInfo) + set(CMAKE_BUILD_TYPE RelWithDebInfo) endif("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_COLOR_MAKEFILE ON) add_definitions(-Wall) @@ -40,17 +41,18 @@ include(CMakeOptions.txt) # Debug build message("-- Build type: ${CMAKE_BUILD_TYPE}") + if(${CMAKE_BUILD_TYPE} STREQUAL Debug) add_definitions(-DDEBUG) endif(${CMAKE_BUILD_TYPE} STREQUAL Debug) # Find libusb -find_package ( LibUSB REQUIRED ) -include_directories ( ${LIBUSB_INCLUDE_DIR} ) +find_package(LibUSB REQUIRED) +include_directories(${LIBUSB_INCLUDE_DIR}) # Find Boost -if (FTDIPP OR BUILD_TESTS) - find_package( Boost REQUIRED ) +if(FTDIPP OR BUILD_TESTS) + find_package(Boost REQUIRED) endif() # Set components @@ -59,28 +61,25 @@ set(CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries") set(CPACK_COMPONENT_STATICLIBS_DISPLAY_NAME "Static libraries") set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") -set(CPACK_COMPONENT_SHAREDLIBS_DESCRIPTION -"Shared library for general use.") -set(CPACK_COMPONENT_STATICLIBS_DESCRIPTION -"Static library, good if you want to embed libftdi1 in your application.") -set(CPACK_COMPONENT_HEADERS_DESCRIPTION -"C/C++ header files.") +set(CPACK_COMPONENT_SHAREDLIBS_DESCRIPTION "Shared library for general use.") +set(CPACK_COMPONENT_STATICLIBS_DESCRIPTION "Static library, good if you want to embed libftdi1 in your application.") +set(CPACK_COMPONENT_HEADERS_DESCRIPTION "C/C++ header files.") set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development") set(CPACK_COMPONENT_STATICLIBS_GROUP "Development") -set(CPACK_COMPONENT_HEADERS_GROUP "Development") +set(CPACK_COMPONENT_HEADERS_GROUP "Development") # guess LIB_SUFFIX, don't take debian multiarch into account -if ( NOT DEFINED LIB_SUFFIX ) - if( CMAKE_SYSTEM_NAME MATCHES "Linux" - AND NOT CMAKE_CROSSCOMPILING - AND NOT EXISTS "/etc/debian_version" - AND NOT EXISTS "/etc/arch-release" ) - if ( "${CMAKE_SIZEOF_VOID_P}" EQUAL "8" ) - set ( LIB_SUFFIX 64 ) - endif () - endif () -endif () +if(NOT DEFINED LIB_SUFFIX) + if(CMAKE_SYSTEM_NAME MATCHES "Linux" + AND NOT CMAKE_CROSSCOMPILING + AND NOT EXISTS "/etc/debian_version" + AND NOT EXISTS "/etc/arch-release") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(LIB_SUFFIX 64) + endif() + endif() +endif() if(NOT APPLE) if(CMAKE_SIZEOF_VOID_P EQUAL 4) @@ -93,157 +92,160 @@ else(NOT APPLE) endif(NOT APPLE) # Package information -set(CPACK_PACKAGE_VERSION ${VERSION_STRING}) -set(CPACK_PACKAGE_CONTACT "Intra2net AG <libftdi@developer.intra2net.com>") -set(CPACK_PACKAGE_DESCRIPTION "libftdi1 library.") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION}) +set(CPACK_PACKAGE_VERSION ${VERSION_STRING}) +set(CPACK_PACKAGE_CONTACT "Intra2net AG <libftdi@developer.intra2net.com>") +set(CPACK_PACKAGE_DESCRIPTION "libftdi1 library.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION}) # Package settings -if ( UNIX ) - set(CPACK_GENERATOR "DEB;RPM") - set(CPACK_CMAKE_GENERATOR "Unix Makefiles") - set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) - set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PACK_ARCH}) -endif () - -if ( WIN32 ) - set ( CPACK_GENERATOR "NSIS" ) - set ( CPACK_CMAKE_GENERATOR "MinGW Makefiles" ) - set ( CPACK_PACKAGE_NAME "${PROJECT_NAME}" ) - set ( CPACK_PACKAGE_VENDOR "" ) - set ( CPACK_PACKAGE_INSTALL_DIRECTORY "libftdi1" ) - set ( CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32") - set ( CPACK_NSIS_DISPLAY_NAME "libftdi1" ) - set ( CPACK_NSIS_MODIFY_PATH ON ) -endif () - -set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) - -set(CPACK_SOURCE_GENERATOR TGZ) -set(CPACK_SOURCE_IGNORE_FILES "\\\\.git;~$;build/") -set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}) +if(UNIX) + set(CPACK_GENERATOR "DEB;RPM") + set(CPACK_CMAKE_GENERATOR "Unix Makefiles") + set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) + set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PACK_ARCH}) +endif() + +if(WIN32) + set(CPACK_GENERATOR "NSIS") + set(CPACK_CMAKE_GENERATOR "MinGW Makefiles") + set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") + set(CPACK_PACKAGE_VENDOR "") + set(CPACK_PACKAGE_INSTALL_DIRECTORY "libftdi1") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32") + set(CPACK_NSIS_DISPLAY_NAME "libftdi1") + set(CPACK_NSIS_MODIFY_PATH ON) +endif() + +set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) + +set(CPACK_SOURCE_GENERATOR TGZ) +set(CPACK_SOURCE_IGNORE_FILES "\\\\.git;~$;build/") +set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}) # Subdirectories -if ( UNIX ) - set ( CPACK_SET_DESTDIR ON ) -endif () +if(UNIX) + set(CPACK_SET_DESTDIR ON) +endif() # "make dist" target set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${VERSION_STRING}) add_custom_target(dist - COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD - | bzip2 > ${PROJECT_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD + | bzip2 > ${PROJECT_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(src) add_subdirectory(packages) -if ( DOCUMENTATION ) +if(DOCUMENTATION) add_subdirectory(doc) -endif ( DOCUMENTATION ) +endif(DOCUMENTATION) -if ( FTDIPP ) +if(FTDIPP) project(libftdi1 C CXX) add_subdirectory(ftdipp) -endif ( FTDIPP ) +endif(FTDIPP) -if ( PYTHON_BINDINGS ) +if(PYTHON_BINDINGS) add_subdirectory(python) -endif ( PYTHON_BINDINGS ) +endif(PYTHON_BINDINGS) -if ( FTDI_EEPROM ) +if(FTDI_EEPROM) add_subdirectory(ftdi_eeprom) -endif ( FTDI_EEPROM ) +endif(FTDI_EEPROM) -if ( EXAMPLES ) +if(EXAMPLES) add_subdirectory(examples) -endif ( EXAMPLES ) +endif(EXAMPLES) -if ( BUILD_TESTS ) +if(BUILD_TESTS) project(libftdi1 C CXX) add_subdirectory(test) -endif ( BUILD_TESTS ) +endif(BUILD_TESTS) # PkgConfig -set(prefix ${CMAKE_INSTALL_PREFIX}) +set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) -set(includedir ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}) +set(includedir ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}) if(${UNIX}) - set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) endif(${UNIX}) + if(${WIN32}) - set(libdir ${CMAKE_INSTALL_PREFIX}/bin) + set(libdir ${CMAKE_INSTALL_PREFIX}/bin) endif(${WIN32}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftdi1.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libftdi1.pc @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftdipp1.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libftdipp1.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libftdi1.pc ${CMAKE_CURRENT_BINARY_DIR}/libftdipp1.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -if (UNIX OR MINGW) - configure_file ( libftdi1-config.in ${CMAKE_CURRENT_BINARY_DIR}/libftdi1-config @ONLY ) - install ( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libftdi1-config - DESTINATION bin ) -endif () +if(UNIX OR MINGW) + configure_file(libftdi1-config.in ${CMAKE_CURRENT_BINARY_DIR}/libftdi1-config @ONLY) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libftdi1-config + DESTINATION bin) +endif() # config script install path -if ( NOT DEFINED LIBFTDI_CMAKE_CONFIG_DIR ) - set ( LIBFTDI_CMAKE_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/libftdi1 ) -endif () - -set ( LIBFTDI_INCLUDE_DIR ${includedir} ) -set ( LIBFTDI_INCLUDE_DIRS ${LIBFTDI_INCLUDE_DIR} ) -set ( LIBFTDI_LIBRARY ftdi1 ) -set ( LIBFTDI_LIBRARIES ${LIBFTDI_LIBRARY} ) -list ( APPEND LIBFTDI_LIBRARIES ${LIBUSB_LIBRARIES} ) -set ( LIBFTDI_STATIC_LIBRARY ftdi1.a ) -set ( LIBFTDI_STATIC_LIBRARIES ${LIBFTDI_STATIC_LIBRARY} ) -list ( APPEND LIBFTDI_STATIC_LIBRARIES ${LIBUSB_LIBRARIES} ) -if ( FTDIPP ) - set ( LIBFTDIPP_LIBRARY ftdipp1 ) - set ( LIBFTDIPP_LIBRARIES ${LIBFTDIPP_LIBRARY} ) - list ( APPEND LIBFTDIPP_LIBRARIES ${LIBUSB_LIBRARIES} ) -endif () -set ( LIBFTDI_LIBRARY_DIRS ${libdir} ) -set ( LIBFTDI_ROOT_DIR ${prefix} ) -set ( LIBFTDI_VERSION_STRING ${VERSION_STRING} ) -set ( LIBFTDI_VERSION_MAJOR ${MAJOR_VERSION} ) -set ( LIBFTDI_VERSION_MINOR ${MINOR_VERSION} ) - -set ( LIBFTDI_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBFTDI_CMAKE_CONFIG_DIR}/UseLibFTDI1.cmake ) +if(NOT DEFINED LIBFTDI_CMAKE_CONFIG_DIR) + set(LIBFTDI_CMAKE_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/libftdi1) +endif() + +set(LIBFTDI_INCLUDE_DIR ${includedir}) +set(LIBFTDI_INCLUDE_DIRS ${LIBFTDI_INCLUDE_DIR}) +set(LIBFTDI_LIBRARY ftdi1) +set(LIBFTDI_LIBRARIES ${LIBFTDI_LIBRARY}) +list(APPEND LIBFTDI_LIBRARIES ${LIBUSB_LIBRARIES}) +set(LIBFTDI_STATIC_LIBRARY ftdi1.a) +set(LIBFTDI_STATIC_LIBRARIES ${LIBFTDI_STATIC_LIBRARY}) +list(APPEND LIBFTDI_STATIC_LIBRARIES ${LIBUSB_LIBRARIES}) + +if(FTDIPP) + set(LIBFTDIPP_LIBRARY ftdipp1) + set(LIBFTDIPP_LIBRARIES ${LIBFTDIPP_LIBRARY}) + list(APPEND LIBFTDIPP_LIBRARIES ${LIBUSB_LIBRARIES}) +endif() + +set(LIBFTDI_LIBRARY_DIRS ${libdir}) +set(LIBFTDI_ROOT_DIR ${prefix}) +set(LIBFTDI_VERSION_STRING ${VERSION_STRING}) +set(LIBFTDI_VERSION_MAJOR ${MAJOR_VERSION}) +set(LIBFTDI_VERSION_MINOR ${MINOR_VERSION}) + +set(LIBFTDI_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBFTDI_CMAKE_CONFIG_DIR}/UseLibFTDI1.cmake) include(CMakePackageConfigHelpers) -configure_package_config_file ( +configure_package_config_file( cmake/LibFTDI1Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR} PATH_VARS - LIBFTDI_USE_FILE - LIBFTDI_ROOT_DIR - LIBFTDI_INCLUDE_DIR - LIBFTDI_INCLUDE_DIRS - LIBFTDI_LIBRARY_DIRS + LIBFTDI_USE_FILE + LIBFTDI_ROOT_DIR + LIBFTDI_INCLUDE_DIR + LIBFTDI_INCLUDE_DIRS + LIBFTDI_LIBRARY_DIRS NO_CHECK_REQUIRED_COMPONENTS_MACRO ) -write_basic_package_version_file ( +write_basic_package_version_file( LibFTDI1ConfigVersion.cmake VERSION ${LIBFTDI_VERSION_STRING} COMPATIBILITY AnyNewerVersion ) -install ( +install( FILES - ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1ConfigVersion.cmake - cmake/UseLibFTDI1.cmake + ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1ConfigVersion.cmake + cmake/UseLibFTDI1.cmake DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR} ) include(CPack) -message (STATUS "Summary of build options: +message(STATUS "Summary of build options: Build static libs: ${STATICLIBS} Build C++ bindings: ${FTDIPP} diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 983301d..16b7c6f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package ( Doxygen REQUIRED ) +find_package(Doxygen REQUIRED) # Copy doxy.config.in configure_file( diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9ec7bff..fafd99f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,5 @@ # Includes -include_directories( ${CMAKE_CURRENT_SOURCE_DIR} +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) @@ -15,6 +15,7 @@ add_executable(baud_test baud_test.c) add_executable(stream_test stream_test.c) add_executable(eeprom eeprom.c) add_executable(async async.c) + if(NOT MINGW) add_executable(purge_test purge_test.c) endif(NOT MINGW) @@ -31,12 +32,13 @@ target_link_libraries(baud_test ftdi1) target_link_libraries(stream_test ftdi1) target_link_libraries(eeprom ftdi1) target_link_libraries(async ftdi1) + if(NOT MINGW) target_link_libraries(purge_test ftdi1) endif(NOT MINGW) # libftdi++ examples -if( FTDIPP ) +if(FTDIPP) include_directories(BEFORE ${PROJECT_SOURCE_DIR}/ftdipp ${Boost_INCLUDE_DIRS} ) @@ -46,7 +48,7 @@ if( FTDIPP ) # Linkage target_link_libraries(find_all_pp ftdipp1) -endif( FTDIPP ) +endif(FTDIPP) # Source includes include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src) diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt index 7d60693..2da8161 100644 --- a/examples/cmake_example/CMakeLists.txt +++ b/examples/cmake_example/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) -project ( example C ) +project(example C) -find_package ( LibFTDI1 NO_MODULE REQUIRED ) -include ( ${LIBFTDI_USE_FILE} ) +find_package(LibFTDI1 NO_MODULE REQUIRED) +include(${LIBFTDI_USE_FILE}) -add_executable ( example main.c ) -target_link_libraries( example ${LIBFTDI_LIBRARIES} ) +add_executable(example main.c) +target_link_libraries(example ${LIBFTDI_LIBRARIES}) -install ( TARGETS example - DESTINATION bin +install(TARGETS example + DESTINATION bin ) diff --git a/ftdi_eeprom/CMakeLists.txt b/ftdi_eeprom/CMakeLists.txt index 525421e..5000af5 100644 --- a/ftdi_eeprom/CMakeLists.txt +++ b/ftdi_eeprom/CMakeLists.txt @@ -1,8 +1,9 @@ -find_package ( Confuse REQUIRED ) -find_package ( Libintl ) +find_package(Confuse REQUIRED) +find_package(Libintl) # determine docdir include(GNUInstallDirs) + if(NOT CMAKE_INSTALL_DOCDIR) if(WIN32) set(CMAKE_INSTALL_DOCDIR .) @@ -13,32 +14,33 @@ endif(NOT CMAKE_INSTALL_DOCDIR) message(STATUS "Building ftdi_eeprom") -include_directories ( ${CONFUSE_INCLUDE_DIRS} ) -list ( APPEND libs ${CONFUSE_LIBRARIES} ) - -if ( LIBINTL_FOUND ) - include_directories ( ${LIBINTL_INCLUDE_DIR} ) - list ( APPEND libs ${LIBINTL_LIBRARIES} ) -endif () +include_directories(${CONFUSE_INCLUDE_DIRS}) +list(APPEND libs ${CONFUSE_LIBRARIES}) +if(LIBINTL_FOUND) + include_directories(${LIBINTL_INCLUDE_DIR}) + list(APPEND libs ${LIBINTL_LIBRARIES}) +endif() # Version defines -set ( EEPROM_MAJOR_VERSION 0 ) -set ( EEPROM_MINOR_VERSION 17 ) -set ( EEPROM_VERSION_STRING ${EEPROM_MAJOR_VERSION}.${EEPROM_MINOR_VERSION} ) +set(EEPROM_MAJOR_VERSION 0) +set(EEPROM_MINOR_VERSION 17) +set(EEPROM_VERSION_STRING ${EEPROM_MAJOR_VERSION}.${EEPROM_MINOR_VERSION}) -include_directories ( BEFORE ${PROJECT_SOURCE_DIR}/src ) -include_directories ( BEFORE ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src) +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) configure_file( - ftdi_eeprom_version.h.in - ${CMAKE_CURRENT_BINARY_DIR}/ftdi_eeprom_version.h + ftdi_eeprom_version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/ftdi_eeprom_version.h ) -add_executable ( ftdi_eeprom main.c ) -target_link_libraries ( ftdi_eeprom ftdi1 ${CONFUSE_LIBRARIES} ) -if ( LIBINTL_FOUND ) - target_link_libraries ( ftdi_eeprom ${LIBINTL_LIBRARIES} ) -endif () -install ( TARGETS ftdi_eeprom DESTINATION bin ) -install ( FILES example.conf DESTINATION ${CMAKE_INSTALL_DOCDIR} ) +add_executable(ftdi_eeprom main.c) +target_link_libraries(ftdi_eeprom ftdi1 ${CONFUSE_LIBRARIES}) + +if(LIBINTL_FOUND) + target_link_libraries(ftdi_eeprom ${LIBINTL_LIBRARIES}) +endif() + +install(TARGETS ftdi_eeprom DESTINATION bin) +install(FILES example.conf DESTINATION ${CMAKE_INSTALL_DOCDIR}) diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt index 360a831..5369a29 100644 --- a/ftdipp/CMakeLists.txt +++ b/ftdipp/CMakeLists.txt @@ -1,6 +1,6 @@ # Targets -set(cpp_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.cpp CACHE INTERNAL "List of cpp sources" ) -set(cpp_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.hpp CACHE INTERNAL "List of cpp headers" ) +set(cpp_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.cpp CACHE INTERNAL "List of cpp sources") +set(cpp_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.hpp CACHE INTERNAL "List of cpp headers") # Includes include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} @@ -13,7 +13,7 @@ include_directories(${Boost_INCLUDE_DIRS}) # Shared library add_library(ftdipp1 SHARED ${cpp_sources}) -math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases +math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 3) # Prevent clobbering each other during the build @@ -22,25 +22,25 @@ set_target_properties(ftdipp1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) # Dependencies target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) -install ( TARGETS ftdipp1 - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +install(TARGETS ftdipp1 + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) # Static library -if ( STATICLIBS ) +if(STATICLIBS) add_library(ftdipp1-static STATIC ${cpp_sources}) set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1") set_target_properties(ftdipp1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) - install ( TARGETS ftdipp1-static - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT staticlibs + install(TARGETS ftdipp1-static + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT staticlibs ) -endif () +endif() -install ( FILES ${cpp_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers +install(FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers ) diff --git a/packages/CMakeLists.txt b/packages/CMakeLists.txt index 204bbe0..cbd2d49 100644 --- a/packages/CMakeLists.txt +++ b/packages/CMakeLists.txt @@ -1,21 +1,19 @@ # Debian if("${PACKAGE}" STREQUAL "Debian") - # Settings - set(REVISION 0) - set(CPACK_GENERATOR "DEB" PARENT_SCOPE) - set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}-${REVISION} PARENT_SCOPE) + set(REVISION 0) + set(CPACK_GENERATOR "DEB" PARENT_SCOPE) + set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}-${REVISION} PARENT_SCOPE) # Dependencies - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libusb-1.0-0" PARENT_SCOPE) - set(DEBIAN_PACKAGE_BUILDS_DEPENDS "cmake, libusb2-dev" PARENT_SCOPE) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libusb-1.0-0" PARENT_SCOPE) + set(DEBIAN_PACKAGE_BUILDS_DEPENDS "cmake, libusb2-dev" PARENT_SCOPE) # Bundles message("-- Installing udev rules to /etc/udev/rules.d") install(FILES 99-libftdi.rules - DESTINATION /etc/udev/rules.d) - + DESTINATION /etc/udev/rules.d) endif("${PACKAGE}" STREQUAL "Debian") # General RPM rules -set(CPACK_RPM_PACKAGE_DEPENDS "libusb1" PARENT_SCOPE) +set(CPACK_RPM_PACKAGE_DEPENDS "libusb1" PARENT_SCOPE) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9358419..6cacbce 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,62 +1,67 @@ # swig_add_library behavior changed in cmake 3.13 to no longer set # SWIG_MODULE_<target>_REAL_NAME, so restore the old behavior. -if ( POLICY CMP0078 ) - cmake_policy( SET CMP0078 OLD ) -endif () +if(POLICY CMP0078) + cmake_policy(SET CMP0078 OLD) +endif() # workaround for cmake bug #0013449 -if ( NOT DEFINED CMAKE_FIND_ROOT_PATH OR NOT CMAKE_VERSION VERSION_LESS 3.0.0 ) - find_package ( SWIG REQUIRED ) -else () - find_program ( SWIG_EXECUTABLE NAMES swig2.0 swig ) - if ( SWIG_EXECUTABLE ) - set ( SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake ) - set ( SWIG_FOUND TRUE ) - endif () -endif () -find_package ( PythonInterp REQUIRED ) -find_package ( PythonLibs REQUIRED ) - -include ( UseSWIG ) -include_directories ( BEFORE ${PROJECT_SOURCE_DIR}/src ) -include_directories ( ${PYTHON_INCLUDE_DIRS} ) -link_directories ( ${CMAKE_CURRENT_BINARY_DIR}/../src ) - -if ( DOCUMENTATION ) +if(NOT DEFINED CMAKE_FIND_ROOT_PATH OR NOT CMAKE_VERSION VERSION_LESS 3.0.0) + find_package(SWIG REQUIRED) +else() + find_program(SWIG_EXECUTABLE NAMES swig2.0 swig) + + if(SWIG_EXECUTABLE) + set(SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake) + set(SWIG_FOUND TRUE) + endif() +endif() + +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) + +include(UseSWIG) +include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src) +include_directories(${PYTHON_INCLUDE_DIRS}) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../src) + +if(DOCUMENTATION) set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND}) + # manually add dependency for new cmake / swig versions set_property(SOURCE ftdi1.i PROPERTY DEPENDS doc_i) endif() + if(NOT CMAKE_VERSION VERSION_LESS 3.8.0) - swig_add_library ( ftdi1 LANGUAGE python SOURCES ftdi1.i ) -else () - swig_add_module ( ftdi1 python ftdi1.i ) + swig_add_library(ftdi1 LANGUAGE python SOURCES ftdi1.i) +else() + swig_add_module(ftdi1 python ftdi1.i) endif() -swig_link_libraries ( ftdi1 ftdi1 ) -if ( LINK_PYTHON_LIBRARY ) - swig_link_libraries ( ftdi1 ${PYTHON_LIBRARIES} ) -elseif( APPLE ) - set_target_properties ( ${SWIG_MODULE_ftdi1_REAL_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" ) -endif () +swig_link_libraries(ftdi1 ftdi1) -set_target_properties ( ${SWIG_MODULE_ftdi1_REAL_NAME} PROPERTIES NO_SONAME ON ) +if(LINK_PYTHON_LIBRARY) + swig_link_libraries(ftdi1 ${PYTHON_LIBRARIES}) +elseif(APPLE) + set_target_properties(${SWIG_MODULE_ftdi1_REAL_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") +endif() -execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'platlib', vars={'platbase': '${CMAKE_INSTALL_PREFIX}'} ) )" - OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE ) +set_target_properties(${SWIG_MODULE_ftdi1_REAL_NAME} PROPERTIES NO_SONAME ON) -get_filename_component ( _ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE ) -file ( RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH} ) +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'platlib', vars={'platbase': '${CMAKE_INSTALL_PREFIX}'} ) )" + OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) -set ( PYTHON_MODULE_PATH ${_REL_PYTHON_MODULE_PATH} ) +get_filename_component(_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) +file(RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/ftdi1.py DESTINATION ${PYTHON_MODULE_PATH} ) -install ( TARGETS ${SWIG_MODULE_ftdi1_REAL_NAME} LIBRARY DESTINATION ${PYTHON_MODULE_PATH} ) +set(PYTHON_MODULE_PATH ${_REL_PYTHON_MODULE_PATH}) -if ( DOCUMENTATION ) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ftdi1.py DESTINATION ${PYTHON_MODULE_PATH}) +install(TARGETS ${SWIG_MODULE_ftdi1_REAL_NAME} LIBRARY DESTINATION ${PYTHON_MODULE_PATH}) + +if(DOCUMENTATION) # Run doxygen to only generate the xml - add_custom_command ( OUTPUT ${PROJECT_BINARY_DIR}/doc/xml/ftdi_8c.xml + add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/xml/ftdi_8c.xml COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/doc/Doxyfile.xml WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Generating ftdi_8c.xml" @@ -64,22 +69,21 @@ if ( DOCUMENTATION ) ) # generate .i from doxygen .xml - add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n - ${PROJECT_BINARY_DIR}/doc/xml/ftdi_8c.xml - ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i + ${PROJECT_BINARY_DIR}/doc/xml/ftdi_8c.xml + ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i COMMENT "Generating ftdi1_doc.i from ftdi_8c.xml" DEPENDS ${PROJECT_BINARY_DIR}/doc/xml/ftdi_8c.xml ) - add_custom_target ( doc_i + add_custom_target(doc_i COMMENT "Python API bindings documentation" DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i ) - add_dependencies( ${SWIG_MODULE_ftdi1_REAL_NAME} doc_i ) - -endif ( DOCUMENTATION ) + add_dependencies(${SWIG_MODULE_ftdi1_REAL_NAME} doc_i) +endif(DOCUMENTATION) -set ( LIBFTDI_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH} ) -set ( LIBFTDI_PYTHON_MODULE_PATH ${LIBFTDI_PYTHON_MODULE_PATH} PARENT_SCOPE ) # for ftdiconfig.cmake +set(LIBFTDI_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}) +set(LIBFTDI_PYTHON_MODULE_PATH ${LIBFTDI_PYTHON_MODULE_PATH} PARENT_SCOPE) # for ftdiconfig.cmake -add_subdirectory ( examples ) +add_subdirectory(examples) diff --git a/python/examples/CMakeLists.txt b/python/examples/CMakeLists.txt index 232595f..ea6f0bb 100644 --- a/python/examples/CMakeLists.txt +++ b/python/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -install ( FILES simple.py complete.py cbus.py - DESTINATION share/libftdi/examples - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ +install(FILES simple.py complete.py cbus.py + DESTINATION share/libftdi/examples + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e145af1..fa10f3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,55 +1,57 @@ # Includes include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ) # Version information set(SNAPSHOT_VERSION "unknown") execute_process(COMMAND git describe - OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT - RESULT_VARIABLE GIT_DESCRIBE_RESULT - OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT + RESULT_VARIABLE GIT_DESCRIBE_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(${GIT_DESCRIBE_RESULT} STREQUAL 0) set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) -endif () +endif() + message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}") configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY) # Targets -set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources" ) -set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers" ) +set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources") +set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers") add_library(ftdi1 SHARED ${c_sources}) -math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases +math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) -# Prevent clobbering each other during the build -set_target_properties ( ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) +# Prevent clobbering each other during the build +set_target_properties(ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) # Dependencies target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES}) -install ( TARGETS ftdi1 - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +install(TARGETS ftdi1 + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -if ( STATICLIBS ) +if(STATICLIBS) add_library(ftdi1-static STATIC ${c_sources}) target_link_libraries(ftdi1-static ${LIBUSB_LIBRARIES}) set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1") set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) - install ( TARGETS ftdi1-static - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT staticlibs + install(TARGETS ftdi1-static + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT staticlibs ) -endif () +endif() -install ( FILES ${c_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers +install(FILES ${c_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers ) -- 2.44.0.windows.1 -- libftdi - see http://www.intra2net.com/en/developer/libftdi for details. To unsubscribe send a mail to libftdi+unsubscr...@developer.intra2net.com