Debian Codegraph @

hdl/fpga/ip/analogdevicesinc/no_OS/cmake/nios-toolchain.cmake

raw
1 ################################################################################
2 # Configure CMake and setup variables for the Nios II environment
3 #
4 # Inputs:
5 # QUARTUS_ROOTDIR Path to Quartus Prime installation.
6 #
7 #
8 ################################################################################
9 cmake_minimum_required(VERSION 3.5)
10
11 if(NOT "$ENV{QUARTUS_ROOTDIR}" STREQUAL "")
12 set(QUARTUS_ROOTDIR "$ENV{QUARTUS_ROOTDIR}")
13 endif()
14
15 # There seems to be some known strange behavior where CMake loses track of
16 # cached variables when (re)parsing toolchain files. This is a workaround
17 # identified in http://stackoverflow.com/questions/28613394/check-cmake-cache-variable-in-toolchain-file
18 if(QUARTUS_ROOTDIR)
19 # Use the environment to back up this definition, per that above workaround
20 set(ENV{_QUARTUS_ROOTDIR} "${QUARTUS_ROOTDIR}")
21 else()
22 if(NOT "$ENV{_QUARTUS_ROOTDIR}" STREQUAL "")
23 # Use the definition we backed up in the environment.
24 set(QUARTUS_ROOTDIR "$ENV{_QUARTUS_ROOTDIR}")
25 endif()
26 endif()
27
28 if("${QUARTUS_ROOTDIR}" STREQUAL "")
29 message(FATAL_ERROR "QUARTUS_ROOTDIR not defined")
30 else()
31 message(STATUS "QUARTUS_ROOTDIR = ${QUARTUS_ROOTDIR}")
32 endif()
33
34
35 ################################################################################
36 # CMake toolchain file configuration
37 ################################################################################
38
39 find_program(CMAKE_C_COMPILER nios2-elf-gcc ${QUARTUS_ROOTDIR}/nios2eds/)
40 find_program(CMAKE_CXX_COMPILER nios2-elf-g++ ${QUARTUS_ROOTDIR}/nios2eds/)
41 set(CMAKE_C_COMPILER_WORKS 1)
42 set(CMAKE_CXX_COMPILER_WORKS 1)
43
44 set(CMAKE_SYSTEM_NAME Generic)
45 set(CMAKE_SYSTEM_PROCESSOR nios2)
46
47 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
48 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
49 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
50 set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)