forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindpythia.cmake
54 lines (46 loc) · 2.23 KB
/
Findpythia.cmake
1
2
3
4
5
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.
set(PKGNAME ${CMAKE_FIND_PACKAGE_NAME})
string(TOUPPER ${PKGNAME} PKGENVNAME)
find_path(${PKGNAME}_INCLUDE_DIR
NAMES Pythia.h
PATH_SUFFIXES Pythia8
PATHS $ENV{${PKGENVNAME}_ROOT}/include)
find_library(${PKGNAME}_LIBRARY_SHARED
NAMES libpythia8.so libpythia8.dylib
PATHS $ENV{${PKGENVNAME}_ROOT}/lib)
find_path(${PKGNAME}_DATA
NAMES MainProgramSettings.xml
PATHS ${${PKGNAME}_ROOT}/share/Pythia8/xmldoc
$ENV{${PKGENVNAME}_ROOT}/share/Pythia8/xmldoc
$ENV{PYTHIA8DATA})
if(${PKGNAME}_INCLUDE_DIR AND ${PKGNAME}_LIBRARY_SHARED AND ${PKGNAME}_DATA)
add_library(pythia SHARED IMPORTED)
get_filename_component(incdir ${${PKGNAME}_INCLUDE_DIR}/.. ABSOLUTE)
get_filename_component(libdir ${${PKGNAME}_LIBRARY_SHARED} DIRECTORY)
set_target_properties(pythia
PROPERTIES IMPORTED_LOCATION
${${PKGNAME}_LIBRARY_SHARED}
INTERFACE_INCLUDE_DIRECTORIES ${incdir}
INTERFACE_LINK_DIRECTORIES ${libdir})
# Promote the imported target to global visibility (so we can alias it)
set_target_properties(pythia PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(MC::Pythia ALIAS pythia)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(${PKGNAME}
REQUIRED_VARS ${PKGNAME}_INCLUDE_DIR
${PKGNAME}_LIBRARY_SHARED
${PKGNAME}_DATA)
mark_as_advanced(${PKGNAME}_INCLUDE_DIR ${PKGNAME}_LIBRARY_SHARED
${PKGNAME}_DATA)
unset(PKGNAME)
unset(PKGENVNAME)