forked from GrammaTech/gtirb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacros.cmake
91 lines (77 loc) · 2.33 KB
/
Macros.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
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
macro(IMPL_GTIRB_ADD_LINKER_FLAG flag)
if(NOT ${CMAKE_EXE_LINKER_FLAGS} MATCHES "(${flag}.*)")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${flag}"
CACHE STRING "Linker Flags" FORCE
)
endif()
if(NOT ${CMAKE_SHARED_LINKER_FLAGS} MATCHES "(${flag}.*)")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} ${flag}"
CACHE STRING "Linker Flags" FORCE
)
endif()
endmacro()
macro(GTIRB_ADD_MSVC_LINKER_FLAG flag)
if(MSVC)
impl_gtirb_add_linker_flag(${flag})
endif()
endmacro()
macro(GTIRB_ADD_GCC_LINKER_FLAG flag)
if(CMAKE_COMPILER_IS_GNUCXX)
impl_gtirb_add_linker_flag(${flag})
endif()
endmacro()
macro(GTIRB_ADD_CLANG_LINKER_FLAG flag)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
impl_gtirb_add_linker_flag(${flag})
endif()
endmacro()
macro(GTIRB_ADD_LIBRARY)
add_library(
${PROJECT_NAME} ${${PROJECT_NAME}_H} ${${PROJECT_NAME}_SRC}
${${PROJECT_NAME}_PROTO}
)
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "gtirb")
endmacro()
macro(GTIRB_ADD_LIBRARY_STATIC)
add_library(
${PROJECT_NAME} STATIC ${${PROJECT_NAME}_H} ${${PROJECT_NAME}_SRC}
)
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "gtirb")
endmacro()
macro(GTIRB_ADD_LIBRARY_HEADERONLY)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)
endmacro()
macro(GTIRB_ADD_EXECUTABLE)
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_H} ${${PROJECT_NAME}_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "gtirb/applications")
endmacro()
macro(GTIRB_ADD_EXECUTABLE_GTEST)
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_H} ${${PROJECT_NAME}_SRC})
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "gtirb/test")
endmacro()
macro(GTIRB_GET_ALL_SUBDIRS result curdir)
file(
GLOB children
RELATIVE ${curdir}
${curdir}/*
)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
macro(GTIRB_ADD_ALL_SUBDIRS)
gtirb_get_all_subdirs(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
foreach(subdir ${SUBDIRS})
add_subdirectory(${subdir})
endforeach()
endmacro()