From 6d4f7fbac8e34f674ce9b4c82492af2bed014541 Mon Sep 17 00:00:00 2001 From: xantares Date: Wed, 14 Aug 2013 20:13:19 +0200 Subject: [PATCH] Fixed installation of static libraries with windows. --- ftdipp/CMakeLists.txt | 142 +++++++++++++++++++++--------------------------- src/CMakeLists.txt | 80 +++++++++------------------- 2 files changed, 87 insertions(+), 135 deletions(-) diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt index d3a22ce..8f581ef 100644 --- a/ftdipp/CMakeLists.txt +++ b/ftdipp/CMakeLists.txt @@ -1,7 +1,7 @@ # Check set(FTDI_BUILD_CPP False PARENT_SCOPE) -option(FTDIPP "Build C++ binding library libftdi1++" ON) +option ( FTDIPP "Build C++ binding library libftdi1++" ON ) # Targets set(cpp_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.cpp CACHE INTERNAL "List of cpp sources" ) @@ -9,82 +9,64 @@ set(cpp_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.hpp CACHE INTERNAL "List of c if (FTDIPP) - if(Boost_FOUND) - - # 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++") - - # Shared library - add_library(ftdipp1 SHARED ${cpp_sources}) - - math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases - set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) - - # Static library - if (STATICLIBS) - add_library(ftdipp1-static STATIC ${cpp_sources}) - set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1") - endif (STATICLIBS) - - # 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) - - # Dependencies - target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) - - # 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}) - - 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}) - - else(Boost_FOUND) - message(STATUS "Boost not found, won't build libftdi1++") - endif(Boost_FOUND) - -else(FTDIPP) - - message(STATUS "Not building libftdi1++") - -endif(FTDIPP) + if(Boost_FOUND) + + # 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++") + + # Shared library + add_library(ftdipp1 SHARED ${cpp_sources}) + + math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases + set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) + + # Static library + if (STATICLIBS) + add_library(ftdipp1-static STATIC ${cpp_sources}) + set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1") + endif (STATICLIBS) + + # 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) + + # Dependencies + target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) + + + install ( TARGETS ftdipp1 + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + ) + + if ( STATICLIBS ) + install ( TARGETS ftdipp1-static + ARCHIVE DESTINATION lib${LIB_SUFFIX} + COMPONENT staticlibs + ) + endif () + + install ( FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers + ) + + else () + message(STATUS "Boost not found, won't build libftdi1++") + endif () + +else () + message(STATUS "Not building libftdi1++") +endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d67caba..9fd86a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,8 +11,8 @@ execute_process(COMMAND git describe OUTPUT_STRIP_TRAILING_WHITESPACE ) if(${GIT_DESCRIBE_RESULT} STREQUAL 0) - set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) -endif(${GIT_DESCRIBE_RESULT} STREQUAL 0) + set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) +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) @@ -25,61 +25,31 @@ add_library(ftdi1 SHARED ${c_sources}) math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) - -# Static library -add_library(ftdi1-static STATIC ${c_sources}) -if (STATICLIBS) - set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1") -endif (STATICLIBS) - # Prevent clobbering each other during the build -set_target_properties(ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) -if (STATICLIBS) - set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) -endif (STATICLIBS) +set_target_properties ( ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) + # Dependencies target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES}) -# Install -if(${UNIX}) - - install( TARGETS ftdi1 - LIBRARY DESTINATION lib${LIB_SUFFIX} - COMPONENT sharedlibs - ) - - if (STATICLIBS) - install( TARGETS ftdi1-static - ARCHIVE DESTINATION lib${LIB_SUFFIX} - COMPONENT staticlibs - ) - endif (STATICLIBS) - - install( FILES ${c_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers - ) - -endif(${UNIX}) - -if(${WIN32}) - - install( TARGETS ftdi1 - DESTINATION bin - COMPONENT sharedlibs - ) - - if (STATICLIBS) - install( TARGETS ftdi1-static - DESTINATION bin - COMPONENT staticlibs - ) - endif (STATICLIBS) - - install( FILES ${c_headers} - DESTINATION include/${PROJECT_NAME} - COMPONENT headers - ) - -endif(${WIN32}) +install ( TARGETS ftdi1 + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + ) + +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 lib${LIB_SUFFIX} + COMPONENT staticlibs + ) +endif () + +install ( FILES ${c_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers + ) -- 1.7.1