[evolution-data-server/wip/cmake] Build camel/tests as part of 'check' target



commit 03358f788972d122d90246acfb032de316c8a406
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 21 21:51:50 2016 +0200

    Build camel/tests as part of 'check' target

 CMakeLists.txt                         |    5 ++
 camel/CMakeLists.txt                   |    1 +
 camel/tests/CMakeLists.txt             |   53 +++++++++++++++++++++++++
 camel/tests/folder/CMakeLists.txt      |   15 +++++++
 camel/tests/lib/CMakeLists.txt         |   68 ++++++++++++++++++++++++++++++++
 camel/tests/message/CMakeLists.txt     |    7 +++
 camel/tests/mime-filter/CMakeLists.txt |    8 ++++
 camel/tests/misc/CMakeLists.txt        |   11 +++++
 camel/tests/smime/CMakeLists.txt       |    7 +++
 cmake/modules/CheckTarget.cmake        |   20 +++++++++
 cmake/modules/SetupBuildFlags.cmake    |    1 -
 11 files changed, 195 insertions(+), 1 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa4efe3..621b0e2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -202,6 +202,7 @@ unset(optupper)
 # ******************************
 
 include(CodeCoverageGCOV)
+include(CheckTarget)
 include(DistTarget)
 include(GLibTools)
 include(PkgConfigEx)
@@ -215,6 +216,10 @@ include(FindSMIME)
 
 add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
 
+if(ENABLE_MAINTAINER_MODE)
+       set(BUILD_TESTING ON)
+endif(ENABLE_MAINTAINER_MODE)
+
 # Setup compiler/linker flags
 setup_build_flags(${ENABLE_MAINTAINER_MODE})
 
diff --git a/camel/CMakeLists.txt b/camel/CMakeLists.txt
index b5633d3..6cd088d 100644
--- a/camel/CMakeLists.txt
+++ b/camel/CMakeLists.txt
@@ -429,3 +429,4 @@ install(TARGETS camel-gpg-photo-saver
 )
 
 add_subdirectory(providers)
+add_subdirectory(tests)
diff --git a/camel/tests/CMakeLists.txt b/camel/tests/CMakeLists.txt
new file mode 100644
index 0000000..2c9bc8a
--- /dev/null
+++ b/camel/tests/CMakeLists.txt
@@ -0,0 +1,53 @@
+macro(add_camel_test_one _part _name _src_file)
+       set(_test_ident cameltest-${_part}-${_name})
+
+       # not using EXCLUDE_FROM_ALL to have the tests verified that they can be built
+       add_executable(${_test_ident} ${_src_file})
+
+       target_compile_definitions(${_test_ident} PRIVATE
+               -DG_LOG_DOMAIN=\"${_test_ident}\"
+               -DSOURCEDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+               -DTEST_DATA_DIR=\"${CMAKE_SOURCE_DIR}/camel/tests/data\"
+       )
+
+       target_compile_options(${_test_ident} PUBLIC
+               ${CAMEL_CFLAGS}
+       )
+
+       target_include_directories(${_test_ident} PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_BINARY_DIR}/camel
+               ${CMAKE_SOURCE_DIR}
+               ${CMAKE_SOURCE_DIR}/camel
+               ${CMAKE_SOURCE_DIR}/camel/tests/lib
+               ${CAMEL_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(${_test_ident}
+               camel
+               cameltest
+               cameltest-provider
+               ${CAMEL_LDFLAGS}
+       )
+
+       set_target_properties(${_test_ident} PROPERTIES
+               OUTPUT_NAME ${_name}}
+       )
+
+       add_check_test(${_test_ident})
+endmacro(add_camel_test_one)
+
+macro(add_camel_tests _part _tests)
+       foreach(test IN LISTS ${_tests})
+               if(NOT "${test}" STREQUAL "")
+                       add_camel_test_one(${_part} ${test} ${test}.c)
+               endif(NOT "${test}" STREQUAL "")
+       endforeach(test)
+endmacro(add_camel_tests)
+
+add_subdirectory(lib)
+add_subdirectory(message)
+add_subdirectory(folder)
+add_subdirectory(smime)
+add_subdirectory(misc)
+add_subdirectory(mime-filter)
diff --git a/camel/tests/folder/CMakeLists.txt b/camel/tests/folder/CMakeLists.txt
new file mode 100644
index 0000000..adaea8f
--- /dev/null
+++ b/camel/tests/folder/CMakeLists.txt
@@ -0,0 +1,15 @@
+set(TESTS
+       test1
+       test2
+       test3
+       test4
+       test5
+       test6
+       test7
+       test8
+       test9
+       test10
+       test11
+)
+
+add_camel_tests(folder TESTS)
diff --git a/camel/tests/lib/CMakeLists.txt b/camel/tests/lib/CMakeLists.txt
new file mode 100644
index 0000000..92bff2c
--- /dev/null
+++ b/camel/tests/lib/CMakeLists.txt
@@ -0,0 +1,68 @@
+set(SOURCES
+       camel-test.c
+       camel-test.h
+       messages.c
+       messages.h
+       addresses.c
+       addresses.h
+       folders.c
+       folders.h
+       session.c
+       session.h
+       address-data.h
+)
+
+add_library(cameltest STATIC ${SOURCES})
+
+add_dependencies(cameltest camel)
+
+target_compile_definitions(cameltest PRIVATE
+       -DG_LOG_DOMAIN=\"camel-test\"
+       -DCAMEL_BUILD_DIR=\"$(CMAKE_BINARY_DIR)/camel\"
+)
+
+target_compile_options(cameltest PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(cameltest PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(cameltest
+       camel
+       ${CAMEL_LDFLAGS}
+)
+
+add_library(cameltest-provider STATIC
+       camel-test-provider.c
+       camel-test-provider.h
+)
+
+add_dependencies(cameltest-provider camel)
+
+target_compile_definitions(cameltest-provider PRIVATE
+       -DG_LOG_DOMAIN=\"camel-test-provider\"
+       -DCAMEL_BUILD_DIR=\"$(CMAKE_BINARY_DIR)/camel\"
+)
+
+target_compile_options(cameltest-provider PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(cameltest-provider PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(cameltest-provider
+       camel
+       ${CAMEL_LDFLAGS}
+)
diff --git a/camel/tests/message/CMakeLists.txt b/camel/tests/message/CMakeLists.txt
new file mode 100644
index 0000000..e9f9bea
--- /dev/null
+++ b/camel/tests/message/CMakeLists.txt
@@ -0,0 +1,7 @@
+set(TESTS
+       test1
+       test2
+       test4
+)
+
+add_camel_tests(message TESTS)
diff --git a/camel/tests/mime-filter/CMakeLists.txt b/camel/tests/mime-filter/CMakeLists.txt
new file mode 100644
index 0000000..3035488
--- /dev/null
+++ b/camel/tests/mime-filter/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(TESTS
+       test1
+       test-crlf
+       test-charset
+       test-tohtml
+)
+
+add_camel_tests(mime-filter TESTS)
diff --git a/camel/tests/misc/CMakeLists.txt b/camel/tests/misc/CMakeLists.txt
new file mode 100644
index 0000000..7c0b02a
--- /dev/null
+++ b/camel/tests/misc/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(TESTS
+       test1
+       test2
+       url
+       url-scan
+       utf7
+       split
+       rfc2047
+)
+
+add_camel_tests(misc TESTS)
diff --git a/camel/tests/smime/CMakeLists.txt b/camel/tests/smime/CMakeLists.txt
new file mode 100644
index 0000000..3d122e6
--- /dev/null
+++ b/camel/tests/smime/CMakeLists.txt
@@ -0,0 +1,7 @@
+set(TESTS
+       pgp
+#      pgp-mime
+#      pkcs7
+)
+
+add_camel_tests(smime TESTS)
diff --git a/cmake/modules/CheckTarget.cmake b/cmake/modules/CheckTarget.cmake
new file mode 100644
index 0000000..debcc9d
--- /dev/null
+++ b/cmake/modules/CheckTarget.cmake
@@ -0,0 +1,20 @@
+# CheckTarget.cmake
+#
+# Defines a custom target 'check', which gathers test programs like 'make check'
+# This is taken from https://cmake.org/Wiki/CMakeEmulateMakeCheck
+#
+# What you do is to call command:
+# add_check_test(_name)
+#   where _name is the name of the test, as defined by add_executable()
+
+include(CTest)
+
+# Disable this not have verbose tests
+set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} -V)
+
+add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
+
+macro(add_check_test _name)
+       add_test(NAME ${_name} COMMAND ${_name})
+       add_dependencies(check ${_name})
+endmacro(add_check_test)
diff --git a/cmake/modules/SetupBuildFlags.cmake b/cmake/modules/SetupBuildFlags.cmake
index 6b7f3fc..a7d2aa4 100644
--- a/cmake/modules/SetupBuildFlags.cmake
+++ b/cmake/modules/SetupBuildFlags.cmake
@@ -76,6 +76,5 @@ macro(setup_build_flags _maintainer_mode)
                set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
                set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
                set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
-               set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -Wl,--no-undefined")
        endif(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"))
 endmacro()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]