forked from mageec/mageec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
137 lines (108 loc) · 3.74 KB
/
CMakeLists.txt
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
cmake_minimum_required(VERSION 3.0.2)
project(MAGEEC)
# MAGEEC options
# Flags are all enabled by default. The user is expected to selectively
# disable them as required.
option (MAGEEC_DEBUG
"Enable debug for MAGEEC" True)
option (MAGEEC_WITH_USER_DOCS
"Build MAGEEC user documentation" True)
option (MAGEEC_WITH_DESIGN_DOCS
"Build MAGEEC with design documentation" True)
option (MAGEEC_WITH_DOXYGEN
"Generate MAGEEC API documentation with Doxygen" True)
option (MAGEEC_WITH_GCC_PLUGIN
"Build the GCC plugin as well as MAGEEC" True)
option (MAGEEC_WITH_C5
"Built the C5 classifier as well as MAGEEC" True)
# Search path to find gcc plugin headers.
option (GCC_PLUGIN_INCLUDE_DIR
"Directory in which GCC plugin headers can be found")
# This should match the version number found in the mageec framework source
set (MAGEEC_VERSION_MAJOR 2)
set (MAGEEC_VERSION_MINOR 0)
set (MAGEEC_VERSION_PATCH 0)
if (NOT PACKAGE_VERSION)
set(PACKAGE_VERSION
"${MAGEEC_VERSION_MAJOR}.${MAGEEC_VERSION_MINOR}.${MAGEEC_VERSION_PATCH}")
endif()
set (PACKAGE_NAME MAGEEC)
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# Set compiler options depending on the compiler used
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Clang compiler options
set (CMAKE_CXX_FLAGS "\
-fPIC -std=c++11 -Werror -Weverything -Wno-c++98-compat \
-Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-padded \
-Wno-weak-vtables -Wno-switch-enum")
if (MAGEEC_DEBUG)
set (CMAKE_CXX_FLAGS "-g3 ${CMAKE_CXX_FLAGS}")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# GCC compiler options
set (CMAKE_CXX_FLAGS "-fPIC -std=c++11 -Werror -Wall -Wextra")
if (MAGEEC_DEBUG)
set (CMAKE_CXX_FLAGS "-g3 ${CMAKE_CXX_FLAGS}")
endif ()
else ()
# Unknown compiler
message (WARNING "Unrecognized compiler, CXXFLAGS unmodified")
endif ()
# Pass the mageec version number into the compile
add_definitions(
-DMAGEEC_VERSION_MAJOR=${MAGEEC_VERSION_MAJOR}
-DMAGEEC_VERSION_MINOR=${MAGEEC_VERSION_MINOR}
-DMAGEEC_VERSION_PATCH=${MAGEEC_VERSION_PATCH}
)
# Add debug flag
if (MAGEEC_DEBUG)
add_definitions (-DMAGEEC_WITH_DEBUG)
endif ()
# Install header files
install (DIRECTORY include/mageec DESTINATION include)
include_directories(include)
### Targets ###
# MAGEEC library
add_library (mageec_core
lib/DatabaseQuery.cpp
lib/Database.cpp
lib/Framework.cpp
lib/TrainedML.cpp
lib/Util.cpp
)
set_target_properties(mageec_core PROPERTIES OUTPUT_NAME mageec)
target_link_libraries(mageec_core sqlite3)
# Machine learners incorporated into MAGEEC
set (ML_SOURCES "lib/ML/C5.cpp" "lib/ML/FileML.cpp")
add_library (mageec_ml ${ML_SOURCES})
target_link_libraries(mageec_ml mageec_core)
# Standalone tool executable
add_executable (mageec_driver
lib/Driver.cpp
)
set_target_properties(mageec_driver PROPERTIES OUTPUT_NAME mageec)
target_link_libraries(mageec_driver mageec_core mageec_ml)
# Install libraries and executables
install(TARGETS mageec_driver mageec_ml mageec_core
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# Install scripts
install (DIRECTORY script/ DESTINATION bin PATTERN "*"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# Documentation
if (MAGEEC_WITH_USER_DOCS OR MAGEEC_WITH_DESIGN_DOCS OR MAGEEC_WITH_DOXYGEN)
add_subdirectory (doc)
endif ()
# GCC plugin
if (EXISTS ${PROJECT_SOURCE_DIR}/gcc_plugin AND MAGEEC_WITH_GCC_PLUGIN)
add_subdirectory(gcc_plugin)
endif()
# Standalone C5 classifier
if (MAGEEC_WITH_C5)
add_subdirectory (lib/ML/C5)
endif ()