From 456907595198a08d085368cc985a11a6de6c4047 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 20 Oct 2013 13:24:34 +0200 Subject: Fixed build of samples (now use CMake). --- .gitignore | 9 +++++---- .travis.yml | 11 ++++++++--- CMakeLists.txt | 14 ++++++++++++++ examples/.gitignore | 1 - examples/CMakeLists.txt | 38 ++++++++++++++++++++++++++++++++++++++ examples/Makefile | 8 -------- examples/viewer/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ examples/viewer/Makefile | 18 ------------------ examples/viewer/viewer.cpp | 4 ++-- test-outsourced-build.sh | 2 +- 10 files changed, 99 insertions(+), 37 deletions(-) delete mode 100644 examples/.gitignore create mode 100644 examples/CMakeLists.txt delete mode 100644 examples/Makefile create mode 100644 examples/viewer/CMakeLists.txt delete mode 100644 examples/viewer/Makefile diff --git a/.gitignore b/.gitignore index 78018a46..9976ce0d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,10 @@ doc/html/* /run-tests # CMake-generated / Build files -/CMakeFiles/ -/CMakeCache.txt +CMakeFiles/ +CMakeCache.txt /_CPack_Packages/ -/cmake_install.cmake +cmake_install.cmake /CPackConfig.cmake /CPackSourceConfig.cmake /Doxyfile @@ -28,7 +28,8 @@ doc/html/* /vmime/export-static.hpp /vmime/export-shared.hpp /COPYING.txt -/build/ +build/ +Makefile # Outsourced build test /_build/ diff --git a/.travis.yml b/.travis.yml index c5f04610..c9c38322 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,20 @@ compiler: # Settings env: - - CTEST_OUTPUT_ON_FAILURE=1 OPTIONS="-DVMIME_SENDMAIL_PATH=/path/to/sendmail -DCMAKE_BUILD_TYPE=Debug -DVMIME_BUILD_TESTS=ON" - - CTEST_OUTPUT_ON_FAILURE=1 OPTIONS="-DVMIME_SENDMAIL_PATH=/path/to/sendmail -DCMAKE_BUILD_TYPE=Debug -DVMIME_BUILD_TESTS=ON -DVMIME_CHARSETCONV_LIB_IS_ICONV=OFF -DVMIME_CHARSETCONV_LIB_IS_ICU=ON" - - CTEST_OUTPUT_ON_FAILURE=1 OPTIONS="-DVMIME_SENDMAIL_PATH=/path/to/sendmail -DCMAKE_BUILD_TYPE=Debug -DVMIME_BUILD_TESTS=ON -DVMIME_TLS_SUPPORT_LIB_IS_GNUTLS=OFF -DVMIME_TLS_SUPPORT_LIB_IS_OPENSSL=ON" + # -- default configuration (iconv + GnuTLS) + - CTEST_OUTPUT_ON_FAILURE=1 OPTIONS="-DVMIME_SENDMAIL_PATH=/path/to/sendmail -DCMAKE_BUILD_TYPE=Debug -DVMIME_BUILD_TESTS=ON -DVMIME_BUILD_SAMPLES=ON" + # -- ICU + - CTEST_OUTPUT_ON_FAILURE=1 OPTIONS="-DVMIME_SENDMAIL_PATH=/path/to/sendmail -DCMAKE_BUILD_TYPE=Debug -DVMIME_BUILD_TESTS=ON -DVMIME_BUILD_SAMPLES=ON -DVMIME_CHARSETCONV_LIB_IS_ICONV=OFF -DVMIME_CHARSETCONV_LIB_IS_ICU=ON" + # -- OpenSSL + - CTEST_OUTPUT_ON_FAILURE=1 OPTIONS="-DVMIME_SENDMAIL_PATH=/path/to/sendmail -DCMAKE_BUILD_TYPE=Debug -DVMIME_BUILD_TESTS=ON -DVMIME_BUILD_SAMPLES=ON -DVMIME_TLS_SUPPORT_LIB_IS_GNUTLS=OFF -DVMIME_TLS_SUPPORT_LIB_IS_OPENSSL=ON" # Make sure some required tools/libraries are installed install: - sudo apt-get update >/dev/null - sudo apt-get -q install cmake libcppunit-dev valgrind - sudo apt-get -q install libgsasl7-dev libgnutls-dev libssl-dev libicu-dev + # -- for the samples + - sudo apt-get -q install libgtk-3-dev # Run the build script script: diff --git a/CMakeLists.txt b/CMakeLists.txt index c3680df5..0e925136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,6 +329,20 @@ IF(VMIME_BUILD_TESTS) ENDIF() +############################################################################## +# Examples + +OPTION( + VMIME_BUILD_SAMPLES + "Build samples (in 'examples' directory)" + ON +) + +IF(VMIME_BUILD_SAMPLES) + ADD_SUBDIRECTORY(examples) +ENDIF() + + ############################################################################## # Packaging / Distribution diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index 4fef1718..00000000 --- a/examples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/example[0-9] diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..9e6998fb --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,38 @@ + +IF(VMIME_BUILD_SAMPLES) + + ADD_SUBDIRECTORY(viewer) + + FILE( + GLOB + VMIME_SAMPLES_SRC_FILES + ${CMAKE_SOURCE_DIR}/examples/*.cpp + ) + + # Build one file for each sample + FOREACH(VMIME_SAMPLE_SRC_FILE ${VMIME_SAMPLES_SRC_FILES}) + + GET_FILENAME_COMPONENT(VMIME_SAMPLE_NAME "${VMIME_SAMPLE_SRC_FILE}" NAME_WE) + + ADD_EXECUTABLE( + ${VMIME_SAMPLE_NAME} + ${VMIME_SAMPLE_SRC_FILE} + ) + + TARGET_LINK_LIBRARIES( + ${VMIME_SAMPLE_NAME} + ${VMIME_LIBRARY_NAME} + ) + + ADD_DEPENDENCIES( + ${VMIME_SAMPLE_NAME} + ${VMIME_LIBRARY_NAME} + ) + + ENDFOREACH() + +ELSE() + + MESSAGE(FATAL_ERROR "Examples are not to be built (set VMIME_BUILD_SAMPLES to YES.") + +ENDIF() diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 640ba253..00000000 --- a/examples/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: example1 example6 - -example1: example1.cpp ../libvmime-debug.a - g++-mp-4.8 -o example1 example1.cpp -I.. ../libvmime-debug.a -L /opt/local/lib -lgnutls -lgsasl -liconv - -example6: example6.cpp ../libvmime-debug.a - g++-mp-4.8 -o example6 example6.cpp -I.. ../libvmime-debug.a -L /opt/local/lib -lgnutls -lgsasl -liconv - diff --git a/examples/viewer/CMakeLists.txt b/examples/viewer/CMakeLists.txt new file mode 100644 index 00000000..c8d93163 --- /dev/null +++ b/examples/viewer/CMakeLists.txt @@ -0,0 +1,31 @@ + +IF(VMIME_BUILD_SAMPLES) + + FIND_PACKAGE(PkgConfig REQUIRED) + PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0) + + INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS}) + LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS}) + ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER}) + + ADD_EXECUTABLE( + viewer + viewer.cpp + ) + + TARGET_LINK_LIBRARIES( + viewer + ${VMIME_LIBRARY_NAME} + ${GTK3_LIBRARIES} + ) + + ADD_DEPENDENCIES( + viewer + ${VMIME_LIBRARY_NAME} + ) + +ELSE() + + MESSAGE(FATAL_ERROR "Examples are not to be built (set VMIME_BUILD_SAMPLES to YES.") + +ENDIF() diff --git a/examples/viewer/Makefile b/examples/viewer/Makefile deleted file mode 100644 index f0401c5d..00000000 --- a/examples/viewer/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -COMPILER=g++ -CFLAGS=-g -I ../.. `pkg-config --cflags gtk+-2.0` -LDFLAGS=-I ../.. `pkg-config --libs gtk+-2.0` -lgnutls -lgsasl - - -viewer: viewer.o ../../libvmime-debug.a - $(COMPILER) $(LDFLAGS) -o viewer viewer.o ../../libvmime-debug.a - -viewer.o: viewer.cpp - $(COMPILER) $(CFLAGS) -c -o viewer.o viewer.cpp - -../../libvmime-debug.a: - @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - @echo "! You must build VMime library before compiling the example !" - @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - @false - diff --git a/examples/viewer/viewer.cpp b/examples/viewer/viewer.cpp index c684c140..77303fa6 100644 --- a/examples/viewer/viewer.cpp +++ b/examples/viewer/viewer.cpp @@ -52,14 +52,14 @@ vmime::ref currentMessage = NULL; -void insertRowInModel(GtkTreeStore* model, vmime::ref comp, GtkTreeIter* parent = NULL) +void insertRowInModel(GtkTreeStore* model, vmime::ref comp, GtkTreeIter* parent = NULL) { GtkTreeIter iter; gtk_tree_store_append(model, &iter, parent); gtk_tree_store_set(model, &iter, 0, typeid(*comp).name(), 1, comp.get(), -1); - const std::vector > children = comp->getChildComponents(); + const std::vector > children = comp->getChildComponents(); for (int i = 0 ; i < children.size() ; ++i) { diff --git a/test-outsourced-build.sh b/test-outsourced-build.sh index 6858beec..11d6732c 100755 --- a/test-outsourced-build.sh +++ b/test-outsourced-build.sh @@ -5,7 +5,7 @@ cd _build rm -f ../CMakeCache.txt ../vmime/config.hpp ../vmime/export-static.hpp ../vmime/export-shared.hpp #cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DVMIME_BUILD_SHARED_LIBRARY=NO #cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DVMIME_BUILD_TESTS=YES -cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DVMIME_BUILD_TESTS=YES -DVMIME_TLS_SUPPORT_LIB_IS_OPENSSL=ON -DVMIME_TLS_SUPPORT_LIB_IS_GNUTLS=OFF -DCMAKE_BUILD_TYPE=Release +cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DVMIME_BUILD_TESTS=YES -DVMIME_BUILD_SAMPLES=YES -DVMIME_TLS_SUPPORT_LIB_IS_OPENSSL=ON -DVMIME_TLS_SUPPORT_LIB_IS_GNUTLS=OFF -DCMAKE_BUILD_TYPE=Release cmake .. -L make make install -- cgit v1.2.3