From 8682c99c24f912217e3792401401fdfe1df1c38f Mon Sep 17 00:00:00 2001 From: David Wagner Date: Thu, 15 Oct 2015 17:57:43 +0200 Subject: [PATCH 1/4] Compilation: more doc and sane defaults - Do not turn BASH_COMPLETION buid option on by default on Windows; - Fix a typo in an option documentation; - List known dependencies in the README; - Give some pointers on how to easily compile on Windows; - Print an error if SWIG isn't found when Python bindings are to be compiled. Signed-off-by: David Wagner --- CMakeLists.txt | 9 ++++-- README.md | 51 ++++++++++++++++++++++++++++++++++ appveyor.yml | 4 +-- bindings/python/CMakeLists.txt | 11 +++++++- doc/CMakeLists.txt | 1 - 5 files changed, 70 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9289c5b02..b95cf8891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,11 +36,16 @@ endif(COMMAND cmake_policy) project(parameter-framework) +include(CMakeDependentOption) + option(COVERAGE "Build with coverage support" OFF) -option(BASH_COMPLETION "Install bash completion configuration" ON) +cmake_dependent_option(BASH_COMPLETION "Install bash completion configuration" + ON + UNIX # Only allow installing bash completion on Unix environments + OFF) option(DOXYGEN "Enable doxygen generation (you still have to run 'make doc')" OFF) option(REQUIREMENTS "Generate the html version of the 'requirements' documentation" OFF) -option(PYTHON_BINDINGS "Python library to use the Parameter Framrwork from python" ON) +option(PYTHON_BINDINGS "Python library to use the Parameter Framework from python" ON) option(C_BINDINGS "Library to use the Parameter Framework using a C API" ON) diff --git a/README.md b/README.md index 137fd0276..35509842e 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,45 @@ See [the wiki on github](https://github.com/01org/parameter-framework/wiki). ## Compiling +### Dependencies + +In order to compile you'll need, at the very least: + +- CMake (v2.8.12 or later); +- A C/C++ compiler supporting C++11; +- libxml2 headers and libraries (Provided by the `libxml2-dev` on debian-based +distributions); +- Standalone ASIO (1.10.6 or later) (Provided by `libasio-dev` on debian-based +distributions) ASIO is C++ header-only ASynchronous-IO library. + +If you want to compile the *Python bindings*, you'll also need: + +- SWIG 2.0 (A binding generator); +- Python2.7 development environment (Provided by `python2.7-dev` on debian-based +distributions) + +If you want to *compile and run the tests*, you'll also need: + +- Catch (Provided by `catch` on debian-based distributions). Catch is a +single-header test framework - as such you may also download it directly +[here](https://raw.githubusercontent.com/philsquared/Catch/master/single_include/catch.hpp); +- Python2.7 (Provided by `python2.7` on debian-based distribution - it is +preinstalled on most distributions). + +If you want to *build the code documentation*, you'll need `doxygen` and +`graphviz`. This doc is already available to you - see the wiki. + +### How-To + +If you are already familiar with CMake, you know what to do. + Run `cmake .` then `make`. You may then install libraries, headers and binaries with `make install`. By default, they are installed under `/usr/local` on unix OSes; if you want to install them under a custom directory, you may do so by passing it to the `cmake .` command; e.g. + # Always use absolute paths in CMake "-D" options: you don't know where + # relative paths will be evaluated from. cmake -DCMAKE_INSTALL_PREFIX=/path/to/custom/install . If you want to provide your own dependencies (e.g. your own version of @@ -92,3 +126,20 @@ After a build you may want to run the parameter-framework tests with You may take a look at `.travis.yml` and `appveyor.yml` for examples on how we build the Parameter Framework in the CI. + +### Compiling on Windows + +If you don't already have libxml2 headers/libraries and don't want to build them +by yourself, we have a precompiled version for x86-64. + +Compiled with Visual Studio 12 2013: +- [in debug configuration](https://01.org/sites/default/files/libxml2-x86_64-debug-3eaedba1b64180668fdab7ad2eba549586017bf3.zip) +- [in release configuration](https://01.org/sites/default/files/libxml2-x86_64-3eaedba1b64180668fdab7ad2eba549586017bf3.zip) + +We have mirrored ASIO 1.10.6 [here](https://01.org/sites/default/files/asio-1.10.6.tar.gz). + +Once you have downloaded and uncompressed these two dependencies, add the +following two entries to `CMAKE_PREFIX_PATH`: + + /path/to/libxml2-x86_64/ + /path/to/asio-1.10.6/ diff --git a/appveyor.yml b/appveyor.yml index cdb3c4580..7fdf759af 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -61,7 +61,7 @@ build_script: - mkdir 64bits-debug && cd 64bits-debug # Add debug libxml2.dll in the path so that cmake & tests can find it - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64-debug\bin;%PATH% - - cmake -G "NMake Makefiles" -DPYTHON_BINDINGS=OFF -DBASH_COMPLETION=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" ..\.. + - cmake -G "NMake Makefiles" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" ..\.. - cmake --build . --config debug - ctest --build-config debug %CTEST_PARAMS% - set PATH=%OLD_PATH% && cd .. @@ -69,7 +69,7 @@ build_script: - mkdir 64bits-release & cd 64bits-release # Add release libxml2.dll in the path so that cmake & tests can find it - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64\bin;%PATH% - - cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release -DPYTHON_BINDINGS=OFF -DBASH_COMPLETION=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. + - cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. # Build, test and install - cmake --build . --config release - ctest --build-config release %CTEST_PARAMS% diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 17be2910e..676e4879f 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -26,7 +26,16 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -find_package(SWIG REQUIRED) +find_package(SWIG) +if (NOT SWIG_FOUND) + message(FATAL_ERROR + "Swig is needed to compile the Python bindings but was not found." + "Please either install swig2.0 or disable Python bindings by setting" + "PYTHON_BINDINGS to OFF (e.g. '-DPYTHON_BINDINGS=OFF' in the" + "invocation of CMake.). See the 'Compilation' section of README.md" + "for more details.") +endif() + include(${SWIG_USE_FILE}) # Force usage of Python 2.7.x ... diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index e23b976a3..b6e11086a 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -26,7 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -include(CMakeDependentOption) # Only present DOXYGEN_GRAPHS if DOXYGEN is ON and if so, default to ON. # Else, set to OFF. cmake_dependent_option(DOXYGEN_GRAPHS From 78a9a4c4c625aa5f252acbdc19c0d4eb28f82766 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Mon, 19 Oct 2015 16:40:02 +0200 Subject: [PATCH 2/4] appveyor: setting CMake build type has no effect On multi-configuration build systems (such as Visual Studio or NMake), the build type (aka configuration) is decided at build time whereas on single-configuration build systems, it is set at configuration time (obviously). Remove the unnecessary `-DCMAKE_BUILD_TYPE` option from CMake invocation. Signed-off-by: David Wagner --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7fdf759af..f0c53745b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -69,7 +69,7 @@ build_script: - mkdir 64bits-release & cd 64bits-release # Add release libxml2.dll in the path so that cmake & tests can find it - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64\bin;%PATH% - - cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. + - cmake -G "Visual Studio 12 2013 Win64" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. # Build, test and install - cmake --build . --config release - ctest --build-config release %CTEST_PARAMS% @@ -81,7 +81,7 @@ build_script: # %INSTALL%\lib is where the skeleton plugin is installed (see comment below) # %INSTALL%\bin is where parameter.dll is installed - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64\bin;%INSTALL%\lib;%INSTALL%\bin;%PATH% - - cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH=%INSTALL% %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem + - cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH=%INSTALL% %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem # Unfortunately, the skeleton test currently doesn't work on # multi-configuration build systems (Visual Studio is one of those) without # installing the plugin From ab300721b3d225c4ecb1af005394ce2d5275a6f4 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Fri, 16 Oct 2015 12:03:37 +0200 Subject: [PATCH 3/4] appveyor: do not pollute PATH with test-only paths We used to add the libxml2 directory to the PATH when building although we only intended to do so for the purpose of the tests. It led CMake to find libxml2 for the wrong reasons. It actually shouldn't have been able to find it since libxml2's dir wasn't added to the CMAKE_PREFIX_PATH. The directory where libxml2 has been extracted is now added to the prefix path and its 'bin' subdirectory also added to a variable only used during the tests. Signed-off-by: David Wagner --- appveyor.yml | 22 ++++++++++++---------- ctest/CMakeLists.txt | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f0c53745b..f19b317ff 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,6 +43,8 @@ install: 7z x -i"!asio*/include" asio-1.10.6.tar) - if not exist catch ( wget --no-check-certificate https://raw.github.com/philsquared/Catch/master/single_include/catch.hpp --directory-prefix catch ) + - set DEBUG_LIBXML2_PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64-debug + - set RELEASE_LIBXML2_PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64 # Setup Visual studio build environement - '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64' @@ -59,33 +61,33 @@ build_script: - mkdir build && cd build - mkdir 64bits-debug && cd 64bits-debug - # Add debug libxml2.dll in the path so that cmake & tests can find it - - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64-debug\bin;%PATH% - - cmake -G "NMake Makefiles" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" ..\.. + # Add debug libxml2.dll in the path so that tests can find it + - set TEST_PATH=%DEBUG_LIBXML2_PATH%\bin + - cmake -G "NMake Makefiles" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%;%DEBUG_LIBXML2_PATH%" ..\.. - cmake --build . --config debug - ctest --build-config debug %CTEST_PARAMS% - - set PATH=%OLD_PATH% && cd .. + - cd .. - mkdir 64bits-release & cd 64bits-release - # Add release libxml2.dll in the path so that cmake & tests can find it - - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64\bin;%PATH% - - cmake -G "Visual Studio 12 2013 Win64" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. + # Add debug libxml2.dll in the path so that tests can find it + - set TEST_PATH=%RELEASE_LIBXML2_PATH%\bin + - cmake -G "Visual Studio 12 2013 Win64" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%;%RELEASE_LIBXML2_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. # Build, test and install - cmake --build . --config release - ctest --build-config release %CTEST_PARAMS% - cmake --build . --config release --target install - - set PATH=%OLD_PATH% && cd .. + - cd .. # build and test the skeleton plugin against the previously-installed build; this serves as a smoke test of the whole stack - mkdir skeleton && cd skeleton # %INSTALL%\lib is where the skeleton plugin is installed (see comment below) # %INSTALL%\bin is where parameter.dll is installed - - set OLD_PATH=%PATH% && set PATH=%APPVEYOR_BUILD_FOLDER%\libxml2-x86_64\bin;%INSTALL%\lib;%INSTALL%\bin;%PATH% + # Also add the path where the release libxml2.dll has been extracted + - set TEST_PATH=%RELEASE_LIBXML2_PATH%\bin;%INSTALL%\lib;%INSTALL%\bin - cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH=%INSTALL% %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem # Unfortunately, the skeleton test currently doesn't work on # multi-configuration build systems (Visual Studio is one of those) without # installing the plugin - cmake --build . --config release --target install - ctest --build-config release %CTEST_PARAMS% - - set PATH=%OLD_PATH% && cd .. - cd .. diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index caea468fa..8edb93d0a 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -60,7 +60,7 @@ function(set_test_env TestName) # # Thus all `;` in environment variables must be escaped # before inserting them in the ENVIRONMENT PROPERTY. - string(REPLACE ";" "\\;" TEST_PATH "$ENV{PATH}") + string(REPLACE ";" "\\;" TEST_PATH "$ENV{PATH};$ENV{TEST_PATH}") string(REPLACE ";" "\\;" TEST_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") string(REPLACE ";" "\\;" TEST_PYTHONPATH "$ENV{PYTHONPATH}") From e0a71cf7a975f77ce6500d926fec549cb9f9c0cd Mon Sep 17 00:00:00 2001 From: David Wagner Date: Fri, 16 Oct 2015 14:22:27 +0200 Subject: [PATCH 4/4] CMake: Makes it easy to list all possible build config options Use `cmake -L` and optionaly filter-out `^CMAKE_`. This is done by hiding cache entries that are not one of those. Signed-off-by: David Wagner --- README.md | 3 +++ bindings/python/CMakeLists.txt | 4 ++++ remote-processor/CMakeLists.txt | 2 ++ test/catch/CMakeLists.txt | 2 +- test/test-fixed-point-parameter/CMakeLists.txt | 4 ++-- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35509842e..00d6af07c 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ preinstalled on most distributions). If you want to *build the code documentation*, you'll need `doxygen` and `graphviz`. This doc is already available to you - see the wiki. +**To list all available configuration options, try** `cmake -L` (you may also +filter-out lines starting with `CMAKE_`). + ### How-To If you are already familiar with CMake, you know what to do. diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 676e4879f..fe3648308 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -27,6 +27,10 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. find_package(SWIG) +# Hide these variables from CMake GUIs and `cmake -L` +set_property(CACHE + SWIG_DIR SWIG_EXECUTABLE SWIG_VERSION + PROPERTY ADVANCED TRUE) if (NOT SWIG_FOUND) message(FATAL_ERROR "Swig is needed to compile the Python bindings but was not found." diff --git a/remote-processor/CMakeLists.txt b/remote-processor/CMakeLists.txt index a84aedb38..acb84d397 100644 --- a/remote-processor/CMakeLists.txt +++ b/remote-processor/CMakeLists.txt @@ -44,6 +44,8 @@ find_package(Threads REQUIRED) # If asio isn't installed in a standard directory, add the correct directory to # CMAKE_PREFIX_PATH (see the main README for more information). find_path(ASIO_DIR NAMES asio.hpp) +# Hide this variable from CMake GUIs and `cmake -L` +set_property(CACHE ASIO_DIR PROPERTY ADVANCED TRUE) # FIXME: asio header should not leak to remote-processor users target_include_directories(remote-processor SYSTEM PUBLIC "${ASIO_DIR}") diff --git a/test/catch/CMakeLists.txt b/test/catch/CMakeLists.txt index b76754e08..ed7386959 100644 --- a/test/catch/CMakeLists.txt +++ b/test/catch/CMakeLists.txt @@ -31,6 +31,7 @@ if(BUILD_TESTING) # Unfortunately gtest is very hard to setup as not binary distributed # catch is only one header so it is very easy find_path(CATCH_HEADER catch.hpp) + set_property(CACHE CATCH_HEADER PROPERTY ADVANCED TRUE) if (NOT CATCH_HEADER) message(SEND_ERROR " Catch header `catch.hpp' could not be found. @@ -40,7 +41,6 @@ if(BUILD_TESTING) https://raw.github.com/philsquared/Catch/master/single_include/catch.hpp Then either: - append the download folder to the `CMAKE_INCLUDE_PATH' or `CMAKE_PREFIX_PATH' variable - - set cmake variable `CATCH_HEADER' to the header directory - copy it in a standard location (/usr/include on most linux distribution). To remove test dependancies all together, set `BUILD_TESTING' to false. It will disable test targets, thus the framework they depend on.") diff --git a/test/test-fixed-point-parameter/CMakeLists.txt b/test/test-fixed-point-parameter/CMakeLists.txt index 0324aed14..06732eb5c 100644 --- a/test/test-fixed-point-parameter/CMakeLists.txt +++ b/test/test-fixed-point-parameter/CMakeLists.txt @@ -27,11 +27,11 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (BUILD_TESTING AND PYTHON_BINDINGS) - find_program(python2 python2) + find_package(PythonInterp 2.7 REQUIRED) add_test(NAME fix_point_parameter WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${python2} Main.py) + COMMAND ${PYTHON_EXECUTABLE} Main.py) # Custom function defined in the top-level CMakeLists set_test_env(fix_point_parameter)