Commit 3065e5cb authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Initial commit

parents
build
build2
.kdev4/
.tmp_project
*.kdev4
image: gitlab-registry.in2p3.fr/cta-lapp/phoenix_libs/phoenix/phoenix_minimal:0.2
stages:
- BuildTestinstall
- DocCoverage
- deploy
#- build
#- test
#- deploy
dailyBuildMasterAll:
#cache:
#untracked: true
#paths:
#- build/
stage: BuildTestinstall
script:
- export LD_LIBRARY_PATH=/usr/lib
- env
- mkdir -p build
- cd build
- >
cmake ..
-DCMAKE_INSTALL_PREFIX=/usr
-DSELF_TESTS_MODE=yes
- make all
- make install
- make test
only:
- branches
- tags
tags:
TestCoverage:
stage: DocCoverage
script:
- export LD_LIBRARY_PATH=/usr/lib
- env
- mkdir -p build coverage
- cd build
- >
cmake ..
-DCMAKE_INSTALL_PREFIX=/usr
-DSELF_TESTS_MODE=yes
-DCMAKE_BUILD_TYPE=Coverage
- make all
- make install
- make test
- make ExperimentalCoverage
- cd ../coverage
- gcovr -r ../ --html cov_report.html --html-details
- gcovr -r ../ --xml Coverage.xml
artifacts:
paths:
- coverage
expire_in: 1d
only:
- branches
- tags
tags:
Doc:
stage: DocCoverage
script:
- export LD_LIBRARY_PATH=/usr/lib
- env
#- git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixTex2Html.git
#- cd PhoenixTex2Html
#- ./install.sh /usr
#- cd ..
#- rm -fr PhoenixTex2Html
- rm -fr build public
- mkdir -p build
- mkdir -p public
- mkdir -p public/html
- cd build
- >
cmake ..
-DCMAKE_INSTALL_PREFIX=/usr
-DDOC_MODE=yes
- make all
- make install
- make doc
- scp -r doc/platex/* ../public
- scp -r doc/html/* ../public/html
artifacts:
paths:
- public
expire_in: 1d
only:
- branches
- tags
tags:
pages:
stage: deploy
script:
- mv coverage public/
artifacts:
paths:
- public
expire_in: 1d
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(cmake)
phoenix_base_project("PhoenixDebug" "1.5.7"
"Tool to ease debugging"
"https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixDebug")
pull_extra_module("StringUtils" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/StringUtils.git")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
phoenix_create_find(PhoenixDebug phoenix_debug phoenix_debug.h "" "StringUtils")
add_definitions(-DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
add_subdirectory(src)
if(SELF_TESTS_MODE)
include(CTest)
add_subdirectory(TESTS)
endif(SELF_TESTS_MODE)
if(DOC_MODE)
pull_extra_module("PhoenixTex2Html" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixTex2Html.git")
add_subdirectory(doc)
endif(DOC_MODE)
set(PHOENIX_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src;${PHOENIX_INCLUDE_DIRS}" CACHE INTERNAL "list of Phoenix include dirs")
This diff is collapsed.
![Phoenix logo](doc/logo.png)
----
Code
----
https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixDebug
Documentation
----
https://cta-lapp.pages.in2p3.fr//PHOENIX_LIBS/PhoenixDebug/
Requirements
------------
- c++ compiler >=5.3.1
- cmake > 3
- make
Installation for Users
----------------------
$ git clone https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixDebug.git
$ cd PhoenixDebug
$ ./install.sh
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
include(createLinuxPackages.cmake)
include(phoenix_base_project.cmake)
if(NOT MODULE_MODE)
include(rpath_utils.cmake)
include(pull_extra_module.cmake)
include(create_doc.cmake)
include(environnement_prefix.cmake)
include(create_find_project.cmake)
endif()
# Commands to create debian package with cmake
function(createLinuxPackages)
if(NOT MODULE_MODE)
set(CPACK_PACKAGE_NAME "${PROGRAM_NAME}" CACHE STRING "Name of the program")
set(CPACK_PACKAGE_VERSION "${PROGRAM_VERSION}" CACHE STRING "Version of the program")
set(CPACK_PACKAGE_VENDOR "Pierre Aubert" CACHE STRING "Vendor of the program")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROGRAM_DESCRIPTION_NO_QUOTE} CACHE STRING "Description of the program")
set(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README.md CACHE STRING "DOC of the program")
set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/README.md CACHE STRING "Welcome of the program")
set(CPACK_PACKAGE_HOMEPAGE_URL ${PROGRAM_HOMEPAGE} CACHE STRING "Homepage of the program")
set(CPACK_PACKAGE_CONTACT "pierre.aubert@lapp.in2p3.fr" CACHE STRING "Contact of the program")
set(CPACK_PACKAGE_ICON ${CMAKE_SOURCE_DIR}/doc/icon.bmp CACHE STRING "Icon of the program")
set(CPACK_PACKAGE_DESCRIPTION ${PROGRAM_DESCRIPTION_NO_QUOTE} CACHE STRING "Desription with quote of the program")
if(CREATE_DEB) #Ok for UBUNTU
set(CPACK_GENERATOR "DEB" CACHE STRING "Package type of the program")
set(CPACK_DEBIAN_PACKAGE_VERSION "${PROGRAM_VERSION}" CACHE STRING "Version of the program")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "pierre.aubert@lapp.in2p3.fr" CACHE STRING "Package maintainer of the program") #required
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PROGRAM_HOMEPAGE} CACHE STRING "Homepage of the program") #For the debian installer only
set(CPACK_DEBIAN_PACKAGE_DEPENDS "" CACHE STRING "Depends of the program")
endif(CREATE_DEB)
if(CREATE_RPM) #Need to install rmp package on ubuntu which contains rpmbuild
set(CPACK_GENERATOR "RPM" CACHE STRING "Package type of the program")
set(CPACK_RPM_PACKAGE_AUTOREQ "NO" CACHE STRING "Caracteristics of the program")
set(CPACK_RPM_PACKAGE_REQUIRES "" CACHE STRING "Depends of the program")
set(LIBRARY_DIRECTORY "lib64" CACHE STRING "define the library directory (especially for Fedora with the wtf lib64)" FORCE)
endif(CREATE_RPM)
# if(CREATE_DMG) #We should use DragNDrop or PackageMaker of osx
# set(CPACK_GENERATOR "DMG")
# endif(CREATE_DMG)
include(CPack)
# Has to be used :
# cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCREATE_DEB=yes -DSSE4.2=yes # Or whatever extension
# make -j 8
# cpack
endif()
endfunction(createLinuxPackages)
# Create the target to create the documentation of the current project
# projectName : name of the project to be used
# doxyfileName : name of the Doxyfile cmake macro to be used to generate the documentation
function(phoenix_create_doc projectName doxyfileName)
find_path(doxygen_BINNARY_DIR
NAMES doxygen
PATHS "${PHOENIX_PREFIX}/bin" ${CMAKE_INSTALL_PREFIX}/bin ${CMAKE_INCLUDE_PATH}/bin /usr/bin /usr/local/bin /bin $ENV{HOME}/usr/bin
)
if(doxygen_BINNARY_DIR)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html)
message(STATUS "program doxygen found create doc target by project ${projectName}")
file(GLOB_RECURSE allDocFiles ${CMAKE_SOURCE_DIR}/*.cpp *.h *.dox)
string(REGEX REPLACE "${CMAKE_BINARY_DIR}[^;]+;?" "" allDocFiles "${allDocFiles}")
set(PROJECT_LOGO ${CMAKE_CURRENT_SOURCE_DIR}/logo.png)
set(OUTPUT_DOC_DIR ${CMAKE_CURRENT_BINARY_DIR}/)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${doxyfileName} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
set(targetName "phoenix_doc_${projectName}")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc.txt
OUTPUT ${targetName}
COMMENT "doxygen documentation generation for project ${projectName}"
COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
DEPENDS ${allDocFiles}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(${targetName} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc.txt)
if(NOT TARGET doc)
add_custom_target(doc)
endif()
add_dependencies(doc ${targetName})
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/${projectName}/doc)
else()
message(STATUS "program doxygen not found for project ${projectName}")
endif()
endfunction(phoenix_create_doc)
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)
# Create the version header of the given program
# projectName : name of the project
# projectVersion : version of the project
function(create_version projectName projectVersion)
message(STATUS "Program ${projectName} version ${projectVersion}")
string(REPLACE "." ";" VERSION_STR_LIST ${projectVersion})
set(VERSION_LIST ${VERSION_STR_LIST})
list(LENGTH VERSION_LIST listLength)
list(GET VERSION_LIST 0 MAJOR_PROG_VERSION)
list(GET VERSION_LIST 1 MINOR_PROG_VERSION)
list(GET VERSION_LIST 2 PATCH_PROG_VERSION)
string(TOUPPER ${projectName} PROGRAM_UPPER_NAME)
string(TOLOWER ${projectName} PROGRAM_LOWER_NAME)
set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROGRAM_LOWER_NAME}_version.h)
set(DEFINE_MACRO_HEADER "__${PROGRAM_UPPER_NAME}_VERSION_H__")
file(WRITE ${OUTPUT_FILE} "\n")
file(APPEND ${OUTPUT_FILE} "/***************************************\n")
file(APPEND ${OUTPUT_FILE} " Auteur : Pierre Aubert\n")
file(APPEND ${OUTPUT_FILE} " Mail : aubertp7@gmail.com\n")
file(APPEND ${OUTPUT_FILE} " Licence : CeCILL-C\n")
file(APPEND ${OUTPUT_FILE} "****************************************/\n")
file(APPEND ${OUTPUT_FILE} "\n")
file(APPEND ${OUTPUT_FILE} "#ifndef ${DEFINE_MACRO_HEADER}\n")
file(APPEND ${OUTPUT_FILE} "#define ${DEFINE_MACRO_HEADER}\n\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION_MAJOR ${MAJOR_PROG_VERSION}\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION_MINOR ${MINOR_PROG_VERSION}\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION_PATCH ${PATCH_PROG_VERSION}\n\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_MAKE_VERSION(major, minor, patch) ((major) *10000 + (minor) *100 + (patch))\n\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION ${PROGRAM_UPPER_NAME}_MAKE_VERSION (${PROGRAM_UPPER_NAME}_VERSION_MAJOR, ${PROGRAM_UPPER_NAME}_VERSION_MINOR, ${PROGRAM_UPPER_NAME}_VERSION_PATCH)\n\n")
file(APPEND ${OUTPUT_FILE} "#endif\n\n")
install(FILES ${OUTPUT_FILE} DESTINATION include/${projectName})
endfunction(create_version)
# Setting the default phoenix install prefix
set(PHOENIX_INSTALL_PREFIX "$ENV{HOME}/usr" CACHE STRING "Phoenix Install prefix" FORCE)
if(DEFINED ENV{CONDA_PREFIX})
message(STATUS "Find conda variable CONDA_PREFIX = '$ENV{CONDA_PREFIX}' used as new install prefix")
set(PHOENIX_INSTALL_PREFIX "$ENV{CONDA_PREFIX}" CACHE STRING "Phoenix Install prefix" FORCE)
endif()
if(DEFINED ENV{CONDA_ENV_PATH})
message(STATUS "Find conda variable CONDA_ENV_PATH = '$ENV{CONDA_ENV_PATH}' used as new install prefix")
set(PHOENIX_INSTALL_PREFIX "$ENV{CONDA_ENV_PATH}" CACHE STRING "Phoenix Install prefix" FORCE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PHOENIX_INSTALL_PREFIX}" CACHE PATH "cmake install prefix" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake CACHE STRING "cmake module path" FORCE)
This diff is collapsed.
include(create_version.cmake)
# Define the base of a Phoenix project
# programName : name of the program/library
# programVersion : version of the program/library
# programDescritpion : description of the program/library
# programHomePage : home page of the program/library
function(phoenix_base_project programName programVersion programDescritpion programHomePage)
create_version("${programName}" "${programVersion}")
if(NOT MODULE_MODE)
set(PROGRAM_NAME "${programName}" CACHE STRING "name of the current project" FORCE)
set(PROGRAM_VERSION "${programVersion}" CACHE STRING "version of the current project" FORCE)
set(PROGRAM_DESCRIPTION_NO_QUOTE "${programDescritpion}" CACHE STRING "description of the current project" FORCE)
set(PROGRAM_DESCRIPTION "\"${PROGRAM_DESCRIPTION_NO_QUOTE}\"" CACHE STRING "description with double quotes of the current project" FORCE)
set(PROGRAM_HOMEPAGE "${programHomePage}" CACHE STRING "home page of the current project" FORCE)
set(LIBRARY_DIRECTORY "lib" CACHE STRING "define the library directory (especially for Fedora with the wtf lib64)" FORCE)
set(DOC_MODE no CACHE BOOL "Doc mode")
message(STATUS "DOC_MODE = ${DOC_MODE}")
set(SELF_TESTS_MODE yes CACHE BOOL "Self test mode")
message(STATUS "SELF_TESTS_MODE = ${SELF_TESTS_MODE}")
set(VALGRIND_TEST yes CACHE BOOL "enable test with valgrind")
message(STATUS "VALGRIND_TEST = ${VALGRIND_TEST}")
set(PHOENIX_FORCE_PULL_MODULE no CACHE BOOL "Say if the submodule have to be pulled every time or not")
add_definitions(--std=c++11 -Wall -Werror -g -O2 -D__PROGRAM_VERSION__="${PROGRAM_VERSION}")
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
message(STATUS "Build for tests COVERAGE")
set(CTEST_COVERAGE_COMMAND "gcov")
set(SELF_TESTS_MODE yes)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -Werror -g -O0 -fprofile-arcs -ftest-coverage" PARENT_SCOPE)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -Werror -g -O2" PARENT_SCOPE)
endif()
add_definitions(-D__PROGRAM_VERSION__="${PROGRAM_VERSION}")
createLinuxPackages()
endif()
endfunction(phoenix_base_project)
set(SCRIPT_CLONE_MODULE "${CMAKE_CURRENT_SOURCE_DIR}/scriptCloneModule.sh" CACHE STRING "Script to be used to clone project used as module")
set(SCRIPT_PULL_MODULE "${CMAKE_CURRENT_SOURCE_DIR}/scriptPull.sh" CACHE STRING "Script to be used to clone project used as module")
set(SCRIPT_CLONE_PACKAGE "${CMAKE_CURRENT_SOURCE_DIR}/scriptClonePackage.sh" CACHE STRING "Script to be used to clone package used as module")
# Check if a project (used as module) is found, if it's not, it will be fetch with its url
# When the project is found, this function does a classic add_subdirectory
# Parameter :
# packageName : name of the package to be found (classic parameter of find_package)
# urlGitToPackage : url of the git repository to be used to fetch it if it is not found
function(get_extra_module packageName urlGitToPackage)
set(PHOENIX_TARGET_NAME "phoenix_${packageName}_found")
if(TARGET ${PHOENIX_TARGET_NAME})
message(STATUS "Project ${packageName} already found, target ${PHOENIX_TARGET_NAME} exits")
else()
add_custom_target(${PHOENIX_TARGET_NAME})
set(SUB_MODULE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tmp_project)
file(MAKE_DIRECTORY ${SUB_MODULE_DIRECTORY})
set(MODULE_MODE yes)
set(MODULE_PROJECT_DIR ${SUB_MODULE_DIRECTORY}/${packageName})
if(EXISTS ${MODULE_PROJECT_DIR})
message(STATUS "Find project ${packageName} in ${MODULE_PROJECT_DIR}")
execute_process(COMMAND ${SCRIPT_PULL_MODULE} ${MODULE_PROJECT_DIR}
WORKING_DIRECTORY ${SUB_MODULE_DIRECTORY}/
ERROR_QUIET
OUTPUT_QUIET
)
add_subdirectory(${MODULE_PROJECT_DIR})
include_directories(${MODULE_PROJECT_DIR}/src)
include_directories(${PHOENIX_INCLUDE_DIRS})
else()
message(STATUS "Project ${packageName} not found")
if(urlGitToPackage)
get_filename_component(basePackageDirName ${urlGitToPackage} NAME_WE)
message(STATUS "Get project ${packageName} with url '${urlGitToPackage}'")
execute_process(COMMAND ${SCRIPT_CLONE_MODULE} ${urlGitToPackage}
WORKING_DIRECTORY ${SUB_MODULE_DIRECTORY}/)
if(EXISTS ${MODULE_PROJECT_DIR})
message(STATUS "Find project ${packageName} in ${MODULE_PROJECT_DIR}")
add_subdirectory(${MODULE_PROJECT_DIR})
include_directories(${MODULE_PROJECT_DIR}/src)
include_directories(${PHOENIX_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Project ${packageName} not found even after cloning repository ${urlGitToPackage}")
endif()
else(urlGitToPackage)
message(FATAL_ERROR "Package ${packageName} not found and no url to fetch it")
endif(urlGitToPackage)
endif()
endif()
endfunction(get_extra_module)
# Check if a project (used as module) is found, if it's not, it will be fetch with its url
# When the project is found, this function does a classic add_subdirectory
# Parameter :
# packageName : name of the package to be found (classic parameter of find_package)
# urlGitToPackage : url of the git repository to be used to fetch it if it is not found
function(pull_extra_module packageName urlGitToPackage)
# There is one global varialbe PHOENIX_FORCE_PULL_MODULE
# - if the PHOENIX_FORCE_PULL_MODULE == no
# - we look for the FindXXX.cmake and we use the classic find_package
# - if the package has been found nothing to do
# - but if the corresponding module is found, we remove it (to avoid extra clone and conflict)
# - if the package is not found, we get the existing module (by clone or pull)
# - if the module does not exsit, it is cloned (and then potentially installed)
# - if the module does exsit, it is pulled (and also potentially installed after)
# - if the PHOENIX_FORCE_PULL_MODULE == yes
# - if the module is not found, we clone it even if the package does exist (we recompile it and reinstall it)
# - if the module is found, we pull it even if the package does exist (we recompile it and reinstall it)
if(PHOENIX_FORCE_PULL_MODULE)
# We always pull the module
get_extra_module(${packageName} ${urlGitToPackage})
else()
# Try to find the package
find_package(${packageName} QUIET)
string(TOUPPER ${packageName} UPPER_PACKAGE_NAME)
if(${${UPPER_PACKAGE_NAME}_FOUND})
# The package is found, we check if the module exist
set(MODULE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tmp_project/${packageName})
if(EXISTS ${MODULE_PROJECT_DIR})
message(STATUS "Remove module ${packageName} in ${MODULE_PROJECT_DIR}")
file(REMOVE_RECURSE ${MODULE_PROJECT_DIR})
endif()
else()
# The module is not found, so we get it
message(STATUS "${packageName} not found")
get_extra_module(${packageName} ${urlGitToPackage})
endif()
endif()
endfunction(pull_extra_module)
# Do a classic find_package but if the package is not found, it will be fetch with its url
# Parameter :
# packageName : name of the package to be found (classic parameter of find_package)
# urlGitToPackage : url of the git repository to be used to fetch it if it is not found
function(phoenix_find_package packageName urlGitToPackage)
find_package(${packageName} QUIET)
string(TOUPPER ${packageName} UPPER_PACKAGE_NAME)
message(STATUS "FIND variable ${packageName}_FOUND = ${${UPPER_PACKAGE_NAME}_FOUND}")
if(NOT ${${UPPER_PACKAGE_NAME}_FOUND})
message(STATUS "${packageName} not found")
if(urlGitToPackage)
get_filename_component(basePackageDirName ${urlGitToPackage} NAME_WE)
message(STATUS "The url '${urlGitToPackage}' gives basePackageDirName = ${basePackageDirName}")
execute_process(COMMAND ${SCRIPT_CLONE_PACKAGE} ${basePackageDirName} ${urlGitToPackage} ${CMAKE_INSTALL_PREFIX}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
message(STATUS "End of ${basePackageDirName} installation")
find_package(${packageName} QUIET)
else(urlGitToPackage)
message(FATAL_ERROR "Package ${packageName} not found and no url to fetch it")
endif(urlGitToPackage)
endif()
endfunction(phoenix_find_package)
if(APPLE)
set(CMAKE_MACOSX_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)