-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
106 lines (87 loc) · 2.84 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
cmake_minimum_required (VERSION 3.2)
project (NeuralNet)
# set compiler flags
set(CMAKE_CXX_COMPILER g++-5)
set(CMAKE_C_COMPILER gcc-5)
set(CXX_COMMON_FLAGS "" CACHE STRING "")
set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS}")
set(CMAKE_C_FLAGS "${CXX_COMMON_FLAGS}")
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_CXX_FLAGS} )
add_definitions(-std=c++11 -funroll-loops -fno-permissive)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set (PROJECT_TARGET_NAME "NeuralNet")
set(NeuralNet_VERSION_MAJOR 1)
set(NeuralNet_VERSION_MINOR 0)
# Options
option(USE_NN_MATRIX "Use Internal Matrix implementation" ON)
# Configure a header file to pass cmake settings
set(RESOURCES_PATH "${PROJECT_SOURCE_DIR}/res/")
configure_file (
"${PROJECT_SOURCE_DIR}/res/config.h.in"
"${PROJECT_BINARY_DIR}/res/config.h"
)
# add the binary tree to the search path for include files
include_directories("${PROJECT_BINARY_DIR}")
# include the matrix lib
if (USE_NN_MATRIX)
include_directories("${PROJECT_SOURCE_DIR}/Matrix")
add_subdirectory(Matrix)
set (EXTRA_LIBS ${EXTRA_LIBS} Matrix)
endif(USE_NN_MATRIX)
# add the executable
set (NN_SOURCE_FILES "main.cpp")
add_executable(${PROJECT_TARGET_NAME} ${NN_SOURCE_FILES})
target_link_libraries(${PROJECT_TARGET_NAME} ${EXTRA_LIBS})
# add the install targets
install (TARGETS NeuralNet DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/config.h" DESTINATION include)
# # # # ENABLE TESTS # # # #
enable_testing()
add_test(Run NeuralNet)
add_test(Usage NeuralNet -h)
set_tests_properties(Usage
PROPERTIES
PASS_REGULAR_EXPRESSION "Usage:.*"
)
# Macro to simplify adding tests
macro (do_test arg result)
add_test(Comp${arg} NeuralNet ${arg})
set_tests_properties(Comp${arg}
PROPERTIES
PASS_REGULAR_EXPRESSION ${result}
)
endmacro(do_test)
# # # # TESTS # # # #
# Usage: do_test(arguments, result)
# ...
# # # #
# Build a CPACK driven installer package
include(InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
set (CPACK_PACKAGE_VERSION_MAJOR "${NeuralNet_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${NeuralNet_VERSION_MINOR}")
set (CPACK_PACKAGE_CONTACT "[email protected]")
include(CPack)
include(CTest)
# # # # ENABLE UNIT TESTS - RUNTIME # # #
set (TESTS_TARGET_NAME "tests")
set (TESTS_SOURCE_FILES "tests.cpp")
add_executable(${TESTS_TARGET_NAME} ${TESTS_SOURCE_FILES})
target_link_libraries(${TESTS_TARGET_NAME} ${EXTRA_LIBS})
# Drive the post-build command through custom target
add_custom_command(
OUTPUT test_.lic
COMMAND Test ${PROJECT_TARGET_NAME}
DEPENDS tests
COMMENT "Testing ml/nn"
VERBATIM
)
add_custom_target(
RunTests ALL
DEPENDS test_.lic
)