diff --git a/cmake/pfs-config.cmake.in b/cmake/pfs-config.cmake.in index 13b93c6..f211a5d 100644 --- a/cmake/pfs-config.cmake.in +++ b/cmake/pfs-config.cmake.in @@ -1,2 +1,13 @@ @PACKAGE_INIT@ check_required_components(pfs) + +set(pfs_FOUND TRUE) + +set(pfs_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include") + +set(pfs_LIBRARIES pfs) +set(pfs_LIBRARY_DIR "${CMAKE_CURRENT_LIST_DIR}/lib") + +set(pfs_INCLUDE_DIRS "${pfs_INCLUDE_DIRS}" CACHE STRING "pfs include directories" FORCE) +set(pfs_LIBRARIES "${pfs_LIBRARIES}" CACHE STRING "pfs libraries" FORCE) +set(pfs_LIBRARY_DIR "${pfs_LIBRARY_DIR}" CACHE STRING "pfs library dirs" FORCE) diff --git a/test/cmake/find_package/find_package.cpp b/test/cmake/find_package.cpp similarity index 100% rename from test/cmake/find_package/find_package.cpp rename to test/cmake/find_package.cpp diff --git a/test/cmake/find_package/CMakeLists.txt b/test/cmake/find_package_installed/CMakeLists.txt similarity index 100% rename from test/cmake/find_package/CMakeLists.txt rename to test/cmake/find_package_installed/CMakeLists.txt diff --git a/test/cmake/find_package_source/CMakeLists.txt b/test/cmake/find_package_source/CMakeLists.txt new file mode 100644 index 0000000..07c6d95 --- /dev/null +++ b/test/cmake/find_package_source/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required (VERSION 3.5) + +project (find_package) + +find_package (pfs PATHS /pfs NO_DEFUALT_PATH REQUIRED) + +set (SOURCES find_package.cpp) + +add_executable (find_package ${SOURCES}) + +target_link_libraries (find_package -L${pfs_LIBRARY_DIR} ${pfs_LIBRARIES}) +target_include_directories (find_package PRIVATE ${pfs_INCLUDE_DIRS}) diff --git a/test/cmake/run_test b/test/cmake/run_test new file mode 100755 index 0000000..ea018fb --- /dev/null +++ b/test/cmake/run_test @@ -0,0 +1,41 @@ +#!/bin/bash + +set -eu + +main() { + if [[ "$#" -ne 1 ]]; then + echo "Usage: $0 " + return 2 + fi + declare -r test_name="$1" + + declare -r project_name="find_package" + + declare -r pfs_dir="/pfs" + declare -r cmake_tests_dir="$pfs_dir/test/cmake" + + declare -r source_file="$cmake_tests_dir/$project_name.cpp" + if [[ ! -f "$source_file" ]]; then + echo "[!] Cannot find test source file [$source_file]" + return 1 + fi + + declare -r test_dir="$cmake_tests_dir/${project_name}_${test_name}" + if [[ ! -d "$test_dir" ]]; then + echo "[!] Cannot find test [$test_dir]" + return 1 + fi + + declare -r target_dir="/$project_name" + echo "[=] Deleting target dir [$target_dir]" + rm -rf "$target_dir" + + echo "[=] Copying test and source file to target dir" + cp -R "$test_dir" "$target_dir" + cp "$source_file" "$target_dir/." + + echo "[=] Building..." + (cd "$target_dir"; cmake .; make; "./$project_name" "/dev/pts/0") +} + +main "$@"