-
Notifications
You must be signed in to change notification settings - Fork 382
/
CMakeLists.txt
170 lines (134 loc) · 5.45 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
IF(BIICODE)
# Initializes block variables
INIT_BIICODE_BLOCK()
# Output folder for binaries
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../bin/fann/examples)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../bin/fann/examples)
# Copy datasets for examples if exists
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/datasets)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/datasets DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../bin/)
ENDIF()
# Include recipes block for CPP11 activation
INCLUDE(biicode/cmake/tools)
# Are examples present?
LIST(FIND BII_BLOCK_EXES examples_parallel_train examples_present)
SET(examples_present (NOT ${examples_present} EQUAL "-1")) # Depending on examples
IF(${examples_present} AND NOT WIN32 AND NOT APPLE) # Linux doesn't have GetTickCount
LIST(REMOVE_ITEM BII_BLOCK_EXES examples_parallel_train)
ENDIF()
ADD_BIICODE_TARGETS()
IF(${examples_present})
# This example needs CPP11
ACTIVATE_CPP11(lasote_fann_examples_xor_sample)
ENDIF()
TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1)
IF(MSVC)
TARGET_COMPILE_OPTIONS(${BII_LIB_TARGET} PUBLIC -DFANN_DLL_EXPORTS)
ELSE()
IF(${examples_present})
TARGET_LINK_LIBRARIES(${BII_BLOCK_TARGET} INTERFACE gomp)
ENDIF()
ENDIF()
ELSE()
cmake_minimum_required (VERSION 2.8)
if (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif ()
project (FANN)
if(MSVC)
if(MSVC_VERSION GREATER_EQUAL "1800")
set(COMPILER_SUPPORTS_CXX11 ON)
else()
set(COMPILER_SUPPORTS_CXX11 OFF)
endif()
else()
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
endif()
IF(NOT COMPILER_SUPPORTS_CXX11)
message(WARNING "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Tests will not be compiled. To enable tests use a compiler that supports C++11.")
ENDIF()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# ugly-hack - fix [-Werror,-Wdeprecated-copy] in macos
add_compile_options(-Wno-deprecated)
endif()
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
set (FANN_VERSION_MAJOR 2)
set (FANN_VERSION_MINOR 2)
set (FANN_VERSION_PATCH 0)
set (FANN_VERSION_STRING ${FANN_VERSION_MAJOR}.${FANN_VERSION_MINOR}.${FANN_VERSION_PATCH})
option(BUILD_SHARED_LIBS "build shared/static libs" ON)
INCLUDE(DefineInstallationPaths)
configure_file (cmake/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/include/config.h)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/src/include/)
configure_file (cmake/fann.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/fann.pc @ONLY)
########### install files ###############
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/fann.pc DESTINATION ${PKGCONFIG_INSTALL_DIR})
ADD_SUBDIRECTORY( src )
################# cpack ################
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast Artificial Neural Network Library (FANN)")
SET(CPACK_PACKAGE_VENDOR "Steffen Nissen")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
SET(CPACK_PACKAGE_VERSION_MAJOR "${FANN_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${FANN_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${FANN_VERSION_PATCH}")
SET(CPACK_GENERATOR "TGZ;ZIP")
SET(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Steffen Nissen")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
IF(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
# SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
# SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
# SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} My Famous Project")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\leenissen.dk/fann/")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\leenissen.dk/fann/")
SET(CPACK_NSIS_CONTACT "[email protected]")
SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
# SET(CPACK_STRIP_FILES "bin/MyExecutable")
# SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(WIN32 AND NOT UNIX)
#SET(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable")
INCLUDE(CPack)
################# config ################
set (FANN_USE_FILE ${CMAKE_CONFIG_DIR}/fann-use.cmake)
set (FANN_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
set (FANN_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set (FANN_INCLUDE_DIRS ${FANN_INCLUDE_DIR})
set (FANN_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/lib)
set (FANN_LIBRARY fann)
set (FANN_LIBRARIES ${FANN_LIBRARY})
if (UNIX)
list (APPEND FANN_LIBRARIES m)
endif ()
if (CMAKE_VERSION VERSION_LESS 2.8.8)
configure_file (cmake/fann-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/fann-config.cmake @ONLY)
else ()
include (CMakePackageConfigHelpers)
configure_package_config_file (
cmake/fann-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/fann-config.cmake
INSTALL_DESTINATION FANN_CMAKE_CONFIG_DIR
PATH_VARS
FANN_USE_FILE
FANN_ROOT_DIR
FANN_INCLUDE_DIR
FANN_INCLUDE_DIRS
FANN_LIBRARY_DIRS
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
endif ()
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/fann-config.cmake
cmake/fann-use.cmake
DESTINATION ${CMAKE_CONFIG_DIR}
)
################# compile tests ################
ADD_SUBDIRECTORY( lib/googletest )
if(COMPILER_SUPPORTS_CXX11)
ADD_SUBDIRECTORY( tests )
endif()
ENDIF()