Skip to content

Commit 1da075d

Browse files
Install library
1 parent 7e92a25 commit 1da075d

8 files changed

Lines changed: 45 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ project(memlayout LANGUAGES CXX)
44
#option(ENABLE_CPU "Build CPU tests" ON)
55
#option(ENABLE_CUDA "Build CUDA tests" ON)
66

7-
add_library(memlayout INTERFACE)
8-
target_include_directories(memlayout INTERFACE include)
7+
add_subdirectory(memlayout)
98

109
add_subdirectory(tests EXCLUDE_FROM_ALL)
1110

memlayout/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
add_library(Wrapper INTERFACE)
2+
3+
target_include_directories(
4+
Wrapper INTERFACE
5+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
6+
$<INSTALL_INTERFACE:include>
7+
)
8+
9+
add_library(memlayout::Wrapper ALIAS Wrapper)
10+
11+
install(
12+
TARGETS Wrapper
13+
EXPORT memlayoutTargets
14+
INCLUDES DESTINATION include
15+
)
16+
17+
install(
18+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/wrapper.h
19+
DESTINATION include/memlayout
20+
)
21+
22+
file(
23+
WRITE
24+
"${CMAKE_CURRENT_BINARY_DIR}/memlayoutConfig.cmake"
25+
"include(\"\${CMAKE_CURRENT_LIST_DIR}/memlayoutTargets.cmake\")\n"
26+
)
27+
28+
install(
29+
EXPORT memlayoutTargets
30+
FILE memlayoutTargets.cmake
31+
NAMESPACE memlayout::
32+
DESTINATION lib/cmake/memlayout
33+
)
34+
35+
install(
36+
FILES
37+
"${CMAKE_CURRENT_BINARY_DIR}/memlayoutConfig.cmake"
38+
DESTINATION lib/cmake/memlayout
39+
)
File renamed without changes.

tests/cpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
44

55
add_executable(test_cpu test_cpu.cpp)
66
target_include_directories(test_cpu PUBLIC ${CMAKE_SOURCE_DIR}/tests/include ${CMAKE_CURRENT_SOURCE_DIR})
7-
target_link_libraries(test_cpu PRIVATE memlayout GTest::gtest_main)
7+
target_link_libraries(test_cpu PRIVATE memlayout::Wrapper GTest::gtest_main)
88

99
gtest_discover_tests(test_cpu)

tests/cpu/test_cpu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "structs.h"
77
#include "vector.h"
8-
#include "memlayout.h"
8+
#include "memlayout/wrapper.h"
99

1010
template<template <class> class Container, memlayout::Layout L>
1111
void initialize(std::size_t N, memlayout::Wrapper<test::Point3D, Container, L> &w) {

tests/gpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr")
55

66
add_executable(test_cuda test_cuda.cu)
77
target_include_directories(test_cuda PUBLIC ${CMAKE_SOURCE_DIR}/tests/include ${CMAKE_CURRENT_SOURCE_DIR})
8-
target_link_libraries(test_cuda PRIVATE memlayout GTest::gtest_main)
8+
target_link_libraries(test_cuda PRIVATE memlayout::Wrapper GTest::gtest_main)
99
set_target_properties(test_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON CUDA_ARCHITECTURES native)
1010

1111
gtest_discover_tests(test_cuda)

tests/gpu/test_cuda.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "device_ptr.h"
66
#include "structs.h"
77
#include "vector.h"
8-
#include "memlayout.h"
8+
#include "memlayout/wrapper.h"
99

1010
template <memlayout::Layout L>
1111
__global__ void add(int N, memlayout::Wrapper<test::Point3D, std::span, L> w) {

tests/include/structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef STRUCTS_H
22
#define STRUCTS_H
33

4-
#include "memlayout.h"
4+
#include "memlayout/wrapper.h"
55

66
namespace test {
77

0 commit comments

Comments
 (0)