2019-05-03 19:56:03 -05:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
|
|
|
|
|
|
|
if (${CMAKE_VERSION} VERSION_GREATER "3.8")
|
|
|
|
#For cmake >= 3.9 INTERPROCEDURAL_OPTIMIZATION behaviour we need to explicitly
|
|
|
|
#set the cmake policy version number
|
2019-09-27 14:58:48 -05:00
|
|
|
cmake_policy(VERSION 3.9)
|
2019-05-03 19:56:03 -05:00
|
|
|
|
|
|
|
# If we are using verison < 3.9 then setting INTERPROCEDURAL_OPTIMIZATION
|
|
|
|
# has no effect unless an Intel compiler is used
|
|
|
|
endif()
|
|
|
|
|
|
|
|
project("vpr7_x2p" C CXX)
|
|
|
|
|
|
|
|
# idenify if we need graphics
|
2019-06-12 23:48:00 -05:00
|
|
|
set(ENABLE_VPR_GRAPHIC_CXX_FLAG true)
|
2019-06-15 14:21:25 -05:00
|
|
|
message(STATUS "Checking VPR graphics option ${ENABLE_VPR_GRAPHICS}")
|
2019-05-15 16:01:54 -05:00
|
|
|
if (ENABLE_VPR_GRAPHICS)
|
2019-05-03 19:56:03 -05:00
|
|
|
# check for dependencies
|
|
|
|
message(STATUS "VPR graphics is turned on, searching for dependencies")
|
|
|
|
find_package(X11 COMPONENTS X11 Xft)
|
|
|
|
|
|
|
|
if (NOT X11_FOUND)
|
|
|
|
message(WARNING "Failed to find required X11 library (on debian/ubuntu try 'sudo apt-get install libx11-dev' to install)")
|
|
|
|
#Disable
|
2019-06-12 23:48:00 -05:00
|
|
|
set(ENABLE_VPR_GRAPHIC_CXX_FLAG false)
|
2019-05-03 19:56:03 -05:00
|
|
|
endif()
|
2019-06-15 14:21:25 -05:00
|
|
|
else ()
|
|
|
|
set(ENABLE_VPR_GRAPHIC_CXX_FLAG false)
|
2019-05-03 19:56:03 -05:00
|
|
|
endif()
|
2019-06-08 16:08:17 -05:00
|
|
|
|
2019-06-12 23:48:00 -05:00
|
|
|
if (NOT ENABLE_VPR_GRAPHIC_CXX_FLAG)
|
2019-09-27 14:58:48 -05:00
|
|
|
# Add a flag to notify compiler not to consider graphic-related source codes
|
2019-06-08 16:08:17 -05:00
|
|
|
set (DISABLE_GRAPHIC_FLAGS "-DNO_GRAPHICS")
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DISABLE_GRAPHIC_FLAGS}")
|
|
|
|
message(STATUS "Add flags to disable graphics in VPR compilation: ${DISABLE_GRAPHIC_FLAGS}")
|
|
|
|
endif()
|
2019-05-03 19:56:03 -05:00
|
|
|
|
2019-09-27 14:58:48 -05:00
|
|
|
# We need readline to compile
|
2019-05-03 19:56:03 -05:00
|
|
|
find_package(Readline REQUIRED)
|
|
|
|
|
|
|
|
#Collect the source files
|
|
|
|
file(GLOB_RECURSE EXEC_SOURCES SRC/main.c)
|
|
|
|
file(GLOB_RECURSE EXEC_SOURCES_SHELL SRC/shell_main.c)
|
2019-05-10 23:50:08 -05:00
|
|
|
file(GLOB_RECURSE LIB_SOURCES SRC/*/*.c SRC/*/*/*.c SRC/*/*.cpp SRC/*/*/*.cpp)
|
2019-05-03 19:56:03 -05:00
|
|
|
file(GLOB_RECURSE LIB_HEADERS SRC/*/*.h SRC/*/*/*.h)
|
|
|
|
files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS)
|
|
|
|
|
|
|
|
# Use c++ compiler for c source files
|
|
|
|
set_source_files_properties(${LIB_SOURCES} PROPERTIES LANGUAGE CXX)
|
|
|
|
set_source_files_properties(${EXEC_SOURCES} PROPERTIES LANGUAGE CXX)
|
|
|
|
set_source_files_properties(${EXEC_SOURCES_SHELL} PROPERTIES LANGUAGE CXX)
|
|
|
|
|
|
|
|
#Create the library
|
|
|
|
add_library(libvpr STATIC
|
|
|
|
${LIB_HEADERS}
|
|
|
|
${LIB_SOURCES})
|
|
|
|
|
|
|
|
# add header files to be included
|
|
|
|
target_include_directories(libvpr PUBLIC ${LIB_INCLUDE_DIRS})
|
|
|
|
set_target_properties(libvpr PROPERTIES PREFIX "") #Avoid extra 'lib' prefix#Create the executable
|
|
|
|
|
|
|
|
#Specify link-time dependancies
|
2019-06-12 23:48:00 -05:00
|
|
|
if (ENABLE_VPR_GRAPHIC_CXX_FLAG)
|
2019-06-08 16:08:17 -05:00
|
|
|
target_link_libraries(libvpr
|
|
|
|
libarchfpga
|
|
|
|
X11
|
2019-06-13 15:42:39 -05:00
|
|
|
libvtrutil
|
2019-11-02 19:20:25 -05:00
|
|
|
libini
|
2019-11-02 18:31:05 -05:00
|
|
|
readline)
|
2019-09-27 14:58:48 -05:00
|
|
|
else ()
|
2019-06-08 16:08:17 -05:00
|
|
|
target_link_libraries(libvpr
|
|
|
|
libarchfpga
|
2019-06-13 15:42:39 -05:00
|
|
|
libvtrutil
|
2019-11-02 19:20:25 -05:00
|
|
|
libini
|
2019-11-02 18:31:05 -05:00
|
|
|
readline)
|
2019-06-08 16:08:17 -05:00
|
|
|
endif()
|
2019-05-03 19:56:03 -05:00
|
|
|
|
|
|
|
#Create the executables
|
|
|
|
# regular vpr interface
|
|
|
|
add_executable(vpr ${EXEC_SOURCES})
|
|
|
|
target_link_libraries(vpr
|
|
|
|
libvpr)
|
|
|
|
|
|
|
|
# Shell-interface vpr
|
|
|
|
add_executable(vpr_shell ${EXEC_SOURCES_SHELL})
|
|
|
|
target_link_libraries(vpr_shell
|
|
|
|
libvpr)
|
|
|
|
|