@@ -12,70 +12,49 @@ elseif(NOT DEFINED CMAKE_INSTALL_PREFIX)
12
12
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR} " )
13
13
endif ()
14
14
15
+ # user options
16
+ option (NT_ENABLE_BENCHMARKING "enable benchmarking using google benchmark" OFF )
17
+ option (NT_ENABLE_PYTHON "enable python interface" OFF )
18
+ option (NT_COMPILE_TESTS "whether or not to compile unit and integration tests" ON )
19
+ option (NT_TEST_COVERAGE "produce code coverage reports when running tests" OFF )
20
+ option (NT_BUILD_TIMING "output time to build each target" OFF )
21
+ option (NT_USE_PCH "NT_USE_PCH" OFF )
22
+
23
+ ## to build the python library we require to build with the pic flag
24
+ if (NT_ENABLE_PYTHON)
25
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
26
+ endif ()
15
27
16
28
# Need to add some special compile flags to check the code test coverage
17
- OPTION (NT_TEST_COVERAGE "produce code coverage reports when running tests" OFF )
18
- IF (NT_TEST_COVERAGE)
29
+ if (NT_TEST_COVERAGE)
19
30
message ("Adding flags to check test coverage" )
20
31
add_compile_options ("--coverage" )
21
32
add_link_options ("--coverage" )
22
- ELSE ()
33
+ else ()
23
34
message ("Won't check test coverage" )
24
- ENDIF ()
35
+ endif ()
25
36
26
- enable_testing ()
37
+ # enable ctest
38
+ if (NT_COMPILE_TESTS)
39
+ message ("Compiling tests" )
40
+ enable_testing ()
41
+ else ()
42
+ message ("Won't compile tests" )
43
+ endif ()
27
44
28
45
##########################
29
46
#### add dependencies ####
30
47
##########################
31
48
32
49
include (cmake/CPM.cmake)
33
-
34
- find_package (Protobuf)
35
- if ( !Protobuf_FOUND )
36
- message ( "didn't find protobuf, will try installing using cpm" )
37
- CPMAddPackage("gh:protocolbuffer/protobuf@27.4" )
38
- endif ()
39
-
40
- find_package (Torch REQUIRED)
41
- message ("Torch cxx flags: ${TORCH_CXX_FLAGS} " )
42
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} " )
43
-
44
- CPMAddPackage("gh:gabime/spdlog@1.8.2" )
45
-
46
- # If user wants to enable benchmarking we need to set up google benchmark dependency
47
- OPTION (NT_ENABLE_BENCHMARKING "enable benchmarking using google benchmark" OFF )
48
- IF (NT_ENABLE_BENCHMARKING)
49
- message ("Enabling benchmarking" )
50
- CPMAddPackage(
51
- GITHUB_REPOSITORY "google/benchmark"
52
- VERSION 1.8.5
53
- OPTIONS "BENCHMARK_DOWNLOAD_DEPENDENCIES ON"
54
- )
55
- ELSE ()
56
- message ("Won't benchmark" )
57
- ENDIF ()
58
-
59
- # If user wants to enable python interface we need to include pybind
60
- OPTION (NT_ENABLE_PYTHON "enable python interface" OFF )
61
- IF (NT_ENABLE_PYTHON)
62
- message ("Enabling python" )
63
- CPMAddPackage(
64
- GITHUB_REPOSITORY "pybind/pybind11"
65
- VERSION 2.13.5
66
- )
67
-
68
- ELSE ()
69
- message ("Won't enable python interface" )
70
- ENDIF ()
50
+ include (cmake/nuTens-dependencies.cmake)
71
51
72
52
73
53
## check build times
74
54
## have this optional as it's not supported on all CMake platforms
75
- OPTION (NT_BUILD_TIMING "output time to build each target" OFF )
76
- IF (NT_BUILD_TIMING)
55
+ if (NT_BUILD_TIMING)
77
56
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time" )
78
- ENDIF ()
57
+ endif ()
79
58
80
59
81
60
######################################
@@ -85,17 +64,13 @@ ENDIF()
85
64
add_subdirectory (nuTens)
86
65
add_subdirectory (tests)
87
66
88
- IF (NT_ENABLE_BENCHMARKING)
89
- add_subdirectory (benchmarks)
90
- ENDIF ()
91
-
92
- IF (NT_ENABLE_PYTHON)
93
- set_property ( TARGET tensor PROPERTY POSITION_INDEPENDENT_CODE ON )
94
- set_property ( TARGET propagator PROPERTY POSITION_INDEPENDENT_CODE ON )
95
- set_property ( TARGET spdlog PROPERTY POSITION_INDEPENDENT_CODE ON )
96
- set_property ( TARGET logging PROPERTY POSITION_INDEPENDENT_CODE ON )
67
+ if (NT_ENABLE_PYTHON)
97
68
add_subdirectory (python)
98
- ENDIF ()
69
+ endif ()
70
+
71
+ if (NT_ENABLE_BENCHMARKING)
72
+ add_subdirectory (benchmarks)
73
+ endif ()
99
74
100
75
# Print out a handy message to more easily see the config options
101
76
message ( STATUS "The following variables have been used to configure the build: " )
0 commit comments