Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

create_find_project.cmake 2.76 KB
Newer Older
Pierre Aubert's avatar
Pierre Aubert committed
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61


set(FIND_PROJECT_TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/template_find_project.cmake" CACHE STRING "Name of the file which contains the template to generate FindProgram.cmake files")
set(FIND_HEADER_PROJECT_TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/template_find_header_project.cmake" CACHE STRING "Name of the file which contains the template to generate FindProgram.cmake files but only with header")

# Create the target to create the find cmake file
# 	projectName : name of the project to be used
# 	libraryTargetName : name of the library to be searched
# 	headerFile : header to be searched
# 	extraIncludeFile : extra include file to be used
function(phoenix_create_find projectName libraryTargetName headerFile extraIncludeFile)
	set(findFileName "Find${projectName}.cmake")
	string(TOUPPER ${projectName} PROJECT_NAME_UPPER)
	
	set(fullDependModule "")
	set(EXTRA_DEPENDENCIES_LIB "")
	foreach(dependencyModule ${ARGN})
		string(APPEND fullDependModule "find_package(${dependencyModule} REQUIRED)\n")
		string(TOUPPER ${dependencyModule} DEPENDENCY_MODULE_UPPER)
		string(APPEND EXTRA_DEPENDENCIES_LIB " \${${DEPENDENCY_MODULE_UPPER}}")
	endforeach(dependencyModule)
	set(PHOENIX_PACKAGE_PEDENDENCIES "${fullDependModule}")
	
	if(extraIncludeFile STREQUAL "")
		set(EXTRA_INCLUDE_CMAKE "")
	else()
		set(EXTRA_INCLUDE_CMAKE "include(${CMAKE_MODULE_PATH}/${extraIncludeFile})")
	endif()
	configure_file(${FIND_PROJECT_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${findFileName} @ONLY)
	
	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${findFileName} DESTINATION share/cmake)
endfunction(phoenix_create_find)

# Create the target to create the find cmake file
# 	projectName : name of the project to be used
# 	libraryTargetName : name of the library to be searched
# 	headerFile : header to be searched
# 	extraIncludeFile : extra include file to be used
function(phoenix_create_find_header projectName headerFile extraIncludeFile)
	set(findFileName "Find${projectName}.cmake")
	string(TOUPPER ${projectName} PROJECT_NAME_UPPER)
	
	set(fullDependModule "")
	set(EXTRA_DEPENDENCIES_LIB "")
	foreach(dependencyModule ${ARGN})
		string(APPEND fullDependModule "find_package(${dependencyModule} REQUIRED)\n")
		string(TOUPPER ${dependencyModule} DEPENDENCY_MODULE_UPPER)
		string(APPEND EXTRA_DEPENDENCIES_LIB " \${${DEPENDENCY_MODULE_UPPER}}")
	endforeach(dependencyModule)
	set(PHOENIX_PACKAGE_PEDENDENCIES "${fullDependModule}")
	
	if(extraIncludeFile STREQUAL "")
		set(EXTRA_INCLUDE_CMAKE "")
	else()
		set(EXTRA_INCLUDE_CMAKE "include(${CMAKE_MODULE_PATH}/${extraIncludeFile})")
	endif()
	configure_file(${FIND_HEADER_PROJECT_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${findFileName} @ONLY)
	
	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${findFileName} DESTINATION share/cmake)
endfunction(phoenix_create_find_header)