2019-05-03 20:04:02 -05:00
cmake_minimum_required ( VERSION 2.8.12 )
2019-08-21 16:25:36 -05:00
find_program ( CCACHE_FOUND ccache )
if ( CCACHE_FOUND )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
endif ( CCACHE_FOUND )
2019-05-03 20:04:02 -05:00
if ( ${ CMAKE_VERSION } VERSION_GREATER "3.8" )
#For cmake >= 3.9 INTERPROCEDURAL_OPTIMIZATION behaviour we need to explicitly
#set the cmake policy version number
cmake_policy ( VERSION 3.9 )
# If we are using verison < 3.9 then setting INTERPROCEDURAL_OPTIMIZATION
# has no effect unless an Intel compiler is used
endif ( )
# Set the default build type if not specified
if ( NOT CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE Release CACHE STRING
" C h o o s e t h e t y p e o f b u i l d : N o n e , D e b u g , R e l e a s e , R e l W i t h D e b I n f o , M i n S i z e R e l "
F O R C E )
endif ( )
message ( STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
2020-01-03 20:56:15 -06:00
if ( ${ CMAKE_SOURCE_DIR } STREQUAL ${ CMAKE_BINARY_DIR } )
message ( "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}" )
message ( "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}" )
message ( FATAL_ERROR "In-source builds not allowed. Use the Makefile wrapper (e.g. make), or create a new build directory and call cmake manually from there (e.g. mkdir -p build && cd build && cmake .. && make). You may need to 'rm -rf CMakeCache.txt CMakeFiles' first." )
endif ( )
#We install to the source directory by default
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "default install path" FORCE )
endif ( )
#Allow the user to configure how much assertion checking should occur
set ( VTR_ASSERT_LEVEL "2" CACHE STRING "VTR assertion checking level. 0: no assertions, 1: fast assertions, 2: regular assertions, 3: additional assertions with noticable run-time overhead, 4: all assertions (including those with significant run-time cost)" )
set_property ( CACHE VTR_ASSERT_LEVEL PROPERTY STRINGS 0 1 2 3 4 )
2019-05-03 20:04:02 -05:00
#Create the project
project ( "OPENFPGA" C CXX )
# Options
# Option to enable/disable graphic in compilation
option ( ENABLE_VPR_GRAPHICS "Enables VPR graphics" ON )
2020-01-03 20:56:15 -06:00
option ( ENABLE_VPR_GRAPHICS "Enables build with librtlnumber" OFF )
2019-05-03 20:04:02 -05:00
# Version number
set ( OPENFPGA_VERSION_MAJOR 1 )
set ( OPENFPGA_VERSION_MINOR 0 )
set ( OPENFPGA_VERSION_PATCH 0 )
set ( OPENFPGA_VERSION_PRERELEASE "dev" )
# Include user-defined functions
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/modules )
include ( FilesToDirs )
2020-01-03 20:56:15 -06:00
# Set the assertion level
add_definitions ( "-DVTR_ASSERT_LEVEL=${VTR_ASSERT_LEVEL}" )
2019-05-03 20:04:02 -05:00
# compiler flag configuration checks
include ( CheckCXXCompilerFlag )
2019-05-23 18:37:39 -05:00
#
# We require c++14 support
#
set ( CMAKE_CXX_STANDARD 14 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( CMAKE_CXX_EXTENSIONS OFF ) #No compiler specific extensions
2019-05-03 20:04:02 -05:00
# Set WARN FLAGS
set ( WARN_FLAGS "" )
if ( MSVC )
# Visual studio warnings
# Note that we do not use /Wall since it generates warnings about standard library headers
set ( WARN_FLAGS_TO_CHECK # the flags to check if the compiler supports
" / W 4 " # Most warnings
)
else ( )
set ( WARN_FLAGS_TO_CHECK # the flags to check if the compiler supports
#GCC-like
" - W p o i n t e r - a r i t h "
" - W c a s t - q u a l "
" - D _ _ U S E _ F I X E D _ P R O T O T Y P E S _ _ "
" - a n s i "
" - W s h a d o w "
" - W c a s t - a l l i g n "
" - W n o - w r i t e - s t r i n g s "
" - D _ P O S I X _ S O U R C E "
" - W a l l " #Most warnings, typically good
" - W e x t r a " #Extra warning, usually good
" - W p e d a n t i c " #Ensure ISO compliance (i.e. no non-standard extensions)
" - W c a s t - q u a l " #Warn if cast removes qualifier (e.g. const char* -> char*)
" - W c a s t - a l i g n " #Warn if a cast causes memory alignment changes
" - W s h a d o w " #Warn if local variable shadows another variable
" - W f o r m a t = 2 " #Sanity checks for printf-like formatting
" - W n o - f o r m a t - n o n l i t e r a l " # But don't worry about non-literal formtting (i.e. run-time printf format strings)
" - W l o g i c a l - o p " #Checks for logical op when bit-wise expected
" - W m i s s i n g - d e c l a r a t i o n s " #Warn if a global function is defined with no declaration
" - W m i s s i n g - i n c l u d e - d i r s " #Warn if a user include directory is missing
" - W r e d u n d a n t - d e c l s " #Warn if there are overlapping declarations
" - W s w i t c h - d e f a u l t " #Warn if a switch has no default
" - W u n d e f " #Warn if #if() preprocessor refers to an undefined directive
" - W u n u s e d " #Warn about unused variables/parameters
" - W u n u s e d - v a r i a b l e " #Warn about variables that are not used
" - W u n u s e d - p a r a m e t e r " #Warn about function parameters which are unused
" - W d i s a b l e d - o p t i m i z a t i o n " #Warn when optimizations are skipped (usually due to large/complex code)
" - W n o e x c e p t " #Warn when functions should be noexcept (i.e. compiler know it doesn't throw)
" - W o v e r l o a d e d - v i r t u a l " #Warn when a function declaration overrides a virtual method
" - W c t o r - d t o r - p r i v a c y " #Warn about inaccessible constructors/destructors
" - W n o n - v i r t u a l - d t o r " #Warn about missing virtual destructors
" - W d u p l i c a t e d - c o n d " #Warn about identical conditions in if-else chains
" - W d u p l i c a t e d - b r a n c h e s " #Warn when different branches of an if-else chain are equivalent
" - W n u l l - d e r e f e r e n c e " #Warn about null pointer dereference execution paths
" - W u n i n i t i a l i z e d " #Warn about unitialized values
" - W i n i t - s e l f " #Warn about self-initialization
" - W c a t c h - v a l u e = 3 " #Warn when catch statements don't catch by reference
" - W e x t r a - s e m i " #Warn about redudnant semicolons
)
endif ( )
# check and see if the compiler supports the various warning flags
# and add valid flags
foreach ( flag ${ WARN_FLAGS_TO_CHECK } )
CHECK_CXX_COMPILER_FLAG ( ${ flag } CXX_COMPILER_SUPPORTS_ ${ flag } )
if ( CXX_COMPILER_SUPPORTS_ ${ flag } )
# flag supported, so enable it
set ( WARN_FLAGS "${WARN_FLAGS} ${flag}" )
endif ( )
endforeach ( )
#
# Sanitizer flags
#
set ( SANITIZE_FLAGS "" )
if ( OPENFPGA_ENABLE_SANITIZE )
#Enable sanitizers
# -fuse-ld=gold force the gold linker to be used (required for sanitizers, but not enabled by default on some systems)
set ( SANITIZE_FLAGS "-g -fsanitize=address -fsanitize=leak -fsanitize=undefined -fuse-ld=gold" )
message ( STATUS "SANTIIZE_FLAGS: ${SANITIZE_FLAGS}" )
link_libraries ( "-static-libasan" ) #Fixes 'ASan runtime does not come first in initial library list'
endif ( )
# Set final flags
#
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_FLAGS} ${SANITIZE_FLAGS}" )
message ( STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}" )
# Unit Testing
#
enable_testing ( )
#
# Sub-projects
#
2019-05-15 14:22:14 -05:00
#add_subdirectory(iverilog)
2020-01-03 17:14:42 -06:00
add_subdirectory ( libs )
2020-01-12 19:11:00 -06:00
add_subdirectory ( libopenfpga )
2019-05-03 20:04:02 -05:00
add_subdirectory ( yosys )
add_subdirectory ( abc )
add_subdirectory ( ace2 )
add_subdirectory ( vpr7_x2p )
2020-01-03 17:45:31 -06:00
add_subdirectory ( vpr )
2019-05-03 20:04:02 -05:00
# run make to extract compiler options, linker options and list of source files
#add_custom_target(
# yosys
# COMMAND make run
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/yosys
#)
# Add extra compilation flags to suppress warnings from some libraries/tools
# Note that target_compile_options() *appends* to the current compilation options of
# the specified target
#Since ABC is an externally developed tool, we suppress all compiler warnings
CHECK_CXX_COMPILER_FLAG ( "-w" CXX_COMPILER_SUPPORTS_-w )
if ( CXX_COMPILER_SUPPORTS_-w )
target_compile_options ( libabc PRIVATE "-w" )
target_compile_options ( abc PRIVATE "-w" )
endif ( )
#Some ABC headers generate warnings, treat them as system headers to suppress warnings
get_property ( ABC_INCLUDE_DIRS TARGET libabc PROPERTY INCLUDE_DIRECTORIES )
target_include_directories ( libabc SYSTEM INTERFACE ${ ABC_INCLUDE_DIRS } )
# We use Yosys and abc Makefile now, TODO: create CMakeLists.txt as well
set_target_properties ( libabc abc
P R O P E R T I E S
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a b c "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a b c "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a b c " )
# Set output locations to be in the main source tree under the relevant folder
set_target_properties ( libace ace
P R O P E R T I E S
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a c e 2 "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a c e 2 "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a c e 2 " )
2020-01-03 17:14:42 -06:00
set_target_properties ( libarchfpgavpr7 read_arch_vpr7
2019-05-03 20:04:02 -05:00
P R O P E R T I E S
2020-01-03 17:14:42 -06:00
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b a r c h f p g a v p r 7 "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b a r c h f p g a v p r 7 "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b a r c h f p g a v p r 7 " )
2019-05-03 20:04:02 -05:00
set_target_properties ( libpcre pcredemo
P R O P E R T I E S
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b p c r e "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b p c r e "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b p c r e " )
set_target_properties ( libprinthandler printhandlerdemo
P R O P E R T I E S
2019-05-04 00:03:04 -05:00
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b p r i n t h a n d l e r "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b p r i n t h a n d l e r "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / l i b p r i n t h a n d l e r " )
2019-05-03 20:04:02 -05:00
set_target_properties ( libvpr vpr
P R O P E R T I E S
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / v p r "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / v p r "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / v p r " )
2019-05-08 15:29:58 -05:00
set_target_properties ( libvpr vpr_shell
P R O P E R T I E S
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / v p r "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / v p r "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r 7 _ x 2 p / v p r " )
2020-01-03 21:06:40 -06:00
set_target_properties ( libvpr8 vpr8
P R O P E R T I E S
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / v p r " )