Commit 5e91b8fd authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add find program template

parent 41d2a296
Pipeline #119596 passed with stages
in 4 minutes and 41 seconds
/** @brief Tool to create Beamer presentation automatically
*
*
*/
......@@ -2,6 +2,7 @@
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
......@@ -34,7 +35,7 @@ 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
# 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")
......@@ -59,3 +60,30 @@ function(phoenix_create_find_header projectName headerFile extraIncludeFile)
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)
##########################################################################
# #
# test de présence du programme de @PROJECT_NAME_UPPER@ #
# #
##########################################################################
@PHOENIX_PACKAGE_PEDENDENCIES@
if(@PROJECT_NAME_UPPER@_FOUND)
@EXTRA_INCLUDE_CMAKE@
return()
endif()
#Find the program
find_path(@PROJECT_NAME_UPPER@_EXECUTABLE_DIR
NAMES @programTargetName@
PATHS "${@PROJECT_NAME_UPPER@_PREFIX}/bin" ${CMAKE_INSTALL_PREFIX}/bin $ENV{HOME}/usr/bin ${CMAKE_INCLUDE_PATH}/bin /usr/bin /usr/local/bin /bin
)
if(@PROJECT_NAME_UPPER@_EXECUTABLE_DIR)
message(STATUS "Found program @PROJECT_NAME_UPPER@ : ${@PROJECT_NAME_UPPER@_EXECUTABLE_DIR}")
set(@PROJECT_NAME_UPPER@_EXECUTABLE_DIR "${@PROJECT_NAME_UPPER@_EXECUTABLE_DIR}" CACHE STRING "@PROJECT_NAME_UPPER@ program directory")
set(@PROJECT_NAME_UPPER@_EXECUTABLE "${@PROJECT_NAME_UPPER@_EXECUTABLE_DIR}/@programTargetName@" CACHE STRING "@PROJECT_NAME_UPPER@ program")
else(@PROJECT_NAME_UPPER@_EXECUTABLE_DIR)
message(FATAL_ERROR "program @PROJECT_NAME_UPPER@ not found")
endif(@PROJECT_NAME_UPPER@_EXECUTABLE_DIR)
set(@PROJECT_NAME_UPPER@_FOUND "YES" CACHE BOOL "@PROJECT_NAME_UPPER@ project found")
@EXTRA_INCLUDE_CMAKE@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment