Skip to content

Commit 0fae7fc

Browse files
committed
update latest standards
1 parent defed84 commit 0fae7fc

File tree

7 files changed

+92
-101
lines changed

7 files changed

+92
-101
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,51 @@
1-
cmake_minimum_required(VERSION 3.15)
1+
cmake_minimum_required(VERSION 3.18)
22

3-
# Silence warnings about empty CUDA_ARCHITECTURES properties on example targets:
4-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
5-
cmake_policy(SET CMP0104 OLD)
6-
endif()
7-
8-
# Set a name and a version number for your project:
3+
# Project definition
94
project(devdat VERSION 0.0.1 LANGUAGES CXX CUDA)
105

11-
# Initialize some default paths
12-
include(GNUInstallDirs)
13-
14-
# Define the minimum C++ standard that is required
6+
# Set C++ standard
157
set(CMAKE_CXX_STANDARD 17)
168
set(CMAKE_CXX_STANDARD_REQUIRED ON)
17-
189
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1910

20-
# Add nlohmann json
21-
include(FetchContent)
11+
# Optionally set CUDA architectures (uncomment and set as needed)
12+
# set(CMAKE_CUDA_ARCHITECTURES 60 70 75 80 86)
13+
14+
# Install directories
15+
include(GNUInstallDirs)
2216

23-
FetchContent_Declare(json
17+
# Fetch nlohmann_json (modern FetchContent usage)
18+
include(FetchContent)
19+
FetchContent_Declare(
20+
json
2421
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
25-
GIT_PROGRESS TRUE
22+
GIT_TAG v3.0.0
2623
GIT_SHALLOW TRUE
27-
GIT_TAG v3.0.0)
24+
)
2825
FetchContent_MakeAvailable(json)
2926

30-
# Compilation options
31-
# Add an interface target for our header-only library
27+
# Header-only library target
3228
add_library(devdat INTERFACE)
3329
target_include_directories(devdat INTERFACE
34-
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
30+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
3531
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
36-
$<BUILD_INTERFACE:${json_SOURCE_DIR}/include/>
3732
)
3833

39-
# compile the tests
34+
# Alias for downstream usage
35+
add_library(devdat::devdat ALIAS devdat)
36+
37+
# Testing
4038
include(CTest)
4139
if(BUILD_TESTING)
42-
if(NOT TARGET Catch2)
43-
add_subdirectory(ext/Catch2)
44-
include(./ext/Catch2/contrib/Catch.cmake)
45-
endif()
4640
add_subdirectory(tests)
4741
endif()
4842

43+
# === Installation ===
4944

50-
# Add an alias target for use if this project is included as a subproject in another project
51-
add_library(devdat::devdat ALIAS devdat)
52-
53-
# Install targets and configuration
5445
install(
5546
TARGETS devdat
5647
EXPORT devdat-config
57-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
58-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
59-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
48+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
6049
)
6150

6251
install(
@@ -70,9 +59,11 @@ install(
7059
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
7160
)
7261

73-
install(FILES ${json_SOURCE_DIR}/include/nlohmann/json.hpp
74-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nlohmann/)
62+
install(
63+
FILES ${json_SOURCE_DIR}/include/nlohmann/json.hpp
64+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nlohmann/
65+
)
7566

76-
# This prints a summary of found dependencies
67+
# Feature summary
7768
include(FeatureSummary)
7869
feature_summary(WHAT ALL)

README.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,49 @@ Building DevDat requires the following software installed:
1313
* CMake `>= 3.15`
1414
* Cuda `>=10.1`
1515

16-
# Building DevDat
16+
# Building and Installing DevDat
1717

18-
The following sequence of commands builds DevDat.
19-
It assumes that your current working directory is the top-level directory
20-
of the freshly cloned repository:
18+
The recommended way to build and install DevDat is with an out-of-source build:
2119

22-
```
23-
mkdir build
24-
cd build
25-
cmake -DCMAKE_BUILD_TYPE=Release ..
26-
cmake --build .
20+
```sh
21+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/local
22+
cmake --build build --target install
2723
```
2824

29-
The build process can be customized with the following CMake variables,
30-
which can be set by adding `-D<var>={ON, OFF}` to the `cmake` call:
25+
This will install DevDat to `$HOME/local` by default.
26+
If you want to install to a different location, adjust the `CMAKE_INSTALL_PREFIX` accordingly.
3127

32-
* `BUILD_TESTING`: Enable building of the test suite (default: `ON`)
28+
> **Note:** If you install to a custom location, set `CMAKE_PREFIX_PATH` when using DevDat in other projects:
29+
>
30+
> ```sh
31+
> cmake -S . -B build -DCMAKE_PREFIX_PATH=$HOME/local
32+
> ```
3333
34-
# Testing DevDat
34+
# Building and Running the Example
3535
36-
When built according to the above explanation (with `-DBUILD_TESTING=ON`),
37-
the C++ test suite of `DevDat` can be run using
38-
`ctest` from the build directory:
36+
To build the example, first ensure DevDat is installed as above. Then:
3937
38+
```sh
39+
cmake -S examples -B examples/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$HOME/local
40+
cmake --build examples/build
4041
```
41-
cd build
42-
ctest
43-
```
44-
# Building the example
4542
46-
The example directory demonstrates how the library can be integrated into a cmake project:
43+
To run the example:
4744

48-
```
49-
cd examples
50-
mkdir build
51-
cd build
52-
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=~/DevDat/install ..
53-
cmake --build .
45+
```sh
46+
./examples/build/devdat_examples
5447
```
5548

56-
Note that we have assumed here that the library was built beforehand locally by running the following commands in the top-level directory of the repository:
49+
# Running Tests
5750

58-
```
59-
mkdir build
51+
If you enabled tests (`-DBUILD_TESTING=ON`):
52+
53+
```sh
54+
cmake -S . -B build -DBUILD_TESTING=ON
55+
cmake --build build
6056
cd build
61-
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./../install ..
62-
make install -j9
57+
ctest
6358
```
64-
65-
6659
# Documentation
6760

6861
ToDo

examples/CMakeLists.txt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
cmake_minimum_required(VERSION 3.15)
1+
cmake_minimum_required(VERSION 3.18)
22

3-
# Silence warnings about empty CUDA_ARCHITECTURES properties on example targets:
4-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
5-
cmake_policy(SET CMP0104 OLD)
6-
endif()
7-
8-
# Set a name and a version number for your project:
93
project(Example VERSION 0.0.1 LANGUAGES CXX CUDA)
104

11-
# Initialize some default paths
12-
include(GNUInstallDirs)
13-
14-
# Define the minimum C++ standard that is required
155
set(CMAKE_CXX_STANDARD 17)
166
set(CMAKE_CXX_STANDARD_REQUIRED ON)
17-
187
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
198

20-
# Include libraries
9+
# Optionally set CUDA architectures (uncomment and set as needed)
10+
# set(CMAKE_CUDA_ARCHITECTURES 60 70 75 80 86)
11+
12+
include(GNUInstallDirs)
13+
2114
find_package(devdat CONFIG REQUIRED)
2215

23-
add_executable(devdat_examples src/devdat_t.cu src/random.cu main.cpp)
16+
add_executable(devdat_examples
17+
src/devdat_t.cu
18+
src/random.cu
19+
main.cpp
20+
)
21+
2422
target_link_libraries(devdat_examples PRIVATE devdat::devdat)
2523

26-
target_include_directories(devdat_examples PUBLIC
27-
$<BUILD_INTERFACE:${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}>
28-
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
24+
target_include_directories(devdat_examples PRIVATE
25+
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
2926
)
3027

31-
# This prints a summary of found dependencies
3228
include(FeatureSummary)
3329
feature_summary(WHAT ALL)

ext/Catch2

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/devdat/util/thrust_functors.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class repeated_range
2121

2222
typedef typename thrust::iterator_difference<Iterator>::type difference_type;
2323

24-
struct repeat_functor : public thrust::unary_function<difference_type,difference_type>
24+
struct repeat_functor
2525
{
2626
difference_type repeats;
2727

@@ -72,7 +72,7 @@ class tiled_range
7272

7373
typedef typename thrust::iterator_difference<Iterator>::type difference_type;
7474

75-
struct tile_functor : public thrust::unary_function<difference_type,difference_type>
75+
struct tile_functor
7676
{
7777
difference_type tile_size;
7878

@@ -196,7 +196,7 @@ void print_range_in_string(Iterator first, Iterator last, std::string &s)
196196

197197
// convert a linear index to a row index
198198
template <typename T>
199-
struct linear_index_to_row_index : public thrust::unary_function<T,T>
199+
struct linear_index_to_row_index
200200
{
201201
T C; // number of columns
202202

tests/CMakeLists.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
include(FetchContent)
2+
3+
FetchContent_Declare(
4+
Catch2
5+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
6+
GIT_TAG v2.13.8
7+
)
8+
FetchContent_MakeAvailable(Catch2)
9+
110
add_executable(devdat_tests tests.cpp devdat_t.cu)
2-
target_link_libraries(devdat_tests PUBLIC devdat Catch2::Catch2)
311

4-
target_include_directories(devdat_tests PUBLIC
5-
$<BUILD_INTERFACE:${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}>
6-
$<BUILD_INTERFACE:${json_SOURCE_DIR}/include/>
12+
target_include_directories(devdat_tests
13+
PRIVATE
14+
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
15+
${json_SOURCE_DIR}/include
16+
)
17+
18+
target_link_libraries(devdat_tests
19+
PRIVATE
20+
devdat
21+
Catch2::Catch2
722
)
823

9-
# allow user to run tests with `make test` or `ctest`
10-
catch_discover_tests(devdat_tests)
24+
include(${catch2_SOURCE_DIR}/contrib/Catch.cmake)
25+
catch_discover_tests(devdat_tests)

0 commit comments

Comments
 (0)