| 1 |
find_package(GMock) |
| 2 |
|
| 3 |
# gschemas.compiled |
| 4 |
|
| 5 |
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "gschemas.compiled") |
| 6 |
set_source_files_properties("gschemas.compiled" GENERATED) |
| 7 |
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 8 |
|
| 9 |
add_custom_command( |
| 10 |
OUTPUT "gschemas.compiled" |
| 11 |
DEPENDS "${CMAKE_BINARY_DIR}/data/org.ayatana.common.gschema.xml" |
| 12 |
COMMAND cp -f "${CMAKE_BINARY_DIR}/data/org.ayatana.common.gschema.xml" "${CMAKE_CURRENT_BINARY_DIR}" |
| 13 |
COMMAND ${COMPILE_SCHEMA_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}" |
| 14 |
) |
| 15 |
|
| 16 |
add_custom_target("gschemas-compiled" ALL DEPENDS "gschemas.compiled") |
| 17 |
|
| 18 |
# tst_utils |
| 19 |
|
| 20 |
add_executable(tst_utils tst_utils.cpp) |
| 21 |
target_compile_definitions(tst_utils PUBLIC SCHEMA_DIR="${CMAKE_CURRENT_BINARY_DIR}") |
| 22 |
target_link_options(tst_utils PRIVATE -no-pie) |
| 23 |
add_dependencies(tst_utils "gschemas-compiled") |
| 24 |
target_include_directories(tst_utils PUBLIC "${CMAKE_SOURCE_DIR}/src") |
| 25 |
|
| 26 |
target_link_libraries(tst_utils |
| 27 |
ayatana-common |
| 28 |
${DEPS_LIBRARIES} |
| 29 |
${GTEST_LIBRARIES} |
| 30 |
${GTEST_BOTH_LIBRARIES} |
| 31 |
${GMOCK_LIBRARIES} |
| 32 |
) |
| 33 |
|
| 34 |
add_test(TstUtils tst_utils) |
| 35 |
|
| 36 |
# utils.h |
| 37 |
|
| 38 |
file(COPY "${CMAKE_SOURCE_DIR}/src/utils.h" DESTINATION "${CMAKE_BINARY_DIR}/src/ayatana/common") |
| 39 |
|
| 40 |
# tst_utils.c |
| 41 |
|
| 42 |
add_custom_command( |
| 43 |
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/tst_utils.c" |
| 44 |
DEPENDS "src" |
| 45 |
DEPENDS "gschemas-compiled" |
| 46 |
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 47 |
COMMAND |
| 48 |
${VALA_COMPILER} |
| 49 |
--pkg AyatanaCommon |
| 50 |
--pkg gio-2.0 |
| 51 |
--vapidir=${CMAKE_BINARY_DIR}/src |
| 52 |
--ccode tst_utils.vala |
| 53 |
--directory=${CMAKE_CURRENT_BINARY_DIR} |
| 54 |
) |
| 55 |
|
| 56 |
# tst_utils_vala |
| 57 |
|
| 58 |
if (VALA_COMPILER) |
| 59 |
|
| 60 |
add_executable("tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}/tst_utils.c") |
| 61 |
target_include_directories("tst_utils_vala" PUBLIC "${DEPS_INCLUDE_DIRS};${CMAKE_BINARY_DIR}/src") |
| 62 |
target_link_libraries("tst_utils_vala" "${DEPS_LIBRARIES} -layatana-common -L${CMAKE_BINARY_DIR}/src") |
| 63 |
target_link_directories("tst_utils_vala" PUBLIC "${CMAKE_BINARY_DIR}/src") |
| 64 |
add_dependencies("tst_utils_vala" "src") |
| 65 |
|
| 66 |
add_test(NAME "TstUtilsVala" COMMAND "${CMAKE_CURRENT_BINARY_DIR}/tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}") |
| 67 |
endif() |