Commit d3aa29b0 authored by Valerio Bertone's avatar Valerio Bertone
Browse files

Setting environment variables using cmake

parent 2962742d
......@@ -24,11 +24,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# FIND LIBRARIES ===========================================================================
# find libraries: gsl
find_package(GSL)
# find libraries: Qt
find_package(Qt5 COMPONENTS Core Sql REQUIRED)
find_package(Qt5 COMPONENTS Core Sql XmlPatterns REQUIRED)
# add some useful macros and variables
add_definitions(${QT_DEFINITIONS})
......@@ -36,20 +33,49 @@ add_definitions(${QT_DEFINITIONS})
# find libraries: additional modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# find libraries: SFML
find_package(SFML COMPONENTS system REQUIRED)
# find libraries: ElementaryUtils
find_package(ElementaryUtils REQUIRED)
# find libraries: NumA++
find_package(NumA++ REQUIRED)
# find libraries: PARTONS
find_package(PARTONS REQUIRED)
# find libraries: SFML
find_package(SFML COMPONENTS system REQUIRED)
# find libraries: CLN
find_package(CLN REQUIRED)
# find libraries: GSL
find_package(GSL REQUIRED)
# find libraries: Apfel++
find_package(Apfel++ REQUIRED)
# find libraries: LHAPDF
find_package(LHAPDF REQUIRED)
# directories containing headers
include_directories($(GSL_INCLUDE_DIRS) ${QT_INCLUDE_DIRS} ${SFML_INCLUDE_DIR} ${ElementaryUtils_INCLUDE_DIR} ${NumA++_INCLUDE_DIR} ${PARTONS_INCLUDE_DIR})
include_directories(${QT_INCLUDE_DIRS} ${SFML_INCLUDE_DIR} ${CLN_INCLUDE_DIR} ${ElementaryUtils_INCLUDE_DIR} ${NumA++_INCLUDE_DIR} ${Apfel++_INCLUDE_DIR} ${LHAPDF_INCLUDE_DIR})
include_directories(include)
# ENVIRONMENT VARIABLES ========================================================================
execute_process(COMMAND bash -c "cd ../elementary-utils/; git branch --show-current" OUTPUT_VARIABLE ELEMUTILS_BRANCH)
execute_process(COMMAND bash -c "cd ../elementary-utils/; git rev-parse HEAD;" OUTPUT_VARIABLE ELEMUTILS_REVISION)
string(REGEX REPLACE "\n$" "" ELEMUTILS_BRANCH "${ELEMUTILS_BRANCH}")
string(REGEX REPLACE "\n$" "" ELEMUTILS_REVISION "${ELEMUTILS_REVISION}")
execute_process(COMMAND bash -c "cd ../numa/; git branch --show-current" OUTPUT_VARIABLE NUMA_BRANCH)
execute_process(COMMAND bash -c "cd ../numa/; git rev-parse HEAD;" OUTPUT_VARIABLE NUMA_REVISION)
string(REGEX REPLACE "\n$" "" NUMA_BRANCH "${NUMA_BRANCH}")
string(REGEX REPLACE "\n$" "" NUMA_REVISION "${NUMA_REVISION}")
execute_process(COMMAND bash -c "cd ../partons/; git branch --show-current" OUTPUT_VARIABLE PARTONS_BRANCH)
execute_process(COMMAND bash -c "git rev-parse HEAD" OUTPUT_VARIABLE PARTONS_REVISION)
string(REGEX REPLACE "\n$" "" PARTONS_BRANCH "${PARTONS_BRANCH}")
string(REGEX REPLACE "\n$" "" PARTONS_REVISION "${PARTONS_REVISION}")
configure_file("${CMAKE_SOURCE_DIR}/bin/environment_configuration.dat.in" "${CMAKE_SOURCE_DIR}/bin/environment_configuration.dat")
# FINALIZE ==================================================================================
......@@ -77,20 +103,28 @@ add_executable(
target_link_libraries(
PARTONS_example
${GSL_LIBRARIES}
${QT_LIBRARIES}
${PARTONS_LIBRARIES}
${QT_LIBRARIES}
${SFML_LIBRARIES}
${ElementaryUtils_LIBRARIES}
${NumA++_LIBRARIES}
${PARTONS_LIBRARIES}
${CLN_LIBRARIES}
${ElementaryUtils_LIBRARIES}
${NumA++_LIBRARIES}
${GSL_LIBRARIES}
${Apfel++_LIBRARIES}
${LHAPDF_LIBRARIES}
Qt5::Core
Qt5::Sql
Qt5::XmlPatterns
)
# environment_configuration.dat
# The content of this file is stored in the database during the insertion of data,
# so latter one can easily reproduce the used computational environment.
system: @CMAKE_SYSTEM_NAME@ @CMAKE_SYSTEM_VERSION@
g++: @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@
qt: @Qt5Core_VERSION@
smfl: @SFML_VERSION@
cln: @CLN_VERSION@
gsl: @GSL_VERSION@
apfel++: @Apfel++_VERSION@
lhapdf: @LHAPDF_VERSION@
elementary-utils: @ELEMUTILS_BRANCH@/@ELEMUTILS_REVISION@
numa: @NUMA_BRANCH@/@NUMA_REVISION@
partons: @PARTONS_BRANCH@/@PARTONS_REVISION@
# APFEL++
find_program(Apfel++_CONFIG apfelxx-config REQUIRED)
if (Apfel++_CONFIG)
exec_program(${Apfel++_CONFIG}
ARGS --cppflags
OUTPUT_VARIABLE Apfel++_CXX_FLAGS
)
set(Apfel++_CXX_FLAGS ${Apfel++_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${Apfel++_CONFIG}
ARGS --ldflags
OUTPUT_VARIABLE Apfel++_LIBRARIES
)
set(Apfel++_LIBRARIES ${Apfel++_LIBRARIES} CACHE STRING INTERNAL)
exec_program(${Apfel++_CONFIG}
ARGS --version
OUTPUT_VARIABLE Apfel++_VERSION
)
set(Apfel++_VERSION ${Apfel++_VERSION} CACHE STRING INTERNAL)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Apfel++ REQUIRED_VARS Apfel++_LIBRARIES VERSION_VAR Apfel++_VERSION)
endif(Apfel++_CONFIG)
# CLN_FOUND CLN has been successfully found
# CLN_INCLUDE_DIR the include directories
# CLN_LIBRARIES CLN library and its dependencies (if any)
if (CLN_INCLUDE_DIR AND CLN_LIBRARIES)
set(CLN_FIND_QUIETLY TRUE)
endif()
function(_cl_get_version _out_major _out_minor _out_patch _cl_version_h)
file(STRINGS ${_cl_version_h} _cl_vinfo REGEX "^#define[\t ]+CL_VERSION_.*")
if (NOT _cl_vinfo)
message(FATAL_ERROR "include file ${_cl_version_h} does not exist")
endif()
string(REGEX REPLACE "^.*CL_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" ${_out_major} "${_cl_vinfo}")
string(REGEX REPLACE "^.*CL_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" ${_out_minor} "${_cl_vinfo}")
string(REGEX REPLACE "^.*CL_VERSION_PATCHLEVEL[ \t]+([0-9]+).*" "\\1" ${_out_patch} "${_cl_vinfo}")
if (NOT ${_out_major} MATCHES "[0-9]+")
message(FATAL_ERROR "failed to determine CL_VERSION_MAJOR, "
"expected a number, got ${${_out_major}}")
endif()
if (NOT ${_out_minor} MATCHES "[0-9]+")
message(FATAL_ERROR "failed to determine CL_VERSION_MINOR, "
"expected a number, got ${${_out_minor}}")
endif()
if (NOT ${_out_patch} MATCHES "[0-9]+")
message(FATAL_ERROR "failed to determine CL_VERSION_PATCHLEVEL, "
"expected a number, got ${${_out_patch}}")
endif()
#message(STATUS "found CLN [${_cl_version_h}], version ${${_out_major}}.${${_out_minor}}.${${_out_patch}}")
set(${_out_major} ${${_out_major}} PARENT_SCOPE)
set(${_out_minor} ${${_out_minor}} PARENT_SCOPE)
set(${_out_patch} ${${_out_patch}} PARENT_SCOPE)
endfunction()
set(CLN_FOUND)
set(CLN_INCLUDE_DIR)
set(CLN_LIBRARIES)
#include(FindPkgConfig)
#if (PKG_CONFIG_FOUND)
# pkg_check_modules(_cln cln)
#endif()
find_path(CLN_INCLUDE_DIR NAMES cln/cln.h
HINTS ${_cln_INCLUDE_DIRS}
/usr/local/cln/v1.3.4/include
$ENV{CLN_DIR}/include)
find_library(CLN_LIBRARIES NAMES libcln cln
HINTS ${_cln_LIBRARY_DIR}
${_cln_LIBRARY_DIRS}
/usr/local/cln/v1.3.4/lib
$ENV{CLN_DIR}/lib)
if (CLN_INCLUDE_DIR)
_cl_get_version(CLN_VERSION_MAJOR
CLN_VERSION_MINOR
CLN_VERSION_PATCHLEVEL
${CLN_INCLUDE_DIR}/cln/version.h)
set(CLN_VERSION ${CLN_VERSION_MAJOR}.${CLN_VERSION_MINOR}.${CLN_VERSION_PATCHLEVEL})
# Check if the version reported by pkg-config is the same
# as the one read from the header. This prevents us from
# picking the wrong version of CLN (say, if several versions
# are installed)
if (_cln_FOUND AND NOT CLN_VERSION VERSION_EQUAL _cln_VERSION)
if (NOT CLN_FIND_QUIETLY)
message(ERROR "pkg-config and version.h disagree, "
"${_cln_VERSION} vs ${CLN_VERSION}, "
"please check your installation")
endif()
set(CLN_LIBRARIES CLN-NOTFOUND)
set(CLN_INCLUDE_DIR CLN-NOTFOUND)
set(CLN_LIBRARY_DIRS)
set(CLN_VERSION)
endif()
endif()
set(CMAKE_REQUIRED_QUIET TRUE)
# Check if the version embedded into the library is the same as the one in the headers.
if (CLN_INCLUDE_DIR AND CLN_LIBRARIES AND NOT CMAKE_CROSSCOMPILING)
include(CheckCXXSourceRuns)
set(_save_required_includes ${CMAKE_REQUIRED_INCLUDES})
set(_save_required_libraries ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CLN_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CLN_LIBRARIES})
check_cxx_source_runs("
#include <cln/version.h>
int main() {
return (CL_VERSION_MAJOR == cln::version_major) &&
(CL_VERSION_MINOR == cln::version_minor) &&
(CL_VERSION_PATCHLEVEL == cln::version_patchlevel) ? 0 : 1;
}
"
_cl_version_matches)
set(CMAKE_REQUIRED_LIBRARIES ${_save_required_libraries})
set(CMAKE_REQUIRED_INCLUDES ${_save_required_includes})
if (NOT _cl_version_matches)
if (NOT CLN_FIND_QUIETLY)
message(ERROR "header (version differs from the library one, "
"please check your installation.")
endif()
set(CLN_INCLUDE_DIR CLN-NOTFOUND)
set(CLN_LIBRARIES CLN-NOTFOUND)
set(CLN_LIBRARY_DIRS)
set(CLN_VERSION)
endif()
endif()
if (CLN_LIBRARIES AND CLN_INCLUDE_DIR)
set(_cln_library_dirs)
foreach(_l ${CLN_LIBRARIES})
get_filename_component(_d "${_l}" PATH)
list(APPEND _cln_library_dirs "${_d}")
endforeach()
list(REMOVE_DUPLICATES _cln_library_dirs)
set(CLN_LIBRARY_DIRS ${_cln_library_dirs})
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CLN REQUIRED_VARS CLN_LIBRARIES CLN_INCLUDE_DIR
VERSION_VAR CLN_VERSION)
# LHAPDF
find_program(LHAPDF_CONFIG lhapdf-config REQUIRED)
if (LHAPDF_CONFIG)
exec_program(${LHAPDF_CONFIG}
ARGS --cppflags
OUTPUT_VARIABLE LHAPDF_CXX_FLAGS
)
set(LHAPDF_CXX_FLAGS ${LHAPDF_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${LHAPDF_CONFIG}
ARGS --ldflags
OUTPUT_VARIABLE LHAPDF_LIBRARIES
)
set(LHAPDF_LIBRARIES ${LHAPDF_LIBRARIES} CACHE STRING INTERNAL)
exec_program(${LHAPDF_CONFIG}
ARGS --version
OUTPUT_VARIABLE LHAPDF_VERSION
)
set(LHAPDF_VERSION ${LHAPDF_VERSION} CACHE STRING INTERNAL)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LHAPDF REQUIRED_VARS LHAPDF_LIBRARIES VERSION_VAR LHAPDF_VERSION)
endif(LHAPDF_CONFIG)
......@@ -52,7 +52,7 @@ calculation of CFFs or observables.
<!-- Select alpha_s model -->
<module type="RunningAlphaStrongModule" name="RunningAlphaStrongApfel">
<param name="qcd_order_type" value="NNLO" />
<param name="qcd_order_type" value="LO" />
<param name="alphasRef" value="0.118" />
<param name="muRef" value="91.1876" />
<param name="thresholds" value="0 0 0 1.3 4.75 172" />
......
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