-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
666 lines (585 loc) · 25.6 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# CMakeLists files in this project can
# refer to the root source directory of the project as ${PDC_SOURCE_DIR} and
# to the root binary directory of the project as ${PDC_BINARY_DIR}.
cmake_minimum_required (VERSION 3.0)
# Setup cmake policies.
foreach(p
CMP0012 # CMake 2.6; Full Path Libraries; When set to NEW, the full path is included when specifying a link library in the target_link_libraries command.
CMP0013 # CMake 2.6; Quoted Argument Expansion; When set to NEW, variables within quoted arguments are expanded, allowing variable substitution.
CMP0014 # CMake 2.8; Relative Path Libraries; When set to NEW, relative paths in link libraries are interpreted as relative to the current source directory.
CMP0022 # CMake 2.8.12; Same SONAME Overwrite; When set to NEW, shared libraries with the same SONAME are not overwritten during installation.
CMP0025 # CMake 3.0; Empty if Statement; When set to NEW, an empty if condition is treated as false, providing better control over conditionals.
CMP0053 # CMake 3.1; Find Package Version; When set to NEW, the VERSION option in find_package is interpreted as a version requirement rather than a version hint.
CMP0054 # CMake 3.1; Quoted Empty String; When set to NEW, a quoted empty string is treated as false in the if() command.
CMP0074 # CMake 3.12; Imported Target Usage Requirements; When set to NEW, the "PRIVATE" and "PUBLIC" keywords in target_link_libraries are treated as usage requirements for imported targets.
CMP0075 # CMake 3.12; GNU-Style Installation Paths on macOS; When set to NEW, the "GNUInstallDirs" module is enabled by default on macOS for "GNU-style" installation paths.
CMP0083 # CMake 3.14; Imported Targets Visibility; When set to NEW, imported targets created by find_package with namespaced aliases are visible to other targets within the same directory scope.
CMP0093 # CMake 3.15; Compiler and Linker Flags Handling; When set to NEW, each option in a list of compiler and linker flags is interpreted separately, allowing better control over individual options.
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()
# Set a consistent MACOSX_RPATH default across all CMake versions.
# checks if the variable CMAKE_MACOSX_RPATH is not defined and sets it to 0 if it is not defined.
# The CMAKE_MACOSX_RPATH variable is used to control the behavior of the macOS-specific RPATH feature in CMake.
# RPATH is a linker option that specifies the runtime library search path for executables and shared libraries.
# By default, when CMAKE_MACOSX_RPATH is not defined, the code sets it to 0, indicating that the project does not use the macOS RPATH feature.
# This means that the runtime library search path will not be embedded in the executables or shared libraries produced by the project.
# This code snippet ensures a consistent default value for CMAKE_MACOSX_RPATH across different configurations of the project, even if the variable is not explicitly set before.
# When CMake 2.8.12 is required, change this default to 1.
# When CMake 3.0.0 is required, remove this block (see CMP0042).
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
# Project Name : PDC, Programming Language : C
project(PDC C)
# include CheckSymbolExists module
include(CheckSymbolExists)
# CMake will search for any header files under the project root directory.
include_directories(
${PROJECT_SOURCE_DIR}
)
# Check if MPI_RUN_CMD is not defind. If not, set it to mpiexec.
if(NOT MPI_RUN_CMD)
set(MPI_RUN_CMD mpiexec)
endif()
#------------------------------------------------------------------------------
# Version information
#------------------------------------------------------------------------------
set(PDC_VERSION_MAJOR "0")
set(PDC_VERSION_MINOR "1")
set(PDC_VERSION_PATCH "0")
set(PDC_PACKAGE "pdc")
set(PDC_PACKAGE_NAME "PDC")
set(PDC_PACKAGE_VERSION "${PDC_VERSION_MAJOR}.${PDC_VERSION_MINOR}.${PDC_VERSION_PATCH}")
set(PDC_PACKAGE_VERSION_MAJOR "${PDC_VERSION_MAJOR}.${PDC_VERSION_MINOR}")
set(PDC_PACKAGE_VERSION_MINOR "${PDC_VERSION_PATCH}")
set(PDC_PACKAGE_STRING "${PDC_PACKAGE_NAME} ${PDC_PACKAGE_VERSION}")
set(PDC_PACKAGE_TARNAME "${PDC_PACKAGE}")
#------------------------------------------------------------------------------
# Setup CMake Prefix Paths for searching external libraries.
#------------------------------------------------------------------------------
if(NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
endif()
#------------------------------------------------------------------------------
# general cmake flags:
# -DCMAKE_INSTALL_PREFIX=/usr/local -- the prefix for installing
# -DCMAKE_BUILD_TYPE=type -- type can be Debug, Release, ...
# -DCMAKE_PREFIX_PATH=/dir -- external packages
#
# note that CMAKE_PREFIX_PATH can be a list of directories:
# -DCMAKE_PREFIX_PATH='/dir1;/dir2;/dir3'
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Setup install and output Directories
#------------------------------------------------------------------------------
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
endif()
if(NOT PDC_INSTALL_BIN_DIR)
set(PDC_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
endif()
if(NOT PDC_INSTALL_LIB_DIR)
set(PDC_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
endif()
if(NOT PDC_INSTALL_INCLUDE_DIR)
set(PDC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
endif()
if(NOT PDC_INSTALL_DATA_DIR)
set(PDC_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share)
endif()
if(NOT PDC_INSTALL_SHARE_DIR)
set(PDC_INSTALL_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/cmake/pdc)
endif()
# The purpose of setting CMAKE_INSTALL_RPATH_USE_LINK_PATH to TRUE is to
# include the directories specified by the linker during the build process
# in the install RPATH, ensuring that the installed binary can locate its
# required shared libraries during runtime, regardless of the platform being used.
#
# Setting this ensures that "make install" will leave rpaths to external
# libraries intact on "make install". This ensures that one can install a
# version of PDC on the build machine without any issues. If this not
# desired, simply specify CMAKE_INSTALL_RPATH_USE_LINK_PATH when configuring
# PDC and "make install" will strip all rpaths, which is default behavior.
if(NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
#------------------------------------------------------------------------------
# Setup CMake Prefix Paths for searching external libraries.
#------------------------------------------------------------------------------
# note that CMAKE_PREFIX_PATH can be a list of directories:
# -DCMAKE_PREFIX_PATH='/dir1;/dir2;/dir3'
if(NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
endif()
# MERCURY
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{MERCURY_DIR})
# ANY Future external package goes here...
#------------------------------------------------------------------------------
# Setup CMake Environment
#------------------------------------------------------------------------------
if(APPLE)
# We are doing a unix-style install i.e. everything will be installed in
# CMAKE_INSTALL_PREFIX/bin and CMAKE_INSTALL_PREFIX/lib etc. as on other unix
# platforms. We still need to setup CMAKE_INSTALL_NAME_DIR correctly so that
# the binaries point to appropriate location for the libraries.
# 1. Make CMAKE_INSTALL_PREFIX publicly accessible, if it was hidden in
# previous pass
get_property(is_internal CACHE CMAKE_INSTALL_PREFIX PROPERTY TYPE)
if(is_internal STREQUAL "INTERNAL")
set(CMAKE_INSTALL_PREFIX ${CACHED_CMAKE_INSTALL_PREFIX} CACHE PATH "Install prefix" FORCE)
else()
set(CMAKE_INSTALL_PREFIX ${CACHED_CMAKE_INSTALL_PREFIX} CACHE PATH "Install prefix")
endif()
unset(MACOSX_APP_INSTALL_PREFIX CACHE)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
mark_as_advanced(
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT
)
endif()
#------------------------------------------------------------------------------
if(NOT PDC_EXTERNALLY_CONFIGURED)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables."
)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries"
)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries."
)
endif()
set(PDC_CMAKE_DIR "${PDC_SOURCE_DIR}/CMake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PDC_CMAKE_DIR})
#------------------------------------------------------------------------------
# Disallow in-source build
#------------------------------------------------------------------------------
if("${PDC_SOURCE_DIR}" STREQUAL "${PDC_BINARY_DIR}")
message(FATAL_ERROR
"PDC requires an out of source Build. "
"Please create a separate binary directory and run CMake there.")
endif()
#------------------------------------------------------------------------------
# Set whether or not to disable compiler warnings
#------------------------------------------------------------------------------
set(SUPPRESSED_LIST "")
# Disable warnings for potentially ignorable issues
option(SUPPRESS_IGNORABLE_WARNINGS "Disable warnings for potentially ignorable issues" ON)
if(SUPPRESS_IGNORABLE_WARNINGS)
if(APPLE)
set(SUPPRESSED_LIST "-Wno-deprecated-non-prototype" ${SUPPRESSED_LIST})
else()
set(SUPPRESSED_LIST "-Wno-maybe-uninitialized" ${SUPPRESSED_LIST})
endif()
set(SUPPRESSED_LIST "-Wno-sign-compare" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-format" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-cast-qual" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-unused-parameter" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-unused-variable" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-unused-function" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-unused-result" ${SUPPRESSED_LIST})
set(SUPPRESSED_LIST "-Wno-unused-but-set-variable" ${SUPPRESSED_LIST})
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(${SUPPRESSED_LIST})
endif()
endif()
#------------------------------------------------------------------------------
# Set a default build type if none was specified
#------------------------------------------------------------------------------
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if(NOT CMAKE_C_FLAGS AND CMAKE_COMPILER_IS_GNUCC)
message(STATUS "GCC detected, setting additional flags")
set(CMAKE_C_FLAGS "-Wall -Wextra -Winline -Wcast-qual -std=gnu99 -Wshadow -fcommon" CACHE STRING "Flags used by the compiler during all build types." FORCE)
endif()
#-----------------------------------------------------------------------------
# Targets built within this project are exported at Install time for use
# by other projects.
#-----------------------------------------------------------------------------
if(NOT PDC_EXPORTED_TARGETS)
set(PDC_EXPORTED_TARGETS "pdc-targets")
endif()
#------------------------------------------------------------------------------
# Choose static or shared libraries.
#------------------------------------------------------------------------------
option(BUILD_SHARED_LIBS "Build with shared libraries." OFF)
#-------------------------------------------------------------------------------
function(pdc_set_lib_options libtarget libname libtype)
if(${libtype} MATCHES "SHARED")
if(WIN32 AND NOT MINGW)
set(LIB_RELEASE_NAME "${libname}")
set(LIB_DEBUG_NAME "${libname}_D")
set(LIB_VERSION ${PDC_PACKAGE_VERSION_MAJOR})
else()
set(LIB_RELEASE_NAME "${libname}")
set(LIB_DEBUG_NAME "${libname}_debug")
set(LIB_VERSION ${PDC_PACKAGE_VERSION})
endif()
else()
if(WIN32 AND NOT MINGW)
set(LIB_RELEASE_NAME "lib${libname}")
set(LIB_DEBUG_NAME "lib${libname}_D")
else()
# if the generator supports configuration types or if the CMAKE_BUILD_TYPE has a value
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
set(LIB_RELEASE_NAME "${libname}")
set(LIB_DEBUG_NAME "${libname}_debug")
else()
set(LIB_RELEASE_NAME "lib${libname}")
set(LIB_DEBUG_NAME "lib${libname}_debug")
endif()
endif()
endif()
set_target_properties(${libtarget}
PROPERTIES
DEBUG_OUTPUT_NAME ${LIB_DEBUG_NAME}
RELEASE_OUTPUT_NAME ${LIB_RELEASE_NAME}
MINSIZEREL_OUTPUT_NAME ${LIB_RELEASE_NAME}
RELWITHDEBINFO_OUTPUT_NAME ${LIB_RELEASE_NAME}
VERSION ${LIB_VERSION}
SOVERSION ${LIB_VERSION}
)
#----- Use MSVC Naming conventions for Shared Libraries
if(MINGW AND ${libtype} MATCHES "SHARED")
set_target_properties(${libtarget}
PROPERTIES
IMPORT_SUFFIX ".lib"
IMPORT_PREFIX ""
PREFIX ""
)
endif()
endfunction()
#--------------- start generating config.h from config.h.cmake ---------------
#-----------------------------------------------------------------------------
# Server mode option
#-----------------------------------------------------------------------------
option(PDC_USE_SHARED_SERVER
"Use shared server with client mode." OFF)
if(PDC_USE_SHARED_SERVER)
set(PDC_HAS_SHARED_SERVER 1)
endif()
#-----------------------------------------------------------------------------
# DRC option
#-----------------------------------------------------------------------------
option(PDC_USE_CRAY_DRC
"Use Cray DRC to allow multi-job communication." OFF)
if(PDC_USE_CRAY_DRC)
find_package(DRC REQUIRED)
if(DRC_FOUND)
set(PDC_HAS_CRAY_DRC 1)
include_directories(${DRC_INCLUDE_DIRS})
set(PDC_EXT_LIB_DEPENDENCIES
${PDC_EXT_LIB_DEPENDENCIES}
${DRC_LIBRARIES}
)
else()
message(FATAL_ERROR "Could not find Cray DRC.")
endif()
endif()
#-----------------------------------------------------------------------------
# DART Suffix Tree mode
#-----------------------------------------------------------------------------
option(PDC_DART_SUFFIX_TREE_MODE "Enable DART Suffix Tree mode." ON)
if(PDC_DART_SUFFIX_TREE_MODE)
set(PDC_DART_SFX_TREE 1)
# add_compile_definitions(PDC_DART_SFX_TREE=${PDC_DART_SFX_TREE})
endif()
#-----------------------------------------------------------------------------
# Julia Support option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_JULIA_SUPPORT "Enable Julia Support." OFF)
if(PDC_ENABLE_JULIA_SUPPORT)
find_package(JULIA REQUIRED)
if(JULIA_FOUND)
set(PDC_ENABLE_JULIA 1)
# include_directories(${JULIA_INCLUDE_DIRS})
# set(PDC_EXT_LIB_DEPENDENCIES
# ${PDC_EXT_LIB_DEPENDENCIES}
# ${JULIA_LIBRARIES}
# )
else()
message(FATAL_ERROR "Could not find Julia.")
endif()
endif()
#-----------------------------------------------------------------------------
# MPI option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_MPI "Enable MPI." ON)
if(PDC_ENABLE_MPI)
find_package(MPI)
if(MPI_FOUND)
set(ENABLE_MPI 1)
endif()
endif()
#-----------------------------------------------------------------------------
# LUSTRE option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_LUSTRE "Enable Lustre." OFF)
if(PDC_ENABLE_LUSTRE)
set(ENABLE_LUSTRE 1)
set(PDC_LUSTRE_TOTAL_OST "256" CACHE STRING "Number of Lustre OSTs")
endif()
#-----------------------------------------------------------------------------
# TIMING option
#-----------------------------------------------------------------------------
option(PDC_TIMING "Enable timing." OFF)
if(PDC_TIMING)
set(PDC_TIMING 1)
endif()
#-----------------------------------------------------------------------------
# SERVER CACHE option
#-----------------------------------------------------------------------------
option(PDC_SERVER_CACHE "Enable Server Caching." ON)
if(PDC_SERVER_CACHE)
set(PDC_SERVER_CACHE 1)
set(PDC_SERVER_CACHE_MAX_GB "3" CACHE STRING "Max GB for server cache")
set(PDC_SERVER_CACHE_FLUSH_TIME "30" CACHE STRING "Flush time for server cache")
add_compile_definitions(PDC_SERVER_CACHE_MAX_GB=${PDC_SERVER_CACHE_MAX_GB} PDC_SERVER_CACHE_FLUSH_TIME=${PDC_SERVER_CACHE_FLUSH_TIME})
endif()
#-----------------------------------------------------------------------------
# CHECKPOINT option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_CHECKPOINT "Enable checkpointing." ON)
if(PDC_ENABLE_CHECKPOINT)
set(PDC_ENABLE_CHECKPOINT 1)
endif()
#-----------------------------------------------------------------------------
# Close server by application option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_APP_CLOSE_SERVER
"Close pdc server at the end of application." OFF)
if(PDC_ENABLE_APP_CLOSE_SERVER)
set(ENABLE_APP_CLOSE_SERVER 1)
endif()
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
option(PDC_ENABLE_WAIT_DATA
"Wait for data fanalized in FS when object unmap is called." OFF)
if(PDC_ENABLE_WAIT_DATA)
set(ENABLE_WAIT_DATA 1)
endif()
if(PDC_ENABLE_APP_CLOSE_SERVER AND NOT PDC_ENABLE_WAIT_DATA)
message("WARNING: data tranx may be not done when closing server by application")
message("Wait for data, or close the server later")
endif()
#-----------------------------------------------------------------------------
# MULTITHREAD option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_MULTITHREAD "Enable multithreading." OFF)
if(PDC_ENABLE_MULTITHREAD)
set(ENABLE_MULTITHREAD 1)
endif()
#-----------------------------------------------------------------------------
# Pthread support on Mac OS X
#-----------------------------------------------------------------------------
if(APPLE)
find_package(Threads REQUIRED)
endif()
#-----------------------------------------------------------------------------
# PROFILING option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_PROFILING "Enable profiling." OFF)
if(PDC_ENABLE_PROFILING)
set(ENABLE_PROFILING 1)
endif()
# Not used
# option(PDC_ENABLE_CACHE "Enable data caching." OFF)
# if(PDC_ENABLE_CACHE)
# set(ENABLE_CACHE 1)
# endif()
#-----------------------------------------------------------------------------
# ATTRIBUTE option
#-----------------------------------------------------------------------------
option(PDC_HAVE_ATTRIBUTE_UNUSED "Use compiler attribute" ON)
if(PDC_HAVE_ATTRIBUTE_UNUSED)
set(HAVE_ATTRIBUTE 1)
endif()
#-----------------------------------------------------------------------------
# Query with Fastbit option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_FASTBIT "Enable Fastbit." OFF)
if(PDC_ENABLE_FASTBIT)
find_library(FASTBIT fastbit)
set(ENABLE_FASTBIT 1)
endif()
# Metadata with RocksDB
#-----------------------------------------------------------------------------
option(PDC_ENABLE_ROCKSDB "Enable RocksDB (experimental)." OFF)
if(PDC_ENABLE_ROCKSDB)
set(ENABLE_ROCKSDB 1)
endif()
# Metadata with SQLite
#-----------------------------------------------------------------------------
option(PDC_ENABLE_SQLITE3 "Enable SQLite3 (experimental)." OFF)
if(PDC_ENABLE_SQLITE3)
set(ENABLE_SQLITE3 1)
endif()
# Check availability of symbols
#-----------------------------------------------------------------------------
check_symbol_exists(malloc_usable_size "malloc.h" HAVE_MALLOC_USABLE_SIZE)
if(HAVE_MALLOC_USABLE_SIZE)
add_definitions(-DHAVE_MALLOC_USABLE_SIZE)
endif()
#------------------------------------------------------------------------------
# Data type
#------------------------------------------------------------------------------
include(CheckTypeSize)
check_type_size("float" VAR_SIZE_FLOAT)
check_type_size("double" VAR_SIZE_DOUBLE)
check_type_size("char" VAR_SIZE_CHAR)
check_type_size("short" VAR_SIZE_SINT)
check_type_size("int" VAR_SIZE_INT)
check_type_size("long" VAR_SIZE_LINT)
check_type_size("long long" VAR_SIZE_LLINT)
check_type_size("unsigned" VAR_SIZE_UINT)
check_type_size("unsigned long" VAR_SIZE_ULINT)
check_type_size("unsigned long long" VAR_SIZE_ULLINT)
check_type_size("int64_t" VAR_SIZE_64INT)
check_type_size("uint64_t" VAR_SIZE_U64INT)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pdc_config_sys.h.cmake ${PROJECT_BINARY_DIR}/pdc_config_sys.h)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/pdc_config.h.in
${PROJECT_BINARY_DIR}/pdc_config.h
)
#---------------------- end of generating config.h ---------------------------
#-----------------------------------------------------------------------------
# Source
#-----------------------------------------------------------------------------
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/commons)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/api)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/server)
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
option(BUILD_TESTING "Build testing." OFF)
option(BUILD_MPI_TESTING "Build MPI testing." OFF)
if(NOT PDC_EXTERNALLY_CONFIGURED AND BUILD_TESTING)
enable_testing()
include(CTest)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/tests)
endif()
option(BUILD_TOOLS "Build Tools." OFF)
if(BUILD_TOOLS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/tools)
endif()
#-----------------------------------------------------------------------------
# Build doxygen documentation.
#-----------------------------------------------------------------------------
# option(BUILD_DOCUMENTATION "Build documentation." OFF)
# if(BUILD_DOCUMENTATION)
# add_subdirectory(doc/doxygen)
# endif()
#-----------------------------------------------------------------------------
# Configure the config.cmake file for the build directory
#-----------------------------------------------------------------------------
configure_file(
${PDC_SOURCE_DIR}/CMake/pdc-config.cmake.build.in
${PDC_BINARY_DIR}/pdc-config.cmake @ONLY
)
#-----------------------------------------------------------------------------
# Configure the config.cmake file for the install directory
#-----------------------------------------------------------------------------
configure_file(
${PDC_SOURCE_DIR}/CMake/pdc-config.cmake.install.in
${PDC_BINARY_DIR}/CMakeFiles/pdc-config.cmake @ONLY
)
install(
FILES
${PDC_BINARY_DIR}/CMakeFiles/pdc-config.cmake
DESTINATION
${PDC_INSTALL_DATA_DIR}/cmake/pdc
)
#-----------------------------------------------------------------------------
# Configure the pdc-config-version .cmake file for the install directory
#-----------------------------------------------------------------------------
configure_file(
${PDC_SOURCE_DIR}/CMake/pdc-config-version.cmake.in
${PDC_BINARY_DIR}/CMakeFiles/pdc-config-version.cmake @ONLY
)
install(
FILES
${PDC_BINARY_DIR}/CMakeFiles/pdc-config-version.cmake
DESTINATION
${PDC_INSTALL_DATA_DIR}/cmake/pdc
)
install(
DIRECTORY
${PDC_BINARY_DIR}/bin
DESTINATION
${PDC_INSTALL_DATA_DIR}/test
FILES_MATCHING PATTERN "*"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(BUILD_TOOLS)
install(
FILES
${PDC_BINARY_DIR}/bin/pdc_ls
${PDC_BINARY_DIR}/bin/pdc_export
${PDC_BINARY_DIR}/bin/pdc_import
DESTINATION
${CMAKE_INSTALL_PREFIX}/bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(
DIRECTORY
${PDC_SOURCE_DIR}/scripts
DESTINATION
${CMAKE_INSTALL_PREFIX}
FILES_MATCHING PATTERN "*.sh"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
# set(ADD_EXE_PERMISSION_CMD "chmod +x ${}/test/*")
# add_custom_command(TARGET ${PROJECT_NAME} POST_INSTALL COMMAND ${add_permission_cmd})
#install(
# FILES
# ${PDC_BINARY_DIR}/bin/pdc_server.exe
# ${PDC_BINARY_DIR}/bin/close_server
# DESTINATION
# ${CMAKE_INSTALL_PREFIX}/bin
#)
#-----------------------------------------------------------------------------
# CPack
#-----------------------------------------------------------------------------
if(NOT PDC_EXTERNALLY_CONFIGURED)
# set(CPACK_PACKAGE_DESCRIPTION_FILE ${PDC_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Proactive Data Containers")
set(CPACK_PACKAGE_NAME "PDC")
set(CPACK_PACKAGE_VENDOR "LBNL / The HDF Group / ANL")
set(CPACK_PACKAGE_VERSION_MAJOR ${PDC_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PDC_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PDC_VERSION_PATCH})
set(CPACK_GENERATOR "TBZ2")
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PDC_PACKAGE_TARNAME}-${PDC_PACKAGE_VERSION})
set(CPACK_SOURCE_IGNORE_FILES ".git*;/GitSetup/;/.git/;.swp$;.#;/#;.*~")
set(CPACK_SOURCE_STRIP_FILES "")
include(CPack)
endif()
add_custom_target(format
COMMAND find
${PDC_SOURCE_DIR}/src/api
${PDC_SOURCE_DIR}/src/server
${PDC_SOURCE_DIR}/src/tests
-type f
(
-name "*.c"
-o
-name "*.h"
)
-print0
| xargs -0 clang-format -i -style=file && echo "... done"
COMMENT "clang-format all source codes"
VERBATIM
)