summaryrefslogtreecommitdiffstats
path: root/cmake/modules/UseCheckAPI.cmake
blob: 1518fb4fe872a058ac6c08fa7730adf910b0a303 (plain)
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
# Add a target to call checkAPIs.pl on the specified source files
# The target is excluded from the ALL targte so must be manually
# specified in a build command.
# The target is added to the top-level checkAPIs target
#
# Parameters:
#   NAME: 	The name of the target, must be unique
#   SWITCHES:	Switches to be supplied to the script
#   SOURCES:	The sources to be checked

include(CMakeParseArguments)

macro( CHECKAPI )
	cmake_parse_arguments(CHECKAPI "DEBUG" "" "NAME;SWITCHES;SOURCES" ${ARGN} )

	if (CHECKAPI_UNPARSED_ARGUMENTS)
		message(FATAL_ERROR "CHECKAPIS Unknown argument: ${CHECKAPI_UNPARSED_ARGUMENTS}")
	endif()

	if( CHECKAPI_DEBUG )
		set (CHECKAPI_SWITCHES ${CHECKAPI_SWITCHES --debug)
	endif()

	set(TARGET_NAME checkAPI_${CHECKAPI_NAME})
	add_custom_target(${TARGET_NAME}
		COMMAND ${PERL_EXECUTABLE}
		  ${CMAKE_SOURCE_DIR}/tools/checkAPIs.pl
		  ${CHECKAPI_SWITCHES}
		  ${CHECKAPI_SOURCES}
		WORKING_DIRECTORY
		  ${CMAKE_CURRENT_SOURCE_DIR}
		COMMENT
		  "Running ${TARGET_NAME}"
	)
	add_dependencies(checkAPI ${TARGET_NAME})
	set_target_properties(${TARGET_NAME}
		PROPERTIES FOLDER "Auxiliary/CheckAPIs"
		EXCLUDE_FROM_ALL True
		EXCLUDE_FROM_DEFAULT_BUILD True
	)
ENDMACRO()