-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathFindQDPXX.cmake.in
84 lines (68 loc) · 2.6 KB
/
FindQDPXX.cmake.in
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
set( QDPXX_INSTALL_DIR "@prefix@" )
set( QDPXX_PARALLEL_ARCH "@CONFIG_PARALLEL_ARCH@" )
set( QDPXX_INCLUDE_DIR "@prefix@/include" )
set( QDPXX_LIBDIR "@prefix@/lib")
# Get the Include directories out of the CFLAGS Line if they start with -I
string(STRIP "@HDF5_CXXFLAGS@ @LIBXML2_CXXFLAGS@ @QMP_CFLAGS@ @QMT_CXXFLAGS@" BASE_EXTRA_CXXFLAGS)
string(REPLACE " " ";" BASE_EXTRA_LIST ${BASE_EXTRA_CXXFLAGS})
foreach( ARG ${BASE_EXTRA_LIST})
if( ${ARG} MATCHES "^-I")
string(REPLACE "-I" "" STRIPPED_ARG ${ARG})
list(APPEND EXTRA_INCLUDE_DIRS ${STRIPPED_ARG})
endif()
endforeach()
# Find the library we built and add it as an imported target
# with appropriate include dir and location
function(add_qdpxx_lib LIBNAME)
message(STATUS "Libname: ${LIBNAME}")
# This will find the file, whether a .so or a .a appropriately
find_library(LIB_${LIBNAME} NAMES ${LIBNAME} PATHS "${QDPXX_LIBDIR}")
# Set up the library as an imported target
add_library(${LIBNAME} UNKNOWN IMPORTED )
# Explain where it is
set_target_properties(${LIBNAME} PROPERTIES IMPORTED_LOCATION ${LIB_${LIBNAME}})
# Set the include dir
set_target_properties(${LIBNAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${QDPXX_INCLUDE_DIR}")
endfunction()
# Toplevel QDP++ library
add_qdpxx_lib(qdp)
# Add on Extra includes
foreach( INCDIR ${EXTRA_INCLUDE_DIRS})
message(STATUS "Adding ${INCDIR}")
set_target_properties(qdp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCDIR})
endforeach()
# XML Reader and writer
add_qdpxx_lib(XPathReader)
add_qdpxx_lib(xmlWriter)
target_link_libraries(qdp INTERFACE XPathReader xmlWriter)
# QIO and LIME
add_qdpxx_lib(lime)
add_qdpxx_lib(qio)
target_link_libraries(qio INTERFACE lime)
target_link_libraries(qdp INTERFACE qio)
# Check if using LibIntrin
string(STRIP "@LIBINTRIN_DIR@" QDPXX_LIBINTRIN)
if( QDPXX_LIBINTRIN )
add_qdpxx_lib(intrin)
target_link_libraries(qdp INTERFACE intrin)
endif()
# Check if using FILEDB
string(STRIP "@FILEDB_DIR" QDPXX_FILEDB)
if( QDPXX_FILEDB )
add_qdpxx_lib(filehash)
add_qdpxx_lib(filedb)
target_link_libraries(filedb INTERFACE filehash)
target_link_libraries(qdp INTERFACE filedb)
endif()
# Add other LFlags and libs which we didn't build
string(STRIP "@LDFLAGS@ @HDF5_LDFLAGS@ @QMP_LDFLAGS@ @QMT_LDFLAGS@" QDPXX_LDFLAGS)
string(STRIP "@HDF5_LIBS@ @LIBXML2_LIBS@ @QMP_LIBS@ @LIBS@ @QMT_LIBS@" QDPXX_LIBS)
if( QDPXX_LDFLAGS )
separate_argumnets(${QDPXX_LDFLAGS})
target_link_options(qdp INTERFACE ${QDPXX_LDFLAGS})
endif()
if( QDPXX_LIBS )
separate_arguments(${QDPXX_LIBS})
target_link_libraries(qdp INTERFACE ${QDPXX_LIBS})
endif()
set( QDPXX_FOUND TRUE)