-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding licence for cmake modules
- Loading branch information
Showing
7 changed files
with
99 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,73 @@ | ||
# | ||
# Copyright (c) 2007 Daniel Gollub <[email protected]> | ||
# Copyright (c) 2007-2018 Andreas Schneider <[email protected]> | ||
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <[email protected]> | ||
# | ||
# Redistribution and use is allowed according to the terms of the BSD license. | ||
# | ||
# Modifed version from https://github.com/xbmc/libssh/blob/667fb5f9a9c96f210583dbfb11755c43250c5e55/cmake/Modules/AddCMockaTest.cmake | ||
#.rst: | ||
# AddTestCMocka | ||
# ------------- | ||
# | ||
# This file provides a function to add a test | ||
# | ||
# Functions provided | ||
# ------------------ | ||
# | ||
# :: | ||
# | ||
# add_cmocka_test(target_name | ||
# SOURCES src1 src2 ... srcN | ||
# [COMPILE_OPTIONS opt1 opt2 ... optN] | ||
# [LINK_OPTIONS lopt1 lop2 .. loptN] | ||
# [PRIVATE_ACCESS ON/OFF] | ||
# [LINK_TARGETS target1 target2 .. targetN] | ||
# ) | ||
# | ||
# ``target_name``: | ||
# Required, expects the name of the test which will be used to define a target | ||
# | ||
# ``SOURCES``: | ||
# Required, expects one or more source files names | ||
# | ||
# ``COMPILE_OPTIONS``: | ||
# Optional, expects one or more options to be passed to the compiler | ||
# | ||
# ``LINK_OPTIONS``: | ||
# Optional, expects one or more options to be passed to the linker | ||
# | ||
# ``PRIVATE_ACCESS``: | ||
# Optional, when ON, tests are granted access to az_core private layer | ||
# | ||
# ``LINK_TARGETS``: | ||
# Optional, expects one or more targets from the same project to be passed to cmake target linker | ||
# | ||
# | ||
# Example: | ||
# | ||
# .. code-block:: cmake | ||
# | ||
# add_cmocka_test(my_test | ||
# SOURCES my_test.c other_source.c | ||
# COMPILE_OPTIONS -g -Wall | ||
# LINK_OPTIONS -Wl,--enable-syscall-fixup | ||
# PRIVATE_ACCESS ON | ||
# LINK_TARGETS target1, target2 | ||
# ) | ||
# | ||
# Where ``my_test`` is the name of the test, ``my_test.c`` and | ||
# ``other_source.c`` are sources for the binary, ``-g -Wall`` are compiler | ||
# options to be used, ``-Wl,--enable-syscall-fixup`` is an option passed to the linker, | ||
# ``PRIVATE_ACCESS`` is ON to let tests access private layer from az_core and ``LINK_TAGETS``` | ||
# list all the cmake tagets to link to | ||
# | ||
|
||
find_package(cmocka CONFIG REQUIRED) | ||
|
||
enable_testing() | ||
include(CTest) | ||
|
||
if (CMAKE_CROSSCOMPILING) | ||
if (WIN32) | ||
find_program(WINE_EXECUTABLE | ||
NAMES wine) | ||
set(TARGET_SYSTEM_EMULATOR ${WINE_EXECUTABLE} CACHE INTERNAL "") | ||
endif() | ||
endif() | ||
|
||
function(ADD_CMOCKA_TEST_ENVIRONMENT _TARGET_NAME) | ||
if (WIN32 OR CYGWIN OR MINGW) | ||
file(TO_NATIVE_PATH "${cmocka-library_BINARY_DIR}" CMOCKA_DLL_PATH) | ||
|
||
if (TARGET_SYSTEM_EMULATOR) | ||
set(DLL_PATH_ENV "WINEPATH=${CMOCKA_DLL_PATH};$ENV{WINEPATH}") | ||
else() | ||
set(DLL_PATH_ENV "PATH=${CMOCKA_DLL_PATH};$ENV{PATH}") | ||
endif() | ||
# | ||
# IMPORTANT NOTE: The set_tests_properties(), below, internally | ||
# stores its name/value pairs with a semicolon delimiter. | ||
# because of this we must protect the semicolons in the path | ||
# | ||
string(REPLACE ";" "\\;" DLL_PATH_ENV "${DLL_PATH_ENV}") | ||
|
||
set_tests_properties(${_TARGET_NAME} | ||
PROPERTIES | ||
ENVIRONMENT | ||
"${DLL_PATH_ENV}") | ||
endif() | ||
endfunction() | ||
|
||
set(MATH_LIB_UNIX "") | ||
if (UNIX) | ||
set(MATH_LIB_UNIX "m") | ||
|
@@ -122,6 +156,4 @@ function(ADD_CMOCKA_TEST _TARGET_NAME) | |
${TARGET_SYSTEM_EMULATOR} ${_TARGET_NAME} | ||
) | ||
|
||
add_cmocka_test_environment(${_TARGET_NAME}) | ||
|
||
endfunction (ADD_CMOCKA_TEST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters