Skip to content

Commit a8e2158

Browse files
committed
Add find_package test when pfs is not installed
1 parent 110eeba commit a8e2158

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

cmake/pfs-config.cmake.in

+11
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
@PACKAGE_INIT@
22
check_required_components(pfs)
3+
4+
set(pfs_FOUND TRUE)
5+
6+
set(pfs_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")
7+
8+
set(pfs_LIBRARIES pfs)
9+
set(pfs_LIBRARY_DIR "${CMAKE_CURRENT_LIST_DIR}/lib")
10+
11+
set(pfs_INCLUDE_DIRS "${pfs_INCLUDE_DIRS}" CACHE STRING "pfs include directories" FORCE)
12+
set(pfs_LIBRARIES "${pfs_LIBRARIES}" CACHE STRING "pfs libraries" FORCE)
13+
set(pfs_LIBRARY_DIR "${pfs_LIBRARY_DIR}" CACHE STRING "pfs library dirs" FORCE)
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required (VERSION 3.5)
2+
3+
project (find_package)
4+
5+
find_package (pfs PATHS /pfs NO_DEFUALT_PATH REQUIRED)
6+
7+
set (SOURCES find_package.cpp)
8+
9+
add_executable (find_package ${SOURCES})
10+
11+
target_link_libraries (find_package -L${pfs_LIBRARY_DIR} ${pfs_LIBRARIES})
12+
target_include_directories (find_package PRIVATE ${pfs_INCLUDE_DIRS})

test/cmake/run_test

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
main() {
6+
if [[ "$#" -ne 1 ]]; then
7+
echo "Usage: $0 <test_name>"
8+
return 2
9+
fi
10+
declare -r test_name="$1"
11+
12+
declare -r project_name="find_package"
13+
14+
declare -r pfs_dir="/pfs"
15+
declare -r cmake_tests_dir="$pfs_dir/test/cmake"
16+
17+
declare -r source_file="$cmake_tests_dir/$project_name.cpp"
18+
if [[ ! -f "$source_file" ]]; then
19+
echo "[!] Cannot find test source file [$source_file]"
20+
return 1
21+
fi
22+
23+
declare -r test_dir="$cmake_tests_dir/${project_name}_${test_name}"
24+
if [[ ! -d "$test_dir" ]]; then
25+
echo "[!] Cannot find test [$test_dir]"
26+
return 1
27+
fi
28+
29+
declare -r target_dir="/$project_name"
30+
echo "[=] Deleting target dir [$target_dir]"
31+
rm -rf "$target_dir"
32+
33+
echo "[=] Copying test and source file to target dir"
34+
cp -R "$test_dir" "$target_dir"
35+
cp "$source_file" "$target_dir/."
36+
37+
echo "[=] Building..."
38+
(cd "$target_dir"; cmake .; make; "./$project_name" "/dev/pts/0")
39+
}
40+
41+
main "$@"

0 commit comments

Comments
 (0)