diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-07-13 23:43:41 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2014-07-13 23:43:41 -0500 |
commit | 35a8b1720631a6b700bf9a234d0444c3457ce197 (patch) | |
tree | ac78e5550187fd3d9f703209441d7d11cc8a7852 /tests | |
parent | 3f29c1a35113bfd2461dca76235f1812c8dfd6ef (diff) | |
download | ayatana-indicator-power-35a8b1720631a6b700bf9a234d0444c3457ce197.tar.gz ayatana-indicator-power-35a8b1720631a6b700bf9a234d0444c3457ce197.tar.bz2 ayatana-indicator-power-35a8b1720631a6b700bf9a234d0444c3457ce197.zip |
replace autoconf/automake with cmake
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 46 | ||||
-rw-r--r-- | tests/Makefile.am | 71 |
2 files changed, 46 insertions, 71 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..c5ad09d --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,46 @@ +# build libgtest +add_library (gtest STATIC + ${GTEST_SOURCE_DIR}/gtest-all.cc + ${GTEST_SOURCE_DIR}/gtest_main.cc) +set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR}) +set_target_properties (gtest PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -w) + +# add warnings +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${C_WARNING_ARGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-global-constructors") # Google Test + +# build the necessary schemas +set_directory_properties (PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled) +set_source_files_properties (gschemas.compiled GENERATED) + +# GSettings: +# compile the indicator-power schema into a gschemas.compiled file in this directory, +# and help the tests to find that file by setting -DSCHEMA_DIR +set (SCHEMA_DIR ${CMAKE_CURRENT_BINARY_DIR}) +add_definitions(-DSCHEMA_DIR="${SCHEMA_DIR}") +execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas + OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE + OUTPUT_STRIP_TRAILING_WHITESPACE) +add_custom_command (OUTPUT gschemas.compiled + DEPENDS ${CMAKE_BINARY_DIR}/data/com.canonical.indicator.power.gschema.xml + COMMAND cp -f ${CMAKE_BINARY_DIR}/data/*gschema.xml ${SCHEMA_DIR} + COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR}) + +# look for headers in our src dir, and also in the directories where we autogenerate files... +include_directories (${CMAKE_SOURCE_DIR}/src) +include_directories (${CMAKE_BINARY_DIR}/src) +include_directories (${CMAKE_CURRENT_BINARY_DIR}) + +### +### + +function(add_test_by_name name) + set (TEST_NAME ${name}) + add_executable (${TEST_NAME} ${TEST_NAME}.cc gschemas.compiled) + add_test (${TEST_NAME} ${TEST_NAME}) + add_dependencies (${TEST_NAME} libindicatorpowerservice) + target_link_libraries (${TEST_NAME} indicatorpowerservice gtest ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS}) +endfunction() +add_test_by_name(test-device) + diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 483bb8c..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -TESTS = -CLEANFILES = -BUILT_SOURCES = -check_PROGRAMS = - -### -### tests: stock tests on user-visible strings -### - -include $(srcdir)/Makefile.am.strings - -### -### gtest library -### - -check_LIBRARIES = libgtest.a -nodist_libgtest_a_SOURCES = \ - $(GTEST_SOURCE)/src/gtest-all.cc \ - $(GTEST_SOURCE)/src/gtest_main.cc - -AM_CPPFLAGS = $(GTEST_CPPFLAGS) -I${top_srcdir}/src -Wall -Werror -std=c++11 -AM_CXXFLAGS = $(GTEST_CXXFLAGS) - -### -### tests: indicator-power-device -### - -dear-reader-please-note-the-next-test-takes-90-seconds: - @echo "#!/bin/bash" > $@ - @echo "exit 0" >> $@ - @chmod +x $@ -TESTS += dear-reader-please-note-the-next-test-takes-90-seconds -CLEANFILES += dear-reader-please-note-the-next-test-takes-90-seconds - -TEST_LIBS = $(COVERAGE_LDFLAGS) libgtest.a -lpthread -TEST_CPPFLAGS = $(SERVICE_DEPS_CFLAGS) $(AM_CPPFLAGS) - -TESTS += test-device -check_PROGRAMS += test-device -test_device_SOURCES = test-device.cc -test_device_CPPFLAGS = $(TEST_CPPFLAGS) -Wall -Werror -Wextra -test_device_LDADD = \ - $(top_builddir)/src/libindicatorpower-service.a \ - $(SERVICE_DEPS_LIBS) \ - $(TEST_LIBS) - - -# (FIXME: incomplete) -# -### -### tests: indicator-power-service -### -# -# build a local copy of the GSettings schemas -#BUILT_SOURCES += gschemas.compiled -#CLEANFILES += gschemas.compiled -#gschemas.compiled: Makefile -# @glib-compile-schemas --targetdir=$(abs_builddir) $(top_builddir)/data -# -#TESTS += test-service -#check_PROGRAMS += test-service -#test_service_SOURCES = test-service.cc -#test_service_LDADD = $(TEST_LIBS) -#test_service_CPPFLAGS = $(TEST_CPPFLAGS) -DSCHEMA_DIR="\"$(top_builddir)/tests/\"" -# -#TESTS += test-dbus-listener -#check_PROGRAMS += test-dbus-listener -#test_dbus_listener_SOURCES = test-dbus-listener.cc -#test_dbus_listener_LDADD = $(TEST_LIBS) -#test_dbus_listener_CPPFLAGS = $(TEST_CPPFLAGS) -# |