File: CreateUnitTest.cmake

package info (click to toggle)
saunafs 5.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,820 kB
  • sloc: cpp: 109,287; sh: 18,755; python: 4,737; ansic: 4,023; makefile: 60; awk: 17
file content (42 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#  Copyright 2017 Skytechnology sp. z o.o.
#  Copyright 2023 Leil Storage OÜ
#
#  This file is part of SaunaFS.
#
#  SaunaFS is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, version 3.
#
#  SaunaFS is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with SaunaFS  If not, see <http://www.gnu.org/licenses/>.

function(create_unittest TEST_NAME)
  if(NOT BUILD_TESTS OR ARGC EQUAL 1)
    return()
  endif()
  list(REMOVE_AT ARGV 0)
  set(TEST_LIBRARY_NAME ${TEST_NAME}_unittest)

  add_library(${TEST_LIBRARY_NAME} ${ARGV})

  list(FIND UNITTEST_TEST_NAMES ${TEST_NAME} result)
  if (${result} EQUAL -1)
    set(TMP ${UNITTEST_TEST_NAMES})
    list(APPEND TMP ${TEST_NAME})
    set(UNITTEST_TEST_NAMES ${TMP} CACHE INTERNAL "" FORCE)
  endif()
endfunction(create_unittest)

function(link_unittest TEST_NAME)
  if(NOT BUILD_TESTS OR ARGC EQUAL 1)
    return()
  endif()
  list(REMOVE_AT ARGV 0)

  set(${TEST_NAME}_UNITTEST_LINKLIST ${ARGV} CACHE INTERNAL "" FORCE)
endfunction(link_unittest)