Re: [PATCH] CMake: move options to a dedicated file

2018-02-28 Thread Thomas Jarosch
On 02/20/2018 12:56 PM, Yegor Yefremov wrote:
> You're right ftdi_eeprom should be enabled by default. Python bindings
> have more dependencies so I would let it OFF by default.

ok, sounds like a good compromise for now.
I've committed a change for this.

>> What about having libconfuse / boost library detection
>> in CMakeOptions.txt to set the default values?
> 
> I'm using libftdi in the Buildroot context. In this case it is
> important/desired to have predictable, reproducible builds. If I
> configure the option FTDI_EEPROM as OFF, then I expect that I get no
> ftdi_eeprom binary even if I have libconfuse.
> 
> Another approach would be NOT to define FTDI_EEPROM as an option, but
> just as a variable, that depends on whether libconfuse could be found
> or not. In this case the behavior is controlled externally through the
> development environment.
> 
> But I'm more for the first variant.

yes, the first variant is more obvious.

Your patch has landed on master :)

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscr...@developer.intra2net.com   



Re: [PATCH] CMake: move options to a dedicated file

2018-02-20 Thread Yegor Yefremov
Hi Thomas,

sorry for delay.

On Mon, Feb 5, 2018 at 11:36 PM, Thomas Jarosch
 wrote:
> Hi Yegor,
>
> On 01/03/2018 01:46 PM, Yegor Yefremov wrote:
>> Also disable all options having extra dependencies.
>>
>> If an option is selected makes its dependencies as REQUIRED.
>
> thanks for the big patch. It's almost merged :)
>
> What needs a bit of discussion is the change in default behavior:
>
> The old cmake script was "best effort": If you f.e. had libconfuse
> installed, ftdi_eeprom was automatically build.
>
> With the new way of doing things, ftdi_eeprom needs to be enabled upon
> request. This changes user expectations that have grown over many years.
>
> Do you think we can re-enable ftdi_eeprom
> and the python bindings by default?
> Not sure how widespread the C++ wrapper is used.

You're right ftdi_eeprom should be enabled by default. Python bindings
have more dependencies so I would let it OFF by default.

> What about having libconfuse / boost library detection
> in CMakeOptions.txt to set the default values?

I'm using libftdi in the Buildroot context. In this case it is
important/desired to have predictable, reproducible builds. If I
configure the option FTDI_EEPROM as OFF, then I expect that I get no
ftdi_eeprom binary even if I have libconfuse.

Another approach would be NOT to define FTDI_EEPROM as an option, but
just as a variable, that depends on whether libconfuse could be found
or not. In this case the behavior is controlled externally through the
development environment.

But I'm more for the first variant.

As for Boost as long as it is mostly interesting for testing, it is a
more a matter of  configuring the CI server.

Yegor

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscr...@developer.intra2net.com   



Re: [PATCH] CMake: move options to a dedicated file

2018-02-05 Thread Thomas Jarosch
Hi Yegor,

On 01/03/2018 01:46 PM, Yegor Yefremov wrote:
> Also disable all options having extra dependencies.
> 
> If an option is selected makes its dependencies as REQUIRED.

thanks for the big patch. It's almost merged :)

What needs a bit of discussion is the change in default behavior:

The old cmake script was "best effort": If you f.e. had libconfuse
installed, ftdi_eeprom was automatically build.

With the new way of doing things, ftdi_eeprom needs to be enabled upon
request. This changes user expectations that have grown over many years.

Do you think we can re-enable ftdi_eeprom
and the python bindings by default?
Not sure how widespread the C++ wrapper is used.

What about having libconfuse / boost library detection
in CMakeOptions.txt to set the default values?

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscr...@developer.intra2net.com   



[PATCH] CMake: move options to a dedicated file

2018-01-03 Thread Yegor Yefremov
Also disable all options having extra dependencies.

If an option is selected makes its dependencies as REQUIRED.

Signed-off-by: Yegor Yefremov 
---
 CMakeLists.txt |  62 ---
 CMakeOptions.txt   |   8 +++
 examples/CMakeLists.txt|  98 
 ftdi_eeprom/CMakeLists.txt |  63 ++--
 ftdipp/CMakeLists.txt  |  91 +-
 python/CMakeLists.txt  | 120 -
 test/CMakeLists.txt|  41 
 7 files changed, 209 insertions(+), 274 deletions(-)
 create mode 100644 CMakeOptions.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66abe4c..71857d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,8 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
 
 add_definitions(-Wall)
 
+include(CMakeOptions.txt)
+
 # Debug build
 message("-- Build type: ${CMAKE_BUILD_TYPE}")
 if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
@@ -26,8 +28,10 @@ endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
 find_package ( USB1 REQUIRED )
 include_directories ( ${LIBUSB_INCLUDE_DIR} )
 
-# Find Boost (optional package)
-find_package(Boost)
+# Find Boost
+if (FTDIPP OR BUILD_TESTS)
+  find_package( Boost REQUIRED )
+endif()
 
 # Set components
 set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers)
@@ -46,8 +50,6 @@ set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development")
 set(CPACK_COMPONENT_STATICLIBS_GROUP "Development")
 set(CPACK_COMPONENT_HEADERS_GROUP"Development")
 
-option ( STATICLIBS "Build static libraries" ON )
-
 # guess LIB_SUFFIX, don't take debian multiarch into account 
 if ( NOT DEFINED LIB_SUFFIX )
   if( CMAKE_SYSTEM_NAME MATCHES "Linux"
@@ -113,18 +115,8 @@ add_custom_target(dist
 | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
-# Tests
-option ( BUILD_TESTS "Build unit tests with Boost Unit Test framework" ON )
-
-# Documentation
-option ( DOCUMENTATION "Generate API documentation with Doxygen" ON )
-
-
-find_package ( Doxygen )
-if ( DOCUMENTATION AND DOXYGEN_FOUND )
-
-   # Find doxy config
-   message(STATUS "Doxygen found.")
+if ( DOCUMENTATION )
+   find_package ( Doxygen REQUIRED)
 
# Copy doxy.config.in
set(top_srcdir ${CMAKE_SOURCE_DIR})
@@ -140,19 +132,25 @@ if ( DOCUMENTATION AND DOXYGEN_FOUND )
)
 
add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
-
-   message(STATUS "Generating API documentation with Doxygen")
-else(DOCUMENTATION AND DOXYGEN_FOUND)
-   message(STATUS "Not generating API documentation")
-endif(DOCUMENTATION AND DOXYGEN_FOUND)
+endif ()
 
 add_subdirectory(src)
-add_subdirectory(ftdipp)
+if ( FTDIPP )
+  add_subdirectory(ftdipp)
+endif ()
+if ( PYTHON_BINDINGS )
 add_subdirectory(python)
-add_subdirectory(ftdi_eeprom)
-add_subdirectory(examples)
+endif ()
+if ( FTDI_EEPROM )
+  add_subdirectory(ftdi_eeprom)
+endif ()
+if ( EXAMPLES )
+  add_subdirectory(examples)
+endif ()
 add_subdirectory(packages)
-add_subdirectory(test)
+if ( BUILD_TESTS )
+  add_subdirectory(test)
+endif ()
 
 # PkgConfig
 set(prefix  ${CMAKE_INSTALL_PREFIX})
@@ -191,7 +189,7 @@ 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 (FTDI_BUILD_CPP)
+if ( FTDIPP )
   set ( LIBFTDIPP_LIBRARY ftdipp1 )
   set ( LIBFTDIPP_LIBRARIES ${LIBFTDIPP_LIBRARY} )
   list ( APPEND LIBFTDIPP_LIBRARIES ${LIBUSB_LIBRARIES} )
@@ -238,7 +236,15 @@ install ( FILES
   DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR}
 )
 
+include(CPack)
 
+message (STATUS "Summary of build options:
 
-
-include(CPack)
+  Build static libs: ${STATICLIBS}
+  Build C++ bindings: ${FTDIPP}
+  Build Python bindings: ${PYTHON_BINDINGS}
+  Build ftdi_eeprom: ${FTDI_EEPROM}
+  Build examples: ${EXAMPLES}
+  Build tests: ${BUILD_TESTS}
+  Build API documentation: ${DOCUMENTATION}
+")
diff --git a/CMakeOptions.txt b/CMakeOptions.txt
new file mode 100644
index 000..43a9d3d
--- /dev/null
+++ b/CMakeOptions.txt
@@ -0,0 +1,8 @@
+option ( STATICLIBS "Build static libraries" ON )
+option ( BUILD_TESTS "Build unit tests with Boost Unit Test framework" OFF )
+option ( DOCUMENTATION "Generate API documentation with Doxygen" OFF )
+option ( EXAMPLES "Build example programs" ON )
+option ( FTDIPP "Build C++ binding library libftdi1++" OFF )
+option ( FTDI_EEPROM "Build ftdi_eeprom" OFF )
+option ( PYTHON_BINDINGS "Build python bindings via swig" OFF )
+option ( LINK_PYTHON_LIBRARY "Link against python libraries" OFF )
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 1263c62..97ab096 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,55 +1,43 @@
-option(EXAMPLES "Build example programs" ON)
-
-if (EXAMPLES)
-# Includes
-