Skip to content

Commit 906b46d

Browse files
committed
Merge commit '7dfff533092284813ce088a297340aa06bff7d42' as 'nix'
2 parents 6c0a249 + 7dfff53 commit 906b46d

File tree

378 files changed

+226469
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

378 files changed

+226469
-0
lines changed

nix/.clang-format

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
BasedOnStyle: LLVM
2+
AlignConsecutiveAssignments: true
3+
AlignConsecutiveDeclarations: true
4+
AllowShortBlocksOnASingleLine: Never
5+
AllowShortCaseLabelsOnASingleLine: false
6+
#AllowShortEnumsOnASingleLine: false
7+
AllowShortFunctionsOnASingleLine: None
8+
AllowShortIfStatementsOnASingleLine: Never
9+
AllowShortLoopsOnASingleLine: false
10+
AlwaysBreakTemplateDeclarations: Yes
11+
BreakBeforeBraces: Linux
12+
ColumnLimit: 100
13+
PointerAlignment: Left
14+
SortUsingDeclarations: false

nix/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
compiler.mk
2+
a.out
3+
*.o
4+
*.d
5+
*.dat
6+
*.h5
7+
*.a
8+
*.pyc
9+
test_application
10+
test_sendrecv
11+
test_chunk
12+
test_chunkmap
13+
test_jsonio1
14+
test_jsonio2
15+
test_sfc
16+
test_particle
17+
build

nix/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
set(CMAKE_CXX_STANDARD 17)
3+
4+
# project
5+
project(nix CXX)
6+
7+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
8+
9+
# filesystem
10+
find_package(Filesystem REQUIRED)
11+
12+
# xsimd for xtensor
13+
add_compile_definitions(XTENSOR_USE_XSIMD)
14+
15+
# build static library
16+
add_library(nix STATIC balancer.cpp nixio.cpp sfc.cpp)
17+
18+
# include directory
19+
target_include_directories(nix PUBLIC ${PROJECT_SOURCE_DIR})
20+
target_include_directories(nix PUBLIC ${PROJECT_SOURCE_DIR}/thirdparty)
21+
22+
# unittest
23+
if(ENABLE_TESTING)
24+
enable_testing()
25+
add_subdirectory(unittest)
26+
endif()

nix/FindFilesystem.cmake

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2+
# file Copyright.txt or https://cmake.org/licensing for details.
3+
4+
#[=======================================================================[.rst:
5+
6+
FindFilesystem
7+
##############
8+
9+
This module supports the C++17 standard library's filesystem utilities. Use the
10+
:imp-target:`std::filesystem` imported target to
11+
12+
Options
13+
*******
14+
15+
The ``COMPONENTS`` argument to this module supports the following values:
16+
17+
.. find-component:: Experimental
18+
:name: fs.Experimental
19+
20+
Allows the module to find the "experimental" Filesystem TS version of the
21+
Filesystem library. This is the library that should be used with the
22+
``std::experimental::filesystem`` namespace.
23+
24+
.. find-component:: Final
25+
:name: fs.Final
26+
27+
Finds the final C++17 standard version of the filesystem library.
28+
29+
If no components are provided, behaves as if the
30+
:find-component:`fs.Final` component was specified.
31+
32+
If both :find-component:`fs.Experimental` and :find-component:`fs.Final` are
33+
provided, first looks for ``Final``, and falls back to ``Experimental`` in case
34+
of failure. If ``Final`` is found, :imp-target:`std::filesystem` and all
35+
:ref:`variables <fs.variables>` will refer to the ``Final`` version.
36+
37+
38+
Imported Targets
39+
****************
40+
41+
.. imp-target:: std::filesystem
42+
43+
The ``std::filesystem`` imported target is defined when any requested
44+
version of the C++ filesystem library has been found, whether it is
45+
*Experimental* or *Final*.
46+
47+
If no version of the filesystem library is available, this target will not
48+
be defined.
49+
50+
.. note::
51+
This target has ``cxx_std_17`` as an ``INTERFACE``
52+
:ref:`compile language standard feature <req-lang-standards>`. Linking
53+
to this target will automatically enable C++17 if no later standard
54+
version is already required on the linking target.
55+
56+
57+
.. _fs.variables:
58+
59+
Variables
60+
*********
61+
62+
.. variable:: CXX_FILESYSTEM_IS_EXPERIMENTAL
63+
64+
Set to ``TRUE`` when the :find-component:`fs.Experimental` version of C++
65+
filesystem library was found, otherwise ``FALSE``.
66+
67+
.. variable:: CXX_FILESYSTEM_HAVE_FS
68+
69+
Set to ``TRUE`` when a filesystem header was found.
70+
71+
.. variable:: CXX_FILESYSTEM_HEADER
72+
73+
Set to either ``filesystem`` or ``experimental/filesystem`` depending on
74+
whether :find-component:`fs.Final` or :find-component:`fs.Experimental` was
75+
found.
76+
77+
.. variable:: CXX_FILESYSTEM_NAMESPACE
78+
79+
Set to either ``std::filesystem`` or ``std::experimental::filesystem``
80+
depending on whether :find-component:`fs.Final` or
81+
:find-component:`fs.Experimental` was found.
82+
83+
84+
Examples
85+
********
86+
87+
Using `find_package(Filesystem)` with no component arguments:
88+
89+
.. code-block:: cmake
90+
91+
find_package(Filesystem REQUIRED)
92+
93+
add_executable(my-program main.cpp)
94+
target_link_libraries(my-program PRIVATE std::filesystem)
95+
96+
97+
#]=======================================================================]
98+
99+
100+
if(TARGET std::filesystem)
101+
# This module has already been processed. Don't do it again.
102+
return()
103+
endif()
104+
105+
cmake_minimum_required(VERSION 3.10)
106+
107+
include(CMakePushCheckState)
108+
include(CheckIncludeFileCXX)
109+
110+
# If we're not cross-compiling, try to run test executables.
111+
# Otherwise, assume that compile + link is a sufficient check.
112+
set(CMAKE_CROSSCOMPILING TRUE)
113+
if(CMAKE_CROSSCOMPILING)
114+
include(CheckCXXSourceCompiles)
115+
macro(_cmcm_check_cxx_source code var)
116+
check_cxx_source_compiles("${code}" ${var})
117+
endmacro()
118+
else()
119+
include(CheckCXXSourceRuns)
120+
macro(_cmcm_check_cxx_source code var)
121+
check_cxx_source_runs("${code}" ${var})
122+
endmacro()
123+
endif()
124+
125+
cmake_push_check_state()
126+
127+
set(CMAKE_REQUIRED_QUIET ${Filesystem_FIND_QUIETLY})
128+
129+
# All of our tests required C++17 or later
130+
set(CMAKE_CXX_STANDARD 17)
131+
132+
# Normalize and check the component list we were given
133+
set(want_components ${Filesystem_FIND_COMPONENTS})
134+
if(Filesystem_FIND_COMPONENTS STREQUAL "")
135+
set(want_components Final)
136+
endif()
137+
138+
# Warn on any unrecognized components
139+
set(extra_components ${want_components})
140+
list(REMOVE_ITEM extra_components Final Experimental)
141+
foreach(component IN LISTS extra_components)
142+
message(WARNING "Extraneous find_package component for Filesystem: ${component}")
143+
endforeach()
144+
145+
# Detect which of Experimental and Final we should look for
146+
set(find_experimental TRUE)
147+
set(find_final TRUE)
148+
if(NOT "Final" IN_LIST want_components)
149+
set(find_final FALSE)
150+
endif()
151+
if(NOT "Experimental" IN_LIST want_components)
152+
set(find_experimental FALSE)
153+
endif()
154+
155+
if(find_final)
156+
check_include_file_cxx("filesystem" _CXX_FILESYSTEM_HAVE_HEADER)
157+
mark_as_advanced(_CXX_FILESYSTEM_HAVE_HEADER)
158+
if(_CXX_FILESYSTEM_HAVE_HEADER)
159+
# We found the non-experimental header. Don't bother looking for the
160+
# experimental one.
161+
set(find_experimental FALSE)
162+
endif()
163+
else()
164+
set(_CXX_FILESYSTEM_HAVE_HEADER FALSE)
165+
endif()
166+
167+
if(find_experimental)
168+
check_include_file_cxx("experimental/filesystem" _CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER)
169+
mark_as_advanced(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER)
170+
else()
171+
set(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER FALSE)
172+
endif()
173+
174+
if(_CXX_FILESYSTEM_HAVE_HEADER)
175+
set(_have_fs TRUE)
176+
set(_fs_header filesystem)
177+
set(_fs_namespace std::filesystem)
178+
set(_is_experimental FALSE)
179+
elseif(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER)
180+
set(_have_fs TRUE)
181+
set(_fs_header experimental/filesystem)
182+
set(_fs_namespace std::experimental::filesystem)
183+
set(_is_experimental TRUE)
184+
else()
185+
set(_have_fs FALSE)
186+
endif()
187+
188+
set(CXX_FILESYSTEM_HAVE_FS ${_have_fs} CACHE BOOL "TRUE if we have the C++ filesystem headers")
189+
set(CXX_FILESYSTEM_HEADER ${_fs_header} CACHE STRING "The header that should be included to obtain the filesystem APIs")
190+
set(CXX_FILESYSTEM_NAMESPACE ${_fs_namespace} CACHE STRING "The C++ namespace that contains the filesystem APIs")
191+
set(CXX_FILESYSTEM_IS_EXPERIMENTAL ${_is_experimental} CACHE BOOL "TRUE if the C++ filesystem library is the experimental version")
192+
193+
set(_found FALSE)
194+
195+
if(CXX_FILESYSTEM_HAVE_FS)
196+
# We have some filesystem library available. Do link checks
197+
string(CONFIGURE [[
198+
#include <cstdlib>
199+
#include <@CXX_FILESYSTEM_HEADER@>
200+
201+
int main() {
202+
auto cwd = @CXX_FILESYSTEM_NAMESPACE@::current_path();
203+
printf("%s", cwd.c_str());
204+
return EXIT_SUCCESS;
205+
}
206+
]] code @ONLY)
207+
208+
# Check a simple filesystem program without any linker flags
209+
_cmcm_check_cxx_source("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED)
210+
211+
set(can_link ${CXX_FILESYSTEM_NO_LINK_NEEDED})
212+
213+
if(NOT CXX_FILESYSTEM_NO_LINK_NEEDED)
214+
set(prev_libraries ${CMAKE_REQUIRED_LIBRARIES})
215+
# Add the libstdc++ flag
216+
set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lstdc++fs)
217+
_cmcm_check_cxx_source("${code}" CXX_FILESYSTEM_STDCPPFS_NEEDED)
218+
set(can_link ${CXX_FILESYSTEM_STDCPPFS_NEEDED})
219+
if(NOT CXX_FILESYSTEM_STDCPPFS_NEEDED)
220+
# Try the libc++ flag
221+
set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lc++fs)
222+
_cmcm_check_cxx_source("${code}" CXX_FILESYSTEM_CPPFS_NEEDED)
223+
set(can_link ${CXX_FILESYSTEM_CPPFS_NEEDED})
224+
endif()
225+
endif()
226+
227+
if(can_link)
228+
add_library(std::filesystem INTERFACE IMPORTED)
229+
set_property(TARGET std::filesystem APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_17)
230+
set(_found TRUE)
231+
232+
if(CXX_FILESYSTEM_NO_LINK_NEEDED)
233+
# Nothing to add...
234+
elseif(CXX_FILESYSTEM_STDCPPFS_NEEDED)
235+
set_property(TARGET std::filesystem APPEND PROPERTY INTERFACE_LINK_LIBRARIES -lstdc++fs)
236+
elseif(CXX_FILESYSTEM_CPPFS_NEEDED)
237+
set_property(TARGET std::filesystem APPEND PROPERTY INTERFACE_LINK_LIBRARIES -lc++fs)
238+
endif()
239+
endif()
240+
endif()
241+
242+
cmake_pop_check_state()
243+
244+
set(Filesystem_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::filesystem" FORCE)
245+
246+
if(Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND)
247+
message(FATAL_ERROR "Cannot run simple program using std::filesystem")
248+
endif()

0 commit comments

Comments
 (0)