1
1
cmake_minimum_required (VERSION 3.13 )
2
2
project (yosys LANGUAGES CXX C )
3
3
set (YOSYS_VER "0.50+1" )
4
+ set (CMAKE_POSITION_INDEPENDENT_CODE ON )
4
5
5
6
# features (the more the better)
6
7
@@ -53,12 +54,12 @@ if (ENABLE_ABC)
53
54
add_subdirectory (abc EXCLUDE_FROM_ALL )
54
55
55
56
add_custom_command (
56
- OUTPUT ${CMAKE_BINARY_DIR } /yosys-abc
57
+ OUTPUT ${yosys_BINARY_DIR } /yosys-abc
57
58
DEPENDS abc # Depend on the target, not the generator expression
58
- COMMAND ${CMAKE_COMMAND} -E copy $< TARGET_FILE:abc> ${CMAKE_BINARY_DIR } /yosys-abc
59
+ COMMAND ${CMAKE_COMMAND} -E copy $< TARGET_FILE:abc> ${yosys_BINARY_DIR } /yosys-abc
59
60
)
60
61
61
- add_custom_target (yosys-abc-copy ALL DEPENDS ${CMAKE_BINARY_DIR } /yosys-abc )
62
+ add_custom_target (yosys-abc-copy ALL DEPENDS ${yosys_BINARY_DIR } /yosys-abc )
62
63
endif ()
63
64
64
65
set (CMAKE_CXX_STANDARD ${CXXSTD} )
@@ -73,13 +74,18 @@ find_package(FLEX 2.6 REQUIRED)
73
74
find_package (BISON 3.0 REQUIRED )
74
75
find_package (Python3 3.5 REQUIRED COMPONENTS Interpreter )
75
76
76
- add_executable (yosys )
77
- #target_include_directories(yosys PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
78
- #target_include_directories(yosys PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
79
- #target_compile_definitions(yosys PRIVATE _YOSYS_)
77
+ add_library (yosys STATIC )
78
+ #target_include_directories(yosys PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
79
+ #target_include_directories(yosys PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
80
+ #target_compile_definitions(yosys PUBLIC _YOSYS_)
80
81
include_directories (${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
82
+ target_include_directories (yosys PUBLIC
83
+ ${CMAKE_CURRENT_BINARY_DIR}
84
+ ${CMAKE_CURRENT_SOURCE_DIR}
85
+ )
81
86
82
87
add_compile_definitions (_YOSYS_ )
88
+ target_compile_definitions (yosys PUBLIC _YOSYS_ )
83
89
84
90
if (ENABLE_READLINE AND ENABLE_EDITLINE )
85
91
message (FATAL_ERROR "Not possible to enable both ENABLE_READLINE and ENABLE_EDITLINE" )
@@ -88,26 +94,26 @@ endif()
88
94
if (ENABLE_READLINE )
89
95
find_package (Readline REQUIRED )
90
96
add_compile_definitions (YOSYS_ENABLE_READLINE )
91
- target_link_libraries (yosys PRIVATE ${READLINE_LIBRARY} )
97
+ target_link_libraries (yosys PUBLIC ${READLINE_LIBRARY} )
92
98
endif ()
93
99
94
100
if (ENABLE_EDITLINE )
95
101
find_package (Editline REQUIRED )
96
102
add_compile_definitions (YOSYS_ENABLE_EDITLINE )
97
- target_link_libraries (yosys PRIVATE ${EDITLINE_LIBRARY} )
103
+ target_link_libraries (yosys PUBLIC ${EDITLINE_LIBRARY} )
98
104
endif ()
99
105
100
106
if (ENABLE_TCL )
101
107
find_package (TCL 8.6 REQUIRED )
102
108
add_compile_definitions (YOSYS_ENABLE_TCL )
103
- target_include_directories (yosys PRIVATE ${TCL_INCLUDE_PATH} )
104
- target_link_libraries (yosys PRIVATE ${TCL_LIBRARY} )
109
+ target_include_directories (yosys PUBLIC ${TCL_INCLUDE_PATH} )
110
+ target_link_libraries (yosys PUBLIC ${TCL_LIBRARY} )
105
111
endif ()
106
112
107
113
if (ENABLE_ZLIB )
108
114
find_package (ZLIB REQUIRED )
109
115
add_compile_definitions (YOSYS_ENABLE_ZLIB )
110
- target_link_libraries (yosys PRIVATE ZLIB::ZLIB )
116
+ target_link_libraries (yosys PUBLIC ZLIB::ZLIB )
111
117
endif ()
112
118
113
119
if (ENABLE_COVER )
@@ -140,7 +146,7 @@ if (ENABLE_ABC)
140
146
add_compile_definitions (YOSYS_ENABLE_ABC )
141
147
if (LINK_ABC )
142
148
add_compile_definitions (YOSYS_LINK_ABC )
143
- target_link_libraries (yosys PRIVATE $< TARGET_FILE:libabc> )
149
+ target_link_libraries (yosys PUBLIC $< TARGET_FILE:libabc> )
144
150
add_dependencies (yosys libabc )
145
151
endif ()
146
152
endif ()
@@ -149,7 +155,7 @@ if (ENABLE_PLUGINS)
149
155
find_package (LibFFI REQUIRED )
150
156
add_compile_definitions (YOSYS_ENABLE_PLUGINS )
151
157
include_directories (${LIBFFI_INCLUDE_DIR} )
152
- target_link_libraries (yosys PRIVATE ${LIBFFI_LIBRARY} )
158
+ target_link_libraries (yosys PUBLIC ${LIBFFI_LIBRARY} )
153
159
endif ()
154
160
155
161
if (DISABLE_SPAWN )
@@ -284,6 +290,19 @@ endif()
284
290
285
291
set_property (SOURCE kernel/log.cc APPEND PROPERTY COMPILE_DEFINITIONS YOSYS_SRC= "${PROJECT_SOURCE_DIR} " )
286
292
293
+ if (ENABLE_LIBYOSYS )
294
+ add_library (yosys_shared SHARED )
295
+ target_link_libraries (yosys_shared PUBLIC yosys )
296
+ set_target_properties (yosys_shared PROPERTIES OUTPUT_NAME yosys )
297
+ install (TARGETS yosys_shared
298
+ LIBRARY DESTINATION . )
299
+ endif ()
300
+
301
+ add_executable (yosys_exe
302
+ kernel/driver.cc )
303
+ target_link_libraries (yosys_exe PUBLIC yosys )
304
+ set_target_properties (yosys_exe PROPERTIES OUTPUT_NAME yosys )
305
+
287
306
#### yosys-config setup ####
288
307
# compiler
289
308
get_filename_component (_CXX_BASENAME "${CMAKE_CXX_COMPILER} " NAME )
@@ -371,14 +390,14 @@ set(LIBS "${YOSYS_CFG_LIBS}")
371
390
set (BINDIR "${YOSYS_CFG_BINDIR} " )
372
391
set (DATDIR "${YOSYS_CFG_DATDIR} " )
373
392
374
- configure_file (misc/yosys-config.in ${CMAKE_BINARY_DIR } /yosys-config @ONLY )
375
- file (CHMOD ${CMAKE_BINARY_DIR } /yosys-config
393
+ configure_file (misc/yosys-config.in ${yosys_BINARY_DIR } /yosys-config @ONLY )
394
+ file (CHMOD ${yosys_BINARY_DIR } /yosys-config
376
395
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
377
396
GROUP_READ GROUP_EXECUTE
378
397
WORLD_READ WORLD_EXECUTE )
379
398
380
399
add_custom_target (yosys-config-copy ALL
381
- DEPENDS ${CMAKE_BINARY_DIR } /yosys-config )
400
+ DEPENDS ${yosys_BINARY_DIR } /yosys-config )
382
401
383
402
#### INSTALL ####
384
403
install (TARGETS yosys
@@ -390,7 +409,7 @@ if (ENABLE_ABC)
390
409
RENAME yosys-abc )
391
410
endif ()
392
411
393
- install (PROGRAMS ${CMAKE_BINARY_DIR } /yosys-config DESTINATION . )
412
+ install (PROGRAMS ${yosys_BINARY_DIR } /yosys-config DESTINATION . )
394
413
395
414
#### TESTING ####
396
415
include (cmake/TestFiles.cmake )
0 commit comments