forked from Illumina/interop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
209 lines (180 loc) · 7.98 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
cmake_minimum_required(VERSION 3.4)
if(APPLE AND NOT DEFINED CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for Mac OS X" FORCE)
message(STATUS "Building on mac with universal binaries")
endif()
project(InterOp)
project(interop)
message(STATUS "CMake Version: ${CMAKE_VERSION}")
message(STATUS "CMake Generator: ${CMAKE_GENERATOR} ${CMAKE_GENERATOR_PLATFORM} ${CMAKE_GENERATOR_TOOLSET}")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
enable_testing()
include(${PROJECT_SOURCE_DIR}/cmake/Modules/UseGitVersion.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/DependencyManager.cmake)
set(ARCHIVE_VERSION "v3.0.35-src")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
message(WARNING "GCC compiler versions less than 4.8 are not supported and may not work")
endif()
endif()
option(ENABLE_PORTABLE "Statically link libraries for GCC compiler and disable OpenMP" OFF)
find_package(OpenMP)
if(OPENMP_FOUND AND NOT ENABLE_PORTABLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
# TODO: https://help.github.com/articles/creating-project-pages-manually/
# TODO: Handle Windows Shared libs: https://cmake.org/Wiki/BuildingWinDLL
option(ENABLE_BACKWARDS_COMPATIBILITY "Compile code for c++98" OFF)
option(ENABLE_DOCS "Build documentation with Doxygen" ON)
option(ENABLE_SWIG "Build third-party language bindings, e.g. C#" ON)
option(ENABLE_TEST "Build unit tests (depends on Boost)" ON)
option(ENABLE_APPS "Build command line programs" ON)
option(ENABLE_EXAMPLES "Build example programs" ON)
option(ENABLE_STATIC "Build static libraries instead of dynamic" ON)
option(ENABLE_CSHARP "Build C# language bindings" ON)
option(ENABLE_PYTHON "Build Python language bindings" ON)
option(DISABLE_PACKAGE_SUBDIR "Disable placing the packaged build in a subdirectory structure: interop/${VERSION}" OFF)
option(ENABLE_PYTHON_DYNAMIC_LOAD "Do not link to Python shared library (Linux and Mac)" ON)
option(ENABLE_DEPENDENCY_MANAGER "Download dependencies from Artifactory" ON)
option(ENABLE_DEPENDENCY_MANAGER_WINDOWS_ONLY "Only check for dependencies on Windows Platforms" ON)
option(SKIP_PACKAGE_ALL_WHEEL "Do not package a well as apart of the package_all target" OFF)
set(DEPENDENCY_URL "" CACHE STRING "Location of dependencies for Windows")
# Not officially supported if changed from default
option(FORCE_X86 "Force 32-bit libraries instead of platform default (Does nothing for Visual Studio)" OFF)
option(FORCE_SHARED_CRT "Used the shared (DLL) run time lib in MSVC (must be ON if compiling for C#)" ON)
if(ENABLE_DEPENDENCY_MANAGER)
if(WIN32 OR NOT ENABLE_DEPENDENCY_MANAGER_WINDOWS_ONLY)
set(DEPS_URL ${DEPENDENCY_URL})
else()
set(DEPS_URL "")
endif()
if(DEPS_URL)
update_dependencies(
${DEPS_URL}
.illumina.builddeps.interop
DEPS_DIR
)
endif()
endif()
if(DEPS_DIR)
message(STATUS "Using prebuilt dependencies at ${DEPS_DIR}")
set(GTEST_DIR ${DEPS_DIR})
set(GMOCK_DIR ${DEPS_DIR})
set(JUNIT_DIR ${DEPS_DIR})
set(NUNIT_DIR ${DEPS_DIR}/NUnit-2.6.4)
if(WIN32)
if(EXISTS ${DEPS_DIR}/nuget.exe)
set(NUGET_EXE ${DEPS_DIR}/nuget.exe)
endif()
if(EXISTS ${DEPS_DIR}/swig.exe)
set(SWIG_EXECUTABLE ${DEPS_DIR}/swig.exe)
endif()
endif()
else()
message(STATUS "No prebuilt dependencies found")
endif()
include(${PROJECT_SOURCE_DIR}/cmake/InternalUtils.cmake)
interop_config_compiler_and_linker()
set(INTEROP_TESTS interop_tests)
set(INTEROP_LIB interop_lib)
if(COMPILER_IS_GNUCC_OR_CLANG AND NOT MINGW)
set(INTEROP_DL_LIB interop_fpic_lib)
else()
set(INTEROP_DL_LIB interop_lib)
endif()
# Options to control integration builds
set(BUILD_NUMBER "" CACHE STRING "Build number used for select packing scripts")
mark_as_advanced(BUILD_NUMBER)
include_directories(. ${CMAKE_CURRENT_BINARY_DIR}/include)
add_version_target(version ${CMAKE_CURRENT_BINARY_DIR}/include/interop/version.h INTEROP_VERSION ${ARCHIVE_VERSION})
if(INTEROP_VERSION)
string(REGEX REPLACE "[^v]*(v.*)" "\\1" VERSION ${INTEROP_VERSION})
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_SHA1 "${VERSION}")
if(VERSION_SHA1)
string(REGEX REPLACE "[^0-9]*([0-9]*)-.*" "\\1" VERSION_DEV "${VERSION_SHA1}")
if(VERSION_DEV)
set(VERSION_DEV ".dev${VERSION_DEV}")
endif()
endif()
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
string(REPLACE "." "," VERSION_LIST "${VERSION_SHORT}") # Used to configure the version info file
message(STATUS "InterOp v${VERSION_SHORT}")
if(WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Illumina InterOp - ${VERSION_SHORT}")
set(CPACK_PACKAGE_VENDOR "Illumina, Inc.")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "interop_${VERSION_SHORT}")
if(NOT PACKAGE_OUTPUT_FILE_PREFIX)
set(PACKAGE_OUTPUT_FILE_PREFIX ".")
else()
get_filename_component(PACKAGE_OUTPUT_FILE_PREFIX ${PACKAGE_OUTPUT_FILE_PREFIX} ABSOLUTE)
endif()
if(DISABLE_PACKAGE_SUBDIR)
set(CPACK_OUTPUT_FILE_PREFIX "${PACKAGE_OUTPUT_FILE_PREFIX}")
else()
set(CPACK_OUTPUT_FILE_PREFIX "${PACKAGE_OUTPUT_FILE_PREFIX}/interop/${VERSION}")
endif()
endif()
include(CPack)
#https://stackoverflow.com/questions/12302836/renaming-cpack-automatic-target
add_custom_target(bundle
COMMAND ${CMAKE_CPACK_COMMAND} -C $<CONFIG> --config ${CPACK_OUTPUT_CONFIG_FILE})
if(TARGET doc)
add_dependencies(bundle doc)
endif()
if(ENABLE_STATIC)
set(LIBRARY_TYPE STATIC)
set(BUILD_SHARED_LIBS OFF)
else()
set(LIBRARY_TYPE SHARED)
set(BUILD_SHARED_LIBS ON)
endif()
if(WIN32 AND ${LIBRARY_TYPE} STREQUAL "SHARED")
message(FATAL_ERROR "Shared libraries on Windows are not supported")
endif()
add_subdirectory("src")
if(ENABLE_DOCS)
add_subdirectory("docs")
endif()
install(DIRECTORY interop DESTINATION include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/interop/version.h DESTINATION include/interop)
install(FILES README.md docs/src/changes.md DESTINATION .)
find_package(Git)
if(GIT_FOUND)
string(REGEX REPLACE "[^v]*(v[0-9]+.[0-9]+.[0-9]+)-.*" "\\1" TAG ${INTEROP_VERSION})
add_custom_target(history
COMMAND ${GIT_EXECUTABLE} log ${TAG}..HEAD -m --first-parent --date=short --format='%ad | %s'
COMMENT "${GIT_EXECUTABLE} log ${TAG}..HEAD -m --first-parent --date=short --format=%ad | %s"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
set_target_properties(bundle PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
configure_file(interop/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/interop/config.h @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/interop/config.h DESTINATION include/interop)
message(STATUS "Supported Languages")
message(STATUS " C++") # Version
if(PYTHON_BUILD_AVAILABLE)
message(STATUS " ${PYTHON_BUILD_AVAILABLE}")
endif()
if(CSHARP_BUILD_AVAILABLE)
message(STATUS " ${CSHARP_BUILD_AVAILABLE}")
endif()
if(JAVA_BUILD_AVAILABLE)
message(STATUS " ${JAVA_BUILD_AVAILABLE}")
endif()