|
| 1 | +# Copyright (C) 2020-2021 Intel Corporation |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +cmake_minimum_required(VERSION 3.5.1) |
| 5 | + |
| 6 | +project(hexl-fpga LANGUAGES C CXX) |
| 7 | +set(hexl-fpga_VERSION 1.0) |
| 8 | + |
| 9 | +set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE) |
| 10 | +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type: Debug or Release") |
| 11 | +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") |
| 12 | +set(CMAKE_CXX_STANDARD 11) |
| 13 | +set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0 -Wall") |
| 14 | +set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 -Wall") |
| 15 | +set(CMAKE_CXX_FLAGS_RELEASE "-march=native -O3 -funroll-loops -Wall ") |
| 16 | +set(CMAKE_C_FLAGS_RELEASE "-march=native -O3 -funroll-loops -Wall ") |
| 17 | + |
| 18 | +set(OPENCL_ROOT_PATH $ENV{INTELFPGAOCLSDKROOT}) |
| 19 | +set(FPGA_SRC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 20 | + |
| 21 | +option(ENABLE_FPGA_DEBUG "Enable FPGA debugging info" OFF) |
| 22 | +message(STATUS "ENABLE_FPGA_DEBUG: ${ENABLE_FPGA_DEBUG}") |
| 23 | +option(ENABLE_TESTS "Enable Tests" OFF) |
| 24 | +message(STATUS "ENABLE_TESTS: ${ENABLE_TESTS}") |
| 25 | +option(ENABLE_BENCHMARK "Enable Benchmark" OFF) |
| 26 | +message(STATUS "ENABLE_BENCHMARK: ${ENABLE_BENCHMARK}") |
| 27 | +option(ENABLE_DOCS "Enable Documentation" OFF) |
| 28 | +message(STATUS "ENABLE_DOCS: ${ENABLE_DOCS}") |
| 29 | + |
| 30 | +if (LINUX) |
| 31 | + include(GNUInstallDirs) |
| 32 | +else() |
| 33 | + set(CMAKE_INSTALL_INCLUDEDIR "include") |
| 34 | + set(CMAKE_INSTALL_LIBDIR "lib") |
| 35 | +endif() |
| 36 | + |
| 37 | +add_subdirectory(host) |
| 38 | +add_subdirectory(device) |
| 39 | + |
| 40 | +if(ENABLE_DOCS) |
| 41 | + find_package(Doxygen) |
| 42 | + option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND}) |
| 43 | + if(BUILD_DOCUMENTATION) |
| 44 | + if(NOT DOXYGEN_FOUND) |
| 45 | + message(FATAL_ERROR "Doxygen was not found (Required)") |
| 46 | + else() |
| 47 | + add_subdirectory(doc) |
| 48 | + endif() |
| 49 | + endif() |
| 50 | +endif() |
| 51 | + |
| 52 | +if (ENABLE_TESTS) |
| 53 | + add_subdirectory(cmake/gtest) |
| 54 | + add_subdirectory(tests) |
| 55 | +endif (ENABLE_TESTS) |
| 56 | + |
| 57 | +if (ENABLE_BENCHMARK) |
| 58 | + add_subdirectory(cmake/gbenchmark) |
| 59 | + add_subdirectory(benchmark) |
| 60 | +endif (ENABLE_BENCHMARK) |
| 61 | + |
| 62 | +include(CMakePackageConfigHelpers) |
| 63 | +write_basic_package_version_file( |
| 64 | + "${CMAKE_CURRENT_BINARY_DIR}/hexl-fpga/hexl-fpgaConfigVersion.cmake" |
| 65 | + VERSION ${hexl-fpga_VERSION} |
| 66 | + COMPATIBILITY AnyNewerVersion |
| 67 | +) |
| 68 | + |
| 69 | +export(EXPORT hexl-fpgaTargets |
| 70 | + FILE "${CMAKE_CURRENT_BINARY_DIR}/hexl-fpga/hexl-fpgaTargets.cmake" |
| 71 | + NAMESPACE hexl-fpga:: |
| 72 | +) |
| 73 | +configure_file(cmake/hexl-fpga/hexl-fpgaConfig.cmake |
| 74 | + "${CMAKE_CURRENT_BINARY_DIR}/hexl-fpga/hexl-fpgaConfig.cmake" |
| 75 | +) |
| 76 | + |
| 77 | +set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/hexl-fpga) |
| 78 | +install ( |
| 79 | + EXPORT hexl-fpgaTargets |
| 80 | + FILE hexl-fpgaTargets.cmake |
| 81 | + NAMESPACE hexl-fpga:: |
| 82 | + DESTINATION ${ConfigPackageLocation} |
| 83 | +) |
| 84 | + |
| 85 | +install( |
| 86 | + FILES |
| 87 | + cmake/hexl-fpga/hexl-fpgaConfig.cmake |
| 88 | + "${CMAKE_CURRENT_BINARY_DIR}/hexl-fpga/hexl-fpgaConfigVersion.cmake" |
| 89 | + DESTINATION |
| 90 | + ${ConfigPackageLocation} |
| 91 | + COMPONENT |
| 92 | + Devel |
| 93 | +) |
| 94 | +if(ENABLE_DOCS) |
| 95 | +install(DIRECTORY ${DOXYGEN_DOC_DIR} |
| 96 | + DESTINATION ${CMAKE_INSTALL_PREFIX}/doc) |
| 97 | +endif() |
0 commit comments