-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
173 lines (140 loc) · 5.49 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
cmake_minimum_required(VERSION 2.8.10)
project (mgra)
set(PROJECT_NAME mgra)
set (MGRA_VERSION_MAJOR 2)
set (MGRA_VERSION_MINOR 2)
set (MGRA_VERSION_PATCH 1)
# So we can check build type throughout the script
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(TESTS_ON true)
endif()
# The 4 following lines are for CLion and do nothing (as far as I, nkartashov know) for compilation
FILE(GLOB_RECURSE ALL_HEADERS ${CMAKE_SOURCE_DIR}/*.h)
ADD_CUSTOM_TARGET(ADD_HEADERS SOURCES ${ALL_HEADERS})
FILE(GLOB_RECURSE ALL_NEW_HEADERS ${CMAKE_SOURCE_DIR}/*.hpp)
ADD_CUSTOM_TARGET(ADD_NEW_HEADERS SOURCES ${ALL_NEW_HEADERS})
set(MGRA_SOURCE src/mgra.cpp src/reader.cpp src/command_line_parsing.cpp)
# Wstats.cpp
configure_file (
src/include/defined.h.in
${PROJECT_BINARY_DIR}/defined.h
[@ONLY]
)
set(ROOT_DIR "${CMAKE_SOURCE_DIR}/..")
set(COMPILE_OPTION_FLAG "-std=c++11" )
set(DEBUG_FLAG "-g3")
set(OPTIMIZE_FLAG "-O2 -pipe -finline-functions -finline-limit=1000") # -DPSEUDO_EDGE
set(WARNS "-Wall -Wextra -pedantic-errors")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_OPTION_FLAG} ${OPTIMIZE_FLAG} ${WARNS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_OPTION_FLAG} ${DEBUG_FLAG} ${WARNS}")
endif()
include_directories(${CMAKE_BINARY_DIR}
src/include
src/utils
src/libs
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
message(SEND_ERROR "GCC version must be at least 4.7!")
return()
endif()
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.2")
# message(SEND_ERROR "Clang version must be at least 3.2!")
# return()
# endif()
else()
message(SEND_ERROR "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
return()
endif()
add_subdirectory(src/utils/io)
add_subdirectory(src/libs/blossom5)
set_property(TARGET BLOSSOM5 APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
add_executable(${PROJECT_NAME} ${MGRA_SOURCE})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
add_dependencies(${PROJECT_NAME} BLOSSOM5)
target_link_libraries(${PROJECT_NAME} BLOSSOM5)
add_dependencies(${PROJECT_NAME} input)
target_link_libraries(${PROJECT_NAME} input)
# Google Test & Mock
if (TESTS_ON)
enable_testing()
# We need thread support
find_package(Threads REQUIRED)
# Enable ExternalProject CMake module
include(ExternalProject)
# Download and install GoogleTest
ExternalProject_Add(
gtest
URL https://googletest.googlecode.com/files/gtest-1.7.0.zip
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
)
# Create a libgtest target to be used as a dependency by test programs
add_library(libgtest IMPORTED STATIC GLOBAL)
add_dependencies(libgtest gtest)
# Set gtest properties
ExternalProject_Get_Property(gtest source_dir binary_dir)
set_target_properties(libgtest PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
include_directories("${source_dir}/include")
# Download and install GoogleMock
ExternalProject_Add(
gmock
URL https://googlemock.googlecode.com/files/gmock-1.7.0.zip
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gmock
# Disable install step
INSTALL_COMMAND ""
)
# Create a libgmock target to be used as a dependency by test programs
add_library(libgmock IMPORTED STATIC GLOBAL)
add_dependencies(libgmock gmock)
# Set gmock properties
ExternalProject_Get_Property(gmock source_dir binary_dir)
set_target_properties(libgmock PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/libgmock.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
include_directories("${source_dir}/include")
set(TEST_PROJECT_NAME ${PROJECT_NAME}_test)
set(TESTS_DIRECTORY tests)
FILE(GLOB_RECURSE TEST_SOURCE ${TESTS_DIRECTORY}/*.cpp)
include_directories(${TESTS_DIRECTORY}/include
)
add_executable(${TEST_PROJECT_NAME} ${TEST_SOURCE})
target_link_libraries(${TEST_PROJECT_NAME}
libgtest
libgmock
)
add_test(lol ${TEST_PROJECT_NAME})
endif()
if(WIN32)
message(SEND_ERROR "Windows is unsupported system, please use UNIX or OS X systems")
else()
set(LIB_DIR "lib/MGRA")
set(SHARE_DIR "share/MGRA")
set(DOC_DIR "share/MGRA/doc")
install(TARGETS mgra RUNTIME DESTINATION bin)
install(FILES ${ROOT_DIR}/NEWS.md ${ROOT_DIR}/README.md ${ROOT_DIR}/USAGE.md ${ROOT_DIR}/INSTALL.md ${ROOT_DIR}/COPYING DESTINATION ${DOC_DIR})
endif()
set(CPACK_NSIS_MODIFY_PATH "ON")
set(CPACK_SOURCE_IGNORE_FILES "\\\\.git.*;/build/.+;${CPACK_SOURCE_IGNORE_FILES};")
#set(CPACK_RESOURCE_FILE_LICENSE "${ROOT_DIR}/COPYING")
set(CPACK_PACKAGE_NAME "MGRA")
set(CPACK_PACKAGE_VENDOR "George Washington University")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MGRA is a tool used for reconstruction genomes and transformation history")
set(CPACK_PACKAGE_VERSION_MAJOR ${MGRA_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${MGRA_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${MGRA_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "MGRA")
set(CMAKE_SOURCE_DIR ${ROOT_DIR})
include(CPack)