forked from objectcomputing/mFAST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mFASTConfig.cmake.in
112 lines (89 loc) · 4.02 KB
/
mFASTConfig.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Config file for the mFAST package
# It defines the following variables
# MFAST_INCLUDE_DIR - include directories for mFAST
# MFAST_LIBRARY_DIRS - library directories for mFAST
# MFAST_LIBRARIES - libraries to link against
# MFAST_COMPONENTS - installed components
# MFAST_<component>_LIBRARY - particular component library
# MFAST_EXECUTABLE - the fast_type_gen executable
# Compute paths
get_filename_component(MFAST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${MFAST_CMAKE_DIR}/mFASTTargets.cmake")
find_package( Boost 1.55.0 )
set(MFAST_INCLUDE_DIR "${Boost_INCLUDE_DIR}")
foreach (directory @CONF_INCLUDE_DIRS@)
get_filename_component(directory "${directory}" ABSOLUTE)
list(APPEND MFAST_INCLUDE_DIR "${directory}")
endforeach (directory)
set(MFAST_LIBRARY_DIRS "@CONF_LIBRARY_DIRS@")
list(REMOVE_DUPLICATES MFAST_INCLUDE_DIR)
set(MFAST_EXECUTABLE @FAST_TYPE_GEN_INSTALL_LOCATION@)
# These are IMPORTED targets created by mFASTTargets.cmake
set(MFAST_FOUND "TRUE")
# Make dependent targets automatically pick up include directory and definitions for CMake 2.8.12 and later
set_property(TARGET @MFAST_SHARED_LIBRARIES@ @MFAST_STATIC_LIBRARIES@
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MFAST_INCLUDE_DIR})
if (NOT DEFINED MFAST_USE_STATIC_LIBS OR MFAST_USE_STATIC_LIBS)
set(STATIC_SUFFIX "_static")
set(components @MFAST_STATIC_COMPONENTS@)
else ()
if ("${CMAKE_VERSION}" VERSION_LESS "2.8.12")
add_definitions(-DMFAST_DYN_LINK)
endif ("${CMAKE_VERSION}" VERSION_LESS "2.8.12")
set(components @MFAST_DYNAMIC_COMPONENTS@)
endif ()
foreach (entry IN LISTS mFAST_FIND_COMPONENTS)
foreach (component IN LISTS components)
if ("${entry}${STATIC_SUFFIX}" STREQUAL "${component}")
set("MFAST_${entry}_FOUND" Yes)
endif ()
endforeach (component)
if (MFAST_${entry}_FOUND)
list(REMOVE_ITEM mFAST_FIND_COMPONENTS "${entry}")
list(APPEND MFAST_LIBRARIES "mfast_${entry}${STATIC_SUFFIX}")
set(MFAST_USED_COMPONENTS "${MFAST_USED_COMPONENTS} ${entry}")
set("MFAST_${entry}_LIBRARY" "mfast_${entry}${STATIC_SUFFIX}")
else ()
message(SEND_ERROR "mFAST component ${entry} NOT FOUND! Available components: ${components}")
endif ()
endforeach (entry)
list(APPEND MFAST_LIBRARIES "mfast${STATIC_SUFFIX}")
#============================================================
# FASTTYPEGEN_TARGET (public function)
#============================================================
#
function (FASTTYPEGEN_TARGET Name)
set(FASTTYPEGEN_TARGET_usage "FASTTYPEGEN_TARGET(<Name> Input1 Input2 ...]" PARENT_SCOPE)
set("FASTTYPEGEN_${Name}_OUTPUTS")
set(INPUTS)
foreach (input IN LISTS ARGN)
get_filename_component(noext_name "${input}" NAME_WE)
list(APPEND "FASTTYPEGEN_${Name}_OUTPUTS"
"${CMAKE_CURRENT_BINARY_DIR}/${noext_name}.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${noext_name}.h"
"${CMAKE_CURRENT_BINARY_DIR}/${noext_name}.inl")
list(APPEND INPUTS "${CMAKE_CURRENT_SOURCE_DIR}/${input}")
endforeach (input)
if (TARGET fast_type_gen)
set(FAST_TYPE_GEN fast_type_gen)
else (TARGET fast_type_gen)
set(FAST_TYPE_GEN "${MFAST_EXECUTABLE}")
endif (TARGET fast_type_gen)
add_custom_command(
OUTPUT ${FASTTYPEGEN_${Name}_OUTPUTS}
COMMAND "${FAST_TYPE_GEN}" -- ${INPUTS}
DEPENDS ${ARGN}
COMMENT "[FASTTYPEGEN][${Name}] Building Fast Application Types"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM)
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}")
set("FASTTYPEGEN_${Name}_OUTPUTS" "${FASTTYPEGEN_${Name}_OUTPUTS}" PARENT_SCOPE)
set("FASTTYPEGEN_${Name}_DEFINED" TRUE PARENT_SCOPE)
set("FASTTYPEGEN_${Name}_INPUTS" "${ARGN}" PARENT_SCOPE)
endfunction (FASTTYPEGEN_TARGET)
#============================================================
message(STATUS "mFAST Found! Used components:${MFAST_USED_COMPONENTS}")
message(STATUS "Used libraries: ${MFAST_LIBRARIES}")
if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
add_definitions(-std=c++11)
endif()