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") 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") # 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 (will be used in the header template) # 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) # 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)