@@ -19,16 +19,44 @@ if (NOT (CMAKE_SIZEOF_VOID_P EQUAL 8))
19
19
message (FATAL_ERROR "HElib requires a 64-bit architecture." )
20
20
endif ()
21
21
22
- # Define standard installation directories (GNU)
23
- include (GNUInstallDirs)
24
-
25
22
# Use -std=c++14 as default.
26
23
set (CMAKE_CXX_STANDARD 14)
27
24
# Disable C++ extensions
28
25
set (CMAKE_CXX_EXTENSIONS OFF )
29
26
# Require full C++ standard
30
27
set (CMAKE_CXX_STANDARD_REQUIRED ON )
31
28
29
+ ################################################################################
30
+ # #
31
+ # FOLDER DEFINITIONS #
32
+ # #
33
+ ################################################################################
34
+
35
+ # Define standard installation directories (GNU)
36
+ include (GNUInstallDirs)
37
+
38
+ # Location of the cmake extra files
39
+ set (HELIB_CMAKE_EXTRA_DIR "${PROJECT_SOURCE_DIR} /cmake" )
40
+ # Prefix of the header files (directory to be added to the include list)
41
+ set (HELIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR} /include" )
42
+ # Location of helib header files
43
+ set (HELIB_HEADER_DIR "${HELIB_INCLUDE_DIR} /helib" )
44
+ # Location of the source files
45
+ set (HELIB_SOURCE_DIR "${PROJECT_SOURCE_DIR} /src" )
46
+ # Location of the google tests
47
+ set (HELIB_TESTS_DIR "${PROJECT_SOURCE_DIR} /tests" )
48
+ # Location of the directory containing the test binary (runTests).
49
+ # Keeping this location relative as it will be changed if PACKAGE_BUILD=ON.
50
+ set (HELIB_TEST_BIN_DIR "bin" )
51
+
52
+ # Setting compiler output directories
53
+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
54
+ ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
55
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
56
+ ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
57
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
58
+ ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} )
59
+
32
60
# GMP minimal version to be used if not PACKAGE_BUILD
33
61
set (GMP_MINIMAL_VERSION "6.0.0" )
34
62
# NTL minimal version to be used if NOT PACKAGE_BUILD
@@ -60,7 +88,7 @@ set_property(CACHE
60
88
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel" )
61
89
62
90
# Path containing FindGMP.cmake and FindNTL.cmake
63
- list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake " )
91
+ list (APPEND CMAKE_MODULE_PATH "${HELIB_CMAKE_EXTRA_DIR} " )
64
92
65
93
option (BUILD_SHARED "Build as shared library" OFF )
66
94
@@ -224,16 +252,6 @@ else (PACKAGE_BUILD)
224
252
# Checks that at least version NTL_MINIMAL_VERSION is available
225
253
find_package (NTL "${NTL_MINIMAL_VERSION} " REQUIRED)
226
254
227
- # Setting compiler output directories
228
- set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
229
- ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
230
- set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
231
- ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
232
- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
233
- ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} )
234
- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
235
- ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} )
236
-
237
255
# Thread enabling checks
238
256
# Checking if NTL is built with NTL_THREADS=on
239
257
set (ntl_config_file "${NTL_INCLUDE_PATHS} /NTL/config.h" )
@@ -295,13 +313,24 @@ if (PACKAGE_BUILD)
295
313
-DFETCH_GMP=${FETCH_GMP}
296
314
-DENABLE_TEST=${ENABLE_TEST}
297
315
-DHELIB_DEBUG=${HELIB_DEBUG}
316
+ -DHELIB_CMAKE_EXTRA_DIR=${HELIB_CMAKE_EXTRA_DIR}
317
+ -DHELIB_INCLUDE_DIR=${HELIB_INCLUDE_DIR}
318
+ -DHELIB_HEADER_DIR=${HELIB_HEADER_DIR}
319
+ -DHELIB_SOURCE_DIR=${HELIB_SOURCE_DIR}
320
+ -DHELIB_TESTS_DIR=${HELIB_TESTS_DIR}
298
321
BUILD_ALWAYS ON )
299
322
300
- if (ENABLE_TEST)
301
- add_test (NAME helib_check
302
- COMMAND ${CMAKE_MAKE_PROGRAM} test
303
- WORKING_DIRECTORY "${DEPENDENCIES_FOLDER} /Build/helib_external" )
304
- endif (ENABLE_TEST)
323
+ if (ENABLE_TEST)
324
+ # Tests for PACKAGE_BUILD are located in
325
+ # ${DEPENDENCIES_FOLDER}/Build/helib_external/${HELIB_TEST_BIN_DIR}.
326
+ # Update its location and add the tests to cmake to avoid re-creating
327
+ # their targets (as they are already built by ExternalProject_Add)
328
+ set (HELIB_TEST_BIN_DIR
329
+ "${DEPENDENCIES_FOLDER} /Build/helib_external/${HELIB_TEST_BIN_DIR} " )
330
+ set (ONLY_ADD_TEST ON )
331
+ add_subdirectory ("${HELIB_TESTS_DIR} " tests)
332
+ unset (ONLY_ADD_TEST)
333
+ endif (ENABLE_TEST)
305
334
306
335
# To install copy the whole PACKAGE_DIR directory to the defined prefix
307
336
install (
0 commit comments