CORDIC_Rotate_APFX/CMakeLists.txt

92 lines
2.7 KiB
CMake
Raw Normal View History

2022-02-04 19:27:11 +01:00
cmake_minimum_required (VERSION 3.16.0 FATAL_ERROR)
# setting this is required
set (CMAKE_CXX_STANDARD 14)
2022-02-11 20:17:10 +01:00
set (CMAKE_CXX_EXTENSIONS OFF)
2022-02-04 19:27:11 +01:00
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
set (CMAKE_EXPORT_COMPILE_COMMANDS true)
project (
CordicRotate
LANGUAGES CXX
VERSION 0.1
)
####################################################################################################
# Options
####################################################################################################
option (EXPORT_COMMANDS "export compile commands, for use with clangd for example." ON)
option (ENABLE_XILINX "use Xilinx provided and proprietary headers." OFF)
option (ENABLE_TESTING "use Catch2 in conjunction with CTest as a test suite." ON)
2022-02-15 19:25:45 +01:00
option (PEDANTIC "use -Wall and -pedantic." ON)
####################################################################################################
2022-02-15 19:25:45 +01:00
if (PEDANTIC)
add_compile_options(-Wall -pedantic)
endif ()
2022-02-04 19:27:11 +01:00
if (EXPORT_COMMANDS)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
2022-02-04 19:27:11 +01:00
endif ()
if (ENABLE_XILINX)
set (
XILINX_HOME
/opt/Xilinx
CACHE PATH "path to Xilinx root folder."
)
set (
XILINX_VER
"2020.2"
CACHE STRING "Xilinx software version to use."
2022-02-04 19:27:11 +01:00
)
if (XILINX_VER VERSION_GREATER_EQUAL "2020.1")
set (AP_INCLUDE_DIR ${XILINX_HOME}/Vitis_HLS/${XILINX_VER}/include)
else ()
set (AP_INCLUDE_DIR ${XILINX_HOME}/Vivado/${XILINX_VER}/include)
endif ()
message (STATUS "AP headers must lie under ${AP_INCLUDE_DIR}")
else ()
find_file (AP_FIXED ap_fixed.h PATH_SUFFIXES ap_types hls_ap_types/include REQUIRED)
get_filename_component (AP_INCLUDE_DIR ${AP_FIXED} DIRECTORY)
2022-02-04 19:27:11 +01:00
endif ()
if ((NOT EXISTS ${AP_INCLUDE_DIR}/ap_int.h) OR (NOT EXISTS ${AP_INCLUDE_DIR}/ap_fixed.h))
message (FATAL_ERROR "Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n"
"Please provide a suitable path to the headers."
2022-02-04 19:27:11 +01:00
)
endif ()
add_subdirectory (RomGenerators)
2022-02-11 18:17:13 +01:00
add_library (
cordic STATIC sources/CCordicRotate/CCordicRotate.cpp
sources/CCordicRotateHalfPiRom/CCordicRotateHalfPiRom.cpp
)
2022-02-07 18:58:38 +01:00
target_include_directories (cordic PUBLIC sources)
2022-02-04 19:27:11 +01:00
target_include_directories (cordic SYSTEM PUBLIC ${AP_INCLUDE_DIR})
target_link_libraries (cordic PUBLIC romgen)
2022-02-04 19:27:11 +01:00
if (ENABLE_TESTING)
find_package (Catch2 REQUIRED)
2022-02-07 18:58:38 +01:00
add_library (catch_common OBJECT sources/tb/main_catch2.cpp)
target_link_libraries (catch_common PUBLIC Catch2::Catch2)
2022-02-07 18:58:38 +01:00
add_executable (cordic_tb sources/tb/cordic_tb.cpp)
target_link_libraries (cordic_tb PUBLIC cordic catch_common)
2022-02-11 18:17:13 +01:00
include (CTest)
include (Catch)
catch_discover_tests (cordic_tb)
endif ()