X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=ftdipp%2FCMakeLists.txt;h=d3a22cea7743631651e3ad53d3720b5ec0f32a7c;hp=d13071ab78a48d397b7e381724d892537a11bc5f;hb=a00c0a850b7fc6a3f6f7491df7f45a21ac957fa2;hpb=0b2d00fcee8dee36c47060e933d4adbefa05a56e diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt index d13071a..d3a22ce 100644 --- a/ftdipp/CMakeLists.txt +++ b/ftdipp/CMakeLists.txt @@ -1,58 +1,90 @@ # 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 libftdi1++" ON) # Targets -set(cpp_sources ftdi.cpp) -set(cpp_headers ftdi.hpp) +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" ) + +if (FTDIPP) -# Find Boost -find_package(Boost) -if(Boost_FOUND) -set(FTDI_BUILD_CPP True PARENT_SCOPE) -message(STATUS "Building libftdi++") + if(Boost_FOUND) -# Targets -add_library(ftdi_cpp SHARED ${cpp_sources}) + # Includes + include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src) + + include_directories(${Boost_INCLUDE_DIRS}) + + + + set(FTDI_BUILD_CPP True PARENT_SCOPE) + message(STATUS "Building libftdi1++") -# Dependencies -target_link_libraries(ftdi_cpp ftdi usb ${BOOST_LIBRARIES}) + # Shared library + add_library(ftdipp1 SHARED ${cpp_sources}) -# Install -if(${UNIX}) + math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases + set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) - install( TARGETS ftdi_cpp - LIBRARY DESTINATION lib - COMPONENT sharedlibs - ) + # Static library + if (STATICLIBS) + add_library(ftdipp1-static STATIC ${cpp_sources}) + set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1") + endif (STATICLIBS) - install( FILES ${cpp_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers - ) + # Prevent clobbering each other during the build + set_target_properties(ftdipp1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) + if (STATICLIBS) + set_target_properties(ftdipp1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + endif (STATICLIBS) -endif(${UNIX}) + # Dependencies + target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) -if(${WIN32}) + # Install + if(${UNIX}) + install( TARGETS ftdipp1 + LIBRARY DESTINATION lib${LIB_SUFFIX} + COMPONENT sharedlibs + ) + if (STATICLIBS) + install( TARGETS ftdipp1-static + ARCHIVE DESTINATION lib${LIB_SUFFIX} + COMPONENT staticlibs + ) + endif (STATICLIBS) + install( FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers + ) + endif(${UNIX}) - install( TARGETS ftdi_cpp - DESTINATION bin - COMPONENT sharedlibs - ) + if(${WIN32}) + install( TARGETS ftdipp1 + DESTINATION bin + COMPONENT sharedlibs + ) + if (STATICLIBS) + install( TARGETS ftdipp1-static + DESTINATION bin + COMPONENT staticlibs + ) + endif (STATICLIBS) + install( FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers + ) + endif(${WIN32}) - install( FILES ${cpp_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers - ) + else(Boost_FOUND) + message(STATUS "Boost not found, won't build libftdi1++") + endif(Boost_FOUND) -endif(${WIN32}) +else(FTDIPP) -else(Boost_FOUND) - message(STATUS "Boost not found, won't build libftdi++") -endif(Boost_FOUND) + message(STATUS "Not building libftdi1++") +endif(FTDIPP)