create_find_project.cmake 4.24 KB
Newer Older
Pierre Aubert's avatar
Pierre Aubert committed
1 2 3 4


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")
Pierre Aubert's avatar
Pierre Aubert committed
5
set(FIND_PROGRAM_PROJECT_TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/template_find_program.cmake" CACHE STRING "Name of the file which contains the template to generate FindProgram.cmake files but only with program")
Pierre Aubert's avatar
Pierre Aubert committed
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

# 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
Pierre Aubert's avatar
Pierre Aubert committed
38
# 	headerFile : header to be searched (will be used in the header template)
Pierre Aubert's avatar
Pierre Aubert committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
# 	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)

Pierre Aubert's avatar
Pierre Aubert committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
# 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
# 	programFile : header to be searched (will be used in the program template)
# 	extraIncludeFile : extra include file to be used
function(phoenix_create_find_program projectName programTargetName 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_PROGRAM_PROJECT_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${findFileName} @ONLY)
	
	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${findFileName} DESTINATION share/cmake)
endfunction(phoenix_create_find_program)