-
Notifications
You must be signed in to change notification settings - Fork 978
CMake: Rebase From Main & Tests Working #5204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: micko/cmake
Are you sure you want to change the base?
Changes from all commits
b6e5bf1
79f7cfa
615a646
ad800f7
8051724
030b054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
project(yosys LANGUAGES CXX C) | ||
set(YOSYS_VER "0.50+1") | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# features (the more the better) | ||
|
||
|
@@ -53,16 +54,28 @@ if (ENABLE_ABC) | |
add_subdirectory(abc EXCLUDE_FROM_ALL) | ||
|
||
add_custom_command( | ||
OUTPUT ${CMAKE_BINARY_DIR}/yosys-abc | ||
OUTPUT ${yosys_BINARY_DIR}/yosys-abc | ||
DEPENDS abc # Depend on the target, not the generator expression | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:abc> ${CMAKE_BINARY_DIR}/yosys-abc | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:abc> ${yosys_BINARY_DIR}/yosys-abc | ||
) | ||
|
||
add_custom_target(yosys-abc-copy ALL DEPENDS ${CMAKE_BINARY_DIR}/yosys-abc) | ||
add_custom_target(yosys-abc-copy ALL DEPENDS ${yosys_BINARY_DIR}/yosys-abc) | ||
endif() | ||
|
||
get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 23) | ||
message(STATUS "C++23 support enabled") | ||
else() | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
message(STATUS "C++ standard set to ${CMAKE_CXX_STANDARD}") | ||
endif() | ||
|
||
# Ensure C++17 support is available | ||
if(NOT "cxx_std_17" IN_LIST cxx_features) | ||
message(FATAL_ERROR "C++17 support is required but not available") | ||
endif() | ||
|
||
set(CMAKE_CXX_STANDARD ${CXXSTD}) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
|
@@ -73,13 +86,15 @@ find_package(FLEX 2.6 REQUIRED) | |
find_package(BISON 3.0 REQUIRED) | ||
find_package(Python3 3.5 REQUIRED COMPONENTS Interpreter) | ||
|
||
add_executable(yosys) | ||
#target_include_directories(yosys PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) | ||
#target_include_directories(yosys PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) | ||
#target_compile_definitions(yosys PRIVATE _YOSYS_) | ||
add_library(yosys_obj OBJECT) | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) | ||
target_include_directories(yosys_obj PUBLIC | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
add_compile_definitions(_YOSYS_) | ||
target_compile_definitions(yosys_obj PUBLIC _YOSYS_) | ||
|
||
if (ENABLE_READLINE AND ENABLE_EDITLINE) | ||
message(FATAL_ERROR "Not possible to enable both ENABLE_READLINE and ENABLE_EDITLINE") | ||
|
@@ -88,26 +103,26 @@ endif() | |
if (ENABLE_READLINE) | ||
find_package(Readline REQUIRED) | ||
add_compile_definitions(YOSYS_ENABLE_READLINE) | ||
target_link_libraries(yosys PRIVATE ${READLINE_LIBRARY}) | ||
target_link_libraries(yosys_obj PUBLIC ${READLINE_LIBRARY}) | ||
endif() | ||
|
||
if (ENABLE_EDITLINE) | ||
find_package(Editline REQUIRED) | ||
add_compile_definitions(YOSYS_ENABLE_EDITLINE) | ||
target_link_libraries(yosys PRIVATE ${EDITLINE_LIBRARY}) | ||
target_link_libraries(yosys_obj PUBLIC ${EDITLINE_LIBRARY}) | ||
endif() | ||
|
||
if (ENABLE_TCL) | ||
find_package(TCL 8.6 REQUIRED) | ||
add_compile_definitions(YOSYS_ENABLE_TCL) | ||
target_include_directories(yosys PRIVATE ${TCL_INCLUDE_PATH}) | ||
target_link_libraries(yosys PRIVATE ${TCL_LIBRARY}) | ||
target_include_directories(yosys_obj PUBLIC ${TCL_INCLUDE_PATH}) | ||
target_link_libraries(yosys_obj PUBLIC ${TCL_LIBRARY}) | ||
endif() | ||
|
||
if (ENABLE_ZLIB) | ||
find_package(ZLIB REQUIRED) | ||
add_compile_definitions(YOSYS_ENABLE_ZLIB) | ||
target_link_libraries(yosys PRIVATE ZLIB::ZLIB) | ||
target_link_libraries(yosys_obj PUBLIC ZLIB::ZLIB) | ||
endif() | ||
|
||
if (ENABLE_COVER) | ||
|
@@ -140,16 +155,16 @@ if (ENABLE_ABC) | |
add_compile_definitions(YOSYS_ENABLE_ABC) | ||
if (LINK_ABC) | ||
add_compile_definitions(YOSYS_LINK_ABC) | ||
target_link_libraries(yosys PRIVATE $<TARGET_FILE:libabc>) | ||
add_dependencies(yosys libabc) | ||
target_link_libraries(yosys_obj PUBLIC $<TARGET_FILE:libabc>) | ||
add_dependencies(yosys_obj libabc) | ||
endif() | ||
endif() | ||
|
||
if (ENABLE_PLUGINS) | ||
find_package(LibFFI REQUIRED) | ||
add_compile_definitions(YOSYS_ENABLE_PLUGINS) | ||
include_directories(${LIBFFI_INCLUDE_DIR}) | ||
target_link_libraries(yosys PRIVATE ${LIBFFI_LIBRARY}) | ||
target_link_libraries(yosys_obj PUBLIC ${LIBFFI_LIBRARY}) | ||
endif() | ||
|
||
if (DISABLE_SPAWN) | ||
|
@@ -283,3 +298,81 @@ if (ENABLE_ZLIB) | |
endif() | ||
|
||
set_property(SOURCE kernel/log.cc APPEND PROPERTY COMPILE_DEFINITIONS YOSYS_SRC="${PROJECT_SOURCE_DIR}") | ||
|
||
if (ENABLE_LIBYOSYS) | ||
add_library(yosys_shared SHARED | ||
$<TARGET_OBJECTS:yosys_obj> | ||
) | ||
target_link_libraries(yosys_shared PUBLIC yosys_obj) | ||
# set_target_properties(yosys_shared PROPERTIES OUTPUT_NAME yosys) | ||
install(TARGETS yosys_shared | ||
LIBRARY DESTINATION lib) | ||
endif() | ||
|
||
add_executable(yosys_exe | ||
kernel/driver.cc | ||
$<TARGET_OBJECTS:yosys_obj> | ||
) | ||
target_link_libraries(yosys_exe PUBLIC yosys_obj) | ||
set_target_properties(yosys_exe PROPERTIES OUTPUT_NAME yosys) | ||
install(TARGETS yosys_exe | ||
RUNTIME DESTINATION bin) | ||
|
||
#### yosys-config setup #### | ||
include(cmake/YosysConfig.cmake) | ||
|
||
#### INSTALL #### | ||
if (ENABLE_ABC) | ||
install(PROGRAMS $<TARGET_FILE:abc> | ||
DESTINATION bin | ||
RENAME yosys-abc) | ||
endif() | ||
|
||
install(PROGRAMS ${yosys_BINARY_DIR}/yosys-config DESTINATION bin) | ||
|
||
#### TESTING #### | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somehow, the tests run 2.6x longer on my 24 threads than with make, and I saw a test fail indeterministically. I'll see what I can find out on my end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, there was a top level GNU Make running the tests so these make invocations connected to its job server and shared a pool of job threads. Now each make gets only one thread, maybe we could work around that for make, but Ninja doesn't provide a job server (ninja-build/ninja#1139). I think we should rewrite There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the issue you linked indicates that the next Ninja release should include a jobserver client, and I believe there's a jobserver server being discussed. So perhaps continuing to use Ninja will work? |
||
include(cmake/TestFiles.cmake) | ||
enable_testing() | ||
|
||
set(_YOSYS_TEST_ENV | ||
"PATH=${PROJECT_SOURCE_DIR}:$ENV{PATH};") | ||
|
||
foreach(dir IN LISTS SH_TEST_DIRS) | ||
string(REPLACE "/" "_" name "${dir}") | ||
add_test( | ||
NAME seed-tests.${name} | ||
COMMAND bash -c | ||
"cd \"${PROJECT_SOURCE_DIR}/${dir}\" && bash run-test.sh ${SEEDOPT}" | ||
) | ||
set_tests_properties(seed-tests.${name} PROPERTIES | ||
ENVIRONMENT "${_YOSYS_TEST_ENV}" | ||
DEPENDS yosys_exe) | ||
endforeach() | ||
|
||
foreach(dir IN LISTS SH_ABC_TEST_DIRS) | ||
string(REPLACE "/" "_" name "${dir}") | ||
add_test( | ||
NAME abcopt-tests.${name} | ||
COMMAND bash -c | ||
"cd \"${PROJECT_SOURCE_DIR}/${dir}\" && bash run-test.sh ${ABCOPT} ${SEEDOPT}" | ||
) | ||
set_tests_properties(abcopt-tests.${name} PROPERTIES | ||
ENVIRONMENT "${_YOSYS_TEST_ENV}" | ||
DEPENDS yosys_exe) | ||
endforeach() | ||
|
||
foreach(dir IN LISTS MK_TEST_DIRS) | ||
string(REPLACE "/" "_" name "${dir}") | ||
add_test( | ||
NAME makefile-tests.${name} | ||
COMMAND bash -c | ||
" | ||
cd \"${PROJECT_SOURCE_DIR}/${dir}\" && | ||
bash run-test.sh && | ||
${CMAKE_MAKE_PROGRAM} -f run-test.mk | ||
" | ||
) | ||
set_tests_properties(makefile-tests.${name} PROPERTIES | ||
ENVIRONMENT "${_YOSYS_TEST_ENV}" | ||
DEPENDS yosys_exe) | ||
endforeach() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
add_library(yosys_backends_aiger INTERFACE) | ||
|
||
target_sources(yosys_backends_aiger INTERFACE | ||
|
||
add_library(yosys_backends_aiger OBJECT | ||
aiger.cc | ||
xaiger.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_aiger) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_aiger) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_aiger>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_aiger2 INTERFACE) | ||
|
||
target_sources(yosys_backends_aiger2 INTERFACE | ||
|
||
add_library(yosys_backends_aiger2 OBJECT | ||
aiger.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_aiger2) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_aiger2) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_aiger2>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_blif INTERFACE) | ||
|
||
target_sources(yosys_backends_blif INTERFACE | ||
|
||
add_library(yosys_backends_blif OBJECT | ||
blif.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_blif) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_blif) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_blif>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_btor INTERFACE) | ||
|
||
target_sources(yosys_backends_btor INTERFACE | ||
|
||
add_library(yosys_backends_btor OBJECT | ||
btor.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_btor) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_btor) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_btor>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_edif INTERFACE) | ||
|
||
target_sources(yosys_backends_edif INTERFACE | ||
|
||
add_library(yosys_backends_edif OBJECT | ||
edif.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_edif) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_edif) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_edif>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_firrtl INTERFACE) | ||
|
||
target_sources(yosys_backends_firrtl INTERFACE | ||
|
||
add_library(yosys_backends_firrtl OBJECT | ||
firrtl.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_firrtl) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_firrtl) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_firrtl>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
add_library(yosys_backends_functional INTERFACE) | ||
|
||
target_sources(yosys_backends_functional INTERFACE | ||
|
||
add_library(yosys_backends_functional OBJECT | ||
cxx.cc | ||
smtlib.cc | ||
smtlib_rosette.cc | ||
test_generic.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_functional) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_functional) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_functional>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_intersynth INTERFACE) | ||
|
||
target_sources(yosys_backends_intersynth INTERFACE | ||
|
||
add_library(yosys_backends_intersynth OBJECT | ||
intersynth.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_intersynth) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_intersynth) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_intersynth>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_jny INTERFACE) | ||
|
||
target_sources(yosys_backends_jny INTERFACE | ||
|
||
add_library(yosys_backends_jny OBJECT | ||
jny.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_jny) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_jny) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_jny>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_json INTERFACE) | ||
|
||
target_sources(yosys_backends_json INTERFACE | ||
|
||
add_library(yosys_backends_json OBJECT | ||
json.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_json) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_json) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_json>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
add_library(yosys_backends_rtlil INTERFACE) | ||
|
||
target_sources(yosys_backends_rtlil INTERFACE | ||
|
||
add_library(yosys_backends_rtlil OBJECT | ||
rtlil_backend.cc | ||
rtlil_backend.h | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_rtlil) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_rtlil) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_rtlil>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_simplec INTERFACE) | ||
|
||
target_sources(yosys_backends_simplec INTERFACE | ||
|
||
add_library(yosys_backends_simplec OBJECT | ||
simplec.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_simplec) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_simplec) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_simplec>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
add_library(yosys_backends_smt2 INTERFACE) | ||
|
||
target_sources(yosys_backends_smt2 INTERFACE | ||
|
||
add_library(yosys_backends_smt2 OBJECT | ||
smt2.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_smt2) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_smt2) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_smt2>) | ||
|
||
add_share_file("share/python3" "smtio.py") | ||
add_share_file("share/python3" "ywio.py") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_smv INTERFACE) | ||
|
||
target_sources(yosys_backends_smv INTERFACE | ||
|
||
add_library(yosys_backends_smv OBJECT | ||
smv.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_smv) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_smv) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_smv>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
add_library(yosys_backends_spice INTERFACE) | ||
|
||
target_sources(yosys_backends_spice INTERFACE | ||
|
||
add_library(yosys_backends_spice OBJECT | ||
spice.cc | ||
) | ||
|
||
target_link_libraries(yosys PRIVATE yosys_backends_spice) | ||
target_link_libraries(yosys_obj PUBLIC yosys_backends_spice) | ||
target_sources(yosys_obj PUBLIC $<TARGET_OBJECTS:yosys_backends_spice>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this section to be split off into a separate file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also Done: ad800f7