Skip to content

Commit b737ecd

Browse files
committed
Creating CMakeLists for yosys submodule
1 parent 838165a commit b737ecd

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,18 @@ if(${WITH_PARMYS}) # define cmake params to compile Yosys
420420
# else()
421421
# set(CUSTOM_BUILD_PARALLEL_LEVEL "${CMAKE_BUILD_PARALLEL_LEVEL}")
422422
# endif()
423-
add_subdirectory(yosys)
423+
execute_process(
424+
COMMAND git submodule update --init --recursive
425+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/yosys
426+
RESULT_VARIABLE _submod_ret
427+
OUTPUT_QUIET
428+
ERROR_QUIET
429+
)
430+
if(NOT _submod_ret EQUAL 0)
431+
message(FATAL_ERROR
432+
"Failed to `git submodule update --init --recursive` in ${CMAKE_CURRENT_SOURCE_DIR}/yosys")
433+
endif()
434+
add_subdirectory(cmake/yosys)
424435
endif()
425436

426437
add_subdirectory(libs) #libs/CMakeLists.txt handles adding warnings flags to non-external libraries

cmake/yosys/CMakeLists.txt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(yosys_wrapper NONE)
4+
5+
# Create a target out of the library compilation result
6+
#SET(BINARY_LIB_FILE1 ${CMAKE_CURRENT_BINARY_DIR}/yosys1)
7+
#SET(BINARY_LIB_FILE2 ${CMAKE_CURRENT_BINARY_DIR}/yosys2)
8+
#SET(YOSYS_EXEC ${CMAKE_CURRENT_SOURCE_DIR}/yosys)
9+
#SET(BINARY_EXEC_FILE ${CMAKE_CURRENT_BINARY_DIR}/yosys)
10+
#SET(YOSYS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
11+
SET(YOSYS_SRC_DIR ${CMAKE_SOURCE_DIR}/yosys CACHE PATH "")
12+
SET(YOSYS_BUILD_DIR ${CMAKE_BINARY_DIR}/yosys CACHE PATH "")
13+
14+
set(CURRENT_CPPFLAGS "$(CPPFLAGS)-w")
15+
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
16+
set(CURRENT_CPPFLAGS "-w")
17+
endif()
18+
19+
#Initialize yosys submodules
20+
#execute_process(
21+
# COMMAND git submodule update --init --recursive
22+
# WORKING_DIRECTORY ${YOSYS_SRC_DIR}
23+
# RESULT_VARIABLE _submod_ret
24+
# OUTPUT_QUIET
25+
# ERROR_QUIET
26+
#)
27+
#if(NOT _submod_ret EQUAL 0)
28+
# message(FATAL_ERROR
29+
# "Failed to `git submodule update --init --recursive` in ${YOSYS_SRC_DIR}")
30+
#endif()
31+
32+
# how to build the result of the library
33+
add_custom_command(OUTPUT yosys-bin
34+
#COMMAND ${MAKE_PROGRAM} ENABLE_ABC=0
35+
# -C ${CMAKE_CURRENT_BINARY_DIR}
36+
# -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile #(out-of-tree) build directory
37+
#PREFIX=${CMAKE_BINARY_DIR}
38+
COMMAND ${MAKE_PROGRAM} -C ${YOSYS_SRC_DIR}
39+
ENABLE_ABC=0
40+
PREFIX=${YOSYS_BUILD_DIR}
41+
COMMAND
42+
# -j${CUSTOM_BUILD_PARALLEL_LEVEL}
43+
> /dev/null
44+
45+
#COMMAND ${MAKE_PROGRAM} install ENABLE_ABC=0
46+
# -C ${CMAKE_CURRENT_BINARY_DIR}
47+
# -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile #(out-of-tree) build directory
48+
#PREFIX=${CMAKE_BINARY_DIR}
49+
COMMAND ${MAKE_PROGRAM} -C ${YOSYS_SRC_DIR}
50+
install ENABLE_ABC=0
51+
PREFIX=${YOSYS_BUILD_DIR}
52+
> /dev/null
53+
54+
WORKING_DIRECTORY ${YOSYS_SRC_DIR})
55+
56+
add_custom_target(yosys ALL DEPENDS yosys-bin)
57+
58+
# create a target out of the library compilation result
59+
#add_custom_target(yosys-qwerty ALL DEPENDS ${BINARY_LIB_FILE1})
60+
61+
# specify where the library is and where to find the headers
62+
#set_target_properties(yosys-qwerty
63+
# PROPERTIES PREFIX "" #Avoid extra 'lib' prefix
64+
# IMPORTED_LOCATION ${BINARY_LIB_FILE1}
65+
# INTERFACE_INCLUDE_DIRECTORIES ${YOSYS_INCLUDE_DIRS})
66+
67+
68+
#install(FILES ${BINARY_LIB_FILE1} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

0 commit comments

Comments
 (0)