From: Gerd von Egidy Date: Mon, 18 Jan 2010 14:17:09 +0000 (+0100) Subject: building parts of libftdi via cmake is now optional. X-Git-Tag: v0.18~16 X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=commitdiff_plain;h=a03fea794af90cd97514f35f212691f8b5b3700d building parts of libftdi via cmake is now optional. the options are: DOCUMENTATION PYTHON_BINDINGS FTDIPP EXAMPLES by default all parts will be built. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 14e02b2..3595198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,11 @@ add_subdirectory(packages) # Documentation + +option(DOCUMENTATION "Generate API documentation with Doxygen" ON) + find_package(Doxygen) -if(DOXYGEN_FOUND) +if(DOCUMENTATION AND DOXYGEN_FOUND) # Set variables set(PACKAGE libftdi) @@ -126,7 +129,10 @@ if(DOXYGEN_FOUND) add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html) -endif(DOXYGEN_FOUND) + message(STATUS "Generating API documentation with Doxygen") +else(DOCUMENTATION AND DOXYGEN_FOUND) + message(STATUS "Not generating API documentation") +endif(DOCUMENTATION AND DOXYGEN_FOUND) # PkgConfig set(prefix ${CMAKE_INSTALL_PREFIX}) diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 7900074..48f535c 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -2,8 +2,9 @@ include(FindSWIG) include(FindPythonLibs) include(UseSWIG) -if(SWIG_FOUND) -if(PYTHONLIBS_FOUND) +option(PYTHON_BINDINGS "Build python bindings via swig" ON) + +if(PYTHON_BINDINGS AND SWIG_FOUND AND PYTHONLIBS_FOUND) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../src) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) @@ -17,5 +18,6 @@ if(PYTHONLIBS_FOUND) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ftdi.py DESTINATION ${SITEPACKAGE}) message(STATUS "Building python bindings via swig. Will be installed under ${SITEPACKAGE}") -endif(PYTHONLIBS_FOUND) -endif(SWIG_FOUND) +else(PYTHON_BINDINGS AND SWIG_FOUND AND PYTHONLIBS_FOUND) + message(STATUS "Not building python bindings") +endif(PYTHON_BINDINGS AND SWIG_FOUND AND PYTHONLIBS_FOUND) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2a8ee39..d2aeecb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,39 +1,47 @@ -# Includes -include( ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ) - -# Source includes -include_directories(${CMAKE_SOURCE_DIR}/src) - -# Targets -add_executable(simple simple.c) -add_executable(bitbang bitbang.c) -add_executable(bitbang2 bitbang2.c) -add_executable(bitbang_cbus bitbang_cbus.c) -add_executable(bitbang_ft2232 bitbang_ft2232.c) -add_executable(find_all find_all.c) -add_executable(serial_read serial_read.c) -add_executable(baud_test baud_test.c) - -# Linkage -target_link_libraries(simple ftdi) -target_link_libraries(bitbang ftdi) -target_link_libraries(bitbang2 ftdi) -target_link_libraries(bitbang_cbus ftdi) -target_link_libraries(bitbang_ft2232 ftdi) -target_link_libraries(find_all ftdi) -target_link_libraries(serial_read ftdi) -target_link_libraries(baud_test ftdi) - -# libftdi++ examples -if(FTDI_BUILD_CPP) - message(STATUS "Building libftdi++ examples.") - include_directories(${CMAKE_SOURCE_DIR}/ftdipp) - - # Targest - add_executable(find_all_pp find_all_pp.cpp) - - # Linkage - target_link_libraries(find_all_pp ftdipp) -endif() +option(EXAMPLES "Build example programs" ON) + +if (EXAMPLES) + # Includes + include( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + + message(STATUS "Building example programs.") + + # Source includes + include_directories(${CMAKE_SOURCE_DIR}/src) + + # Targets + add_executable(simple simple.c) + add_executable(bitbang bitbang.c) + add_executable(bitbang2 bitbang2.c) + add_executable(bitbang_cbus bitbang_cbus.c) + add_executable(bitbang_ft2232 bitbang_ft2232.c) + add_executable(find_all find_all.c) + add_executable(serial_read serial_read.c) + add_executable(baud_test baud_test.c) + + # Linkage + target_link_libraries(simple ftdi) + target_link_libraries(bitbang ftdi) + target_link_libraries(bitbang2 ftdi) + target_link_libraries(bitbang_cbus ftdi) + target_link_libraries(bitbang_ft2232 ftdi) + target_link_libraries(find_all ftdi) + target_link_libraries(serial_read ftdi) + target_link_libraries(baud_test ftdi) + + # libftdi++ examples + if(FTDI_BUILD_CPP) + message(STATUS "Building libftdi++ examples.") + include_directories(${CMAKE_SOURCE_DIR}/ftdipp) + + # Targest + add_executable(find_all_pp find_all_pp.cpp) + + # Linkage + target_link_libraries(find_all_pp ftdipp) + endif(FTDI_BUILD_CPP) +else(EXAMPLES) + message(STATUS "Not building example programs.") +endif(EXAMPLES) diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt index 515dc91..8423b2e 100644 --- a/ftdipp/CMakeLists.txt +++ b/ftdipp/CMakeLists.txt @@ -1,78 +1,89 @@ # Check set(FTDI_BUILD_CPP False PARENT_SCOPE) -# Includes -include_directories( ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../src - ) +option(FTDIPP "Build C++ binding library libftdi++" ON) -# Targets -set(cpp_sources ftdi.cpp) -set(cpp_headers ftdi.hpp) +if (FTDIPP) -# Find Boost -find_package(Boost) -if(Boost_FOUND) -set(FTDI_BUILD_CPP True PARENT_SCOPE) -message(STATUS "Building libftdi++") + # Includes + include_directories( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../src + ) -# Targets -add_library(ftdipp SHARED ${cpp_sources}) + # Targets + set(cpp_sources ftdi.cpp) + set(cpp_headers ftdi.hpp) -math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases -set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) + # Find Boost + find_package(Boost) + if(Boost_FOUND) + set(FTDI_BUILD_CPP True PARENT_SCOPE) + message(STATUS "Building libftdi++") -# Static library -add_library(ftdipp-static STATIC ${cpp_sources}) -set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp") + # Targets + add_library(ftdipp SHARED ${cpp_sources}) -# Prevent clobbering each other during the build -set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1) -set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases + set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) -# Dependencies -target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) + # Static library + add_library(ftdipp-static STATIC ${cpp_sources}) + set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp") -# Install -if(${UNIX}) + # Prevent clobbering each other during the build + set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) - install( TARGETS ftdipp - LIBRARY DESTINATION lib${LIB_SUFFIX} - COMPONENT sharedlibs - ) + # Dependencies + target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) - install( TARGETS ftdipp-static - ARCHIVE DESTINATION lib${LIB_SUFFIX} - COMPONENT staticlibs - ) + # Install + if(${UNIX}) - install( FILES ${cpp_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers - ) + install( TARGETS ftdipp + LIBRARY DESTINATION lib${LIB_SUFFIX} + COMPONENT sharedlibs + ) -endif(${UNIX}) + install( TARGETS ftdipp-static + ARCHIVE DESTINATION lib${LIB_SUFFIX} + COMPONENT staticlibs + ) -if(${WIN32}) + install( FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers + ) - install( TARGETS ftdipp - DESTINATION bin - COMPONENT sharedlibs - ) + endif(${UNIX}) - install( TARGETS ftdipp-static - DESTINATION bin - COMPONENT staticlibs - ) + if(${WIN32}) - install( FILES ${cpp_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers - ) + install( TARGETS ftdipp + DESTINATION bin + COMPONENT sharedlibs + ) -endif(${WIN32}) + install( TARGETS ftdipp-static + DESTINATION bin + COMPONENT staticlibs + ) + + install( FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers + ) + + endif(${WIN32}) + + else(Boost_FOUND) + message(STATUS "Boost not found, won't build libftdi++") + endif(Boost_FOUND) + +else(FTDIPP) + + message(STATUS "Not building libftdi++") + +endif(FTDIPP) -else(Boost_FOUND) - message(STATUS "Boost not found, won't build libftdi++") -endif(Boost_FOUND)