Added cmake rules
authorMarek Vavrusa <marek@vavrusa.com>
Tue, 21 Oct 2008 20:39:15 +0000 (22:39 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 21 Oct 2008 20:39:15 +0000 (22:39 +0200)
CMakeLists.txt [new file with mode: 0644]
ChangeLog
examples/CMakeLists.txt [new file with mode: 0644]
ftdipp/CMakeLists.txt [new file with mode: 0644]
packages/99-libftdi.rules [new file with mode: 0644]
packages/CMakeLists.txt [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..028495e
--- /dev/null
@@ -0,0 +1,75 @@
+# Project
+project(libftdi)
+set(MAJOR_VERSION 0)
+set(MINOR_VERSION 15)
+set(PATCH_VERSION 0)
+set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
+
+# CMake
+if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+   set(CMAKE_BUILD_TYPE     Debug)
+endif("${CMAKE_BUILD_TYPE}" STREQUAL "")
+set(CMAKE_COLOR_MAKEFILE ON)
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+
+# Debug build
+message("-- Build type: ${CMAKE_BUILD_TYPE}")
+if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
+   add_definitions(-DDEBUG)
+endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
+
+# Set components
+set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers)
+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 libkitclient 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")
+
+# Package information
+set(CPACK_PACKAGE_VERSION              ${VERSION_STRING})
+set(CPACK_PACKAGE_CONTACT              "Marek Vavrusa <marek@vavrusa.com>")
+set(CPACK_PACKAGE_DESCRIPTION          "FITKit multiplatform 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})
+endif(${UNIX})
+
+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    "libftdi")
+  set(CPACK_PACKAGE_FILE_NAME            "${PROJECT_NAME}-${VERSION_STRING}-win32")
+  set(CPACK_NSIS_DISPLAY_NAME            "libftdi")
+  set(CPACK_NSIS_MODIFY_PATH             "ON")
+endif(${WIN32})
+
+set(CPACK_RESOURCE_FILE_LICENSE        ${CMAKE_SOURCE_DIR}/COPYING.LIB)
+
+# Subdirectories
+if(${UNIX})
+  set(CPACK_SET_DESTDIR "ON")
+endif(${UNIX})
+
+add_subdirectory(src)
+add_subdirectory(ftdipp)
+add_subdirectory(examples)
+add_subdirectory(packages)
+
+include(CPack)
index d13cf20..db06a61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 New in 0.15
 -----------
 * Full C++ wrapper. Needs boost (Marek Vavruša and Intra2net)
+* cmake rules (Marek Vavruša)
 
 New in 0.14
 -----------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dddb0bb
--- /dev/null
@@ -0,0 +1,41 @@
+# 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(findall find_all.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(findall ftdi)
+
+# libftdi++ examples
+if(FTDI_BUILD_CPP)
+   message(STATUS "Building libftdi++ examples.")
+   include_directories(${CMAKE_SOURCE_DIR}/ftdipp)
+
+   # Targest
+   add_executable(findall-cpp find_all.cpp)
+   add_executable(memorytest memorytest.cpp)
+
+   # Linkage
+   target_link_libraries(findall-cpp ftdi_cpp)
+   target_link_libraries(memorytest ftdi_cpp)
+   
+endif()
+
+
+
diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d13071a
--- /dev/null
@@ -0,0 +1,58 @@
+# Check
+set(FTDI_BUILD_CPP False PARENT_SCOPE)
+
+# Includes
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}
+                     ${CMAKE_CURRENT_SOURCE_DIR}
+                     ${CMAKE_CURRENT_SOURCE_DIR}/../src
+                     )
+
+# Targets
+set(cpp_sources   ftdi.cpp)
+set(cpp_headers   ftdi.hpp)
+
+# Find Boost
+find_package(Boost)
+if(Boost_FOUND)
+set(FTDI_BUILD_CPP True PARENT_SCOPE)
+message(STATUS "Building libftdi++")
+
+# Targets
+add_library(ftdi_cpp SHARED ${cpp_sources})
+
+# Dependencies
+target_link_libraries(ftdi_cpp ftdi usb ${BOOST_LIBRARIES})
+
+# Install
+if(${UNIX})
+
+   install( TARGETS ftdi_cpp
+            LIBRARY DESTINATION lib
+            COMPONENT sharedlibs
+            )
+
+   install( FILES ${cpp_headers}
+            DESTINATION include/${PROJECT_NAME}
+            COMPONENT headers
+            )
+
+endif(${UNIX})
+
+if(${WIN32})
+
+   install( TARGETS ftdi_cpp 
+            DESTINATION bin
+            COMPONENT sharedlibs
+            )
+
+   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)
+
diff --git a/packages/99-libftdi.rules b/packages/99-libftdi.rules
new file mode 100644 (file)
index 0000000..70c91e2
--- /dev/null
@@ -0,0 +1,2 @@
+# allow users to claim the device
+SUBSYSTEM=="usb_device", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0664", GROUP="plugdev"
diff --git a/packages/CMakeLists.txt b/packages/CMakeLists.txt
new file mode 100644 (file)
index 0000000..92b19bd
--- /dev/null
@@ -0,0 +1,18 @@
+# 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)
+
+   # Dependencies
+   set(CPACK_DEBIAN_PACKAGE_DEPENDS       "libusb-0.1-4" PARENT_SCOPE)
+   set(DEBIAN_PACKAGE_BUILDS_DEPENDS      "cmake, libusb-dev" PARENT_SCOPE)
+
+   # Bundles
+   message("-- Installing udev rules to /etc/udev/rules.d")
+   install(FILES 99-libftdi.rules
+           DESTINATION /etc/udev/rules.d)
+
+endif("${PACKAGE}" STREQUAL "Debian")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6f1c40b
--- /dev/null
@@ -0,0 +1,42 @@
+# Includes
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}
+                     ${CMAKE_CURRENT_SOURCE_DIR}
+                     )
+
+# Targets
+set(c_sources     ftdi.c)
+set(c_headers     ftdi.h)
+
+add_library(ftdi SHARED ${c_sources})
+
+# Dependencies
+target_link_libraries(ftdi usb)
+
+# Install
+if(${UNIX})
+
+   install( TARGETS ftdi
+            LIBRARY DESTINATION lib
+            COMPONENT sharedlibs
+            )
+
+   install( FILES ${c_headers}
+            DESTINATION include/${PROJECT_NAME}
+            COMPONENT headers
+            )
+
+endif(${UNIX})
+
+if(${WIN32})
+
+   install( TARGETS ftdi
+            DESTINATION bin
+            COMPONENT sharedlibs
+            )
+
+   install( FILES ${c_headers}
+            DESTINATION include/${PROJECT_NAME}
+            COMPONENT headers
+            )
+
+endif(${WIN32})