Browse Source

Fixed handling if Verilator is not found from error to status

Eyck Jentzsch 1 year ago
parent
commit
022fe4209d
1 changed files with 110 additions and 109 deletions
  1. 110
    109
      cmake/FindVerilator.cmake

+ 110
- 109
cmake/FindVerilator.cmake View File

@@ -174,118 +174,119 @@ function(_find_verilator)
174 174
         PATH_SUFFIXES bin
175 175
         DOC "Path to the Verilator executable"
176 176
     )
177
-   	if(VERILATOR_EXECUTABLE STREQUAL VERILATOR_EXECUTABLE-NOTFOUND)
178
-    	message( FATAL_ERROR "verilator not found." )
179
-	endif()
180
-    
181
-
182
-    find_program(VERILATOR_COVERAGE_EXECUTABLE verilator_coverage
183
-        HINTS $ENV{VERILATOR_ROOT} /usr/local/bin
184
-        PATH_SUFFIXES bin
185
-        DOC "Path to the Verilator coverage executable"
186
-    )
187 177
 
188
-    get_filename_component(VERILATOR_EXECUTABLE_DIR ${VERILATOR_EXECUTABLE}
189
-        DIRECTORY)
178
+   	if(VERILATOR_EXECUTABLE STREQUAL VERILATOR_EXECUTABLE-NOTFOUND)
179
+   		set(VERILATOR_FOUND FALSE PARENT_SCOPE)
180
+	else()    
181
+	    find_program(VERILATOR_COVERAGE_EXECUTABLE verilator_coverage
182
+	        HINTS $ENV{VERILATOR_ROOT} /usr/local/bin
183
+	        PATH_SUFFIXES bin
184
+	        DOC "Path to the Verilator coverage executable"
185
+	    )
186
+	
187
+	    get_filename_component(VERILATOR_EXECUTABLE_DIR ${VERILATOR_EXECUTABLE}
188
+	        DIRECTORY)
189
+	
190
+	    find_path(VERILATOR_INCLUDE_DIR verilated.h
191
+	        HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_EXECUTABLE_DIR}/.. /usr/local
192
+	        PATH_SUFFIXES include share/verilator/include
193
+	        DOC "Path to the Verilator headers"
194
+	    )
195
+	   	if(VERILATOR_INCLUDE_DIR STREQUAL VERILATOR_INCLUDE_DIR-NOTFOUND)
196
+	    	message( FATAL_ERROR "verilator include files not found." )
197
+		endif()
198
+	
199
+	    mark_as_advanced(VERILATOR_EXECUTABLE)
200
+	    mark_as_advanced(VERILATOR_COVERAGE_EXECUTABLE)
201
+	    mark_as_advanced(VERILATOR_INCLUDE_DIR)
202
+	
203
+	    find_package_handle_standard_args(Verilator REQUIRED_VARS
204
+	        VERILATOR_EXECUTABLE VERILATOR_COVERAGE_EXECUTABLE VERILATOR_INCLUDE_DIR)
205
+	
206
+	    if (WIN32)
207
+	        set(library_policy STATIC)
208
+	    else()
209
+	        set(library_policy SHARED)
210
+	    endif()
211
+	
212
+	    add_library(verilated ${library_policy}
213
+	        ${VERILATOR_INCLUDE_DIR}/verilated.cpp
214
+	        ${VERILATOR_INCLUDE_DIR}/verilated_cov.cpp
215
+	        ${VERILATOR_INCLUDE_DIR}/verilated_dpi.cpp
216
+	        ${VERILATOR_INCLUDE_DIR}/verilated_vcd_c.cpp
217
+	        ${VERILATOR_INCLUDE_DIR}/verilated_vcd_sc.cpp
218
+	        ${CMAKE_CURRENT_LIST_DIR}/../src/verilator_callbacks.cpp
219
+	    )
220
+	
221
+	    set_target_properties(verilated PROPERTIES
222
+	        ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
223
+	        LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
224
+	        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
225
+	    )
226
+	
227
+	    set_source_files_properties(
228
+	        ${VERILATOR_INCLUDE_DIR}/verilated.cpp
229
+	        PROPERTIES
230
+	            COMPILE_DEFINITIONS "VL_USER_STOP;VL_USER_FINISH"
231
+	    )
232
+	
233
+	    set_source_files_properties(
234
+	        ${VERILATOR_INCLUDE_DIR}/verilated_cov.cpp
235
+	        PROPERTIES
236
+	            COMPILE_DEFINITIONS "VM_COVERAGE=1"
237
+	    )
238
+	
239
+	    target_link_libraries(verilated PRIVATE systemc)
240
+	
241
+	    set_target_properties(verilated PROPERTIES
242
+	        ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
243
+	        LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
244
+	    )
245
+	
246
+	    target_include_directories(verilated SYSTEM PRIVATE
247
+	        ${VERILATOR_INCLUDE_DIR}
248
+	        ${VERILATOR_INCLUDE_DIR}/vltstd
249
+	        ${SYSTEMC_INCLUDE_DIRS}
250
+	    )
251
+	
252
+	    if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
253
+	        verilator_target_compile_options(verilated PRIVATE
254
+	            -Wno-attributes
255
+	            -Wno-cast-qual
256
+	            -Wno-float-equal
257
+	            -Wno-suggest-override
258
+	            -Wno-conversion
259
+	            -Wno-unused-parameter
260
+	            -Wno-effc++
261
+	            -Wno-format
262
+	            -Wno-format-nonliteral
263
+	            -Wno-missing-declarations
264
+	            -Wno-old-style-cast
265
+	            -Wno-shadow
266
+	            -Wno-sign-conversion
267
+	            -Wno-strict-overflow
268
+	            -Wno-suggest-attribute=noreturn
269
+	            -Wno-suggest-final-methods
270
+	            -Wno-suggest-final-types
271
+	            -Wno-switch-default
272
+	            -Wno-switch-enum
273
+	            -Wno-undef
274
+	            -Wno-inline
275
+	            -Wno-variadic-macros
276
+	            -Wno-suggest-attribute=format
277
+	            -Wno-zero-as-null-pointer-constant
278
+	        )
279
+	    elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
280
+	        verilator_target_compile_options(verilated PRIVATE -Wno-everything)
281
+	    endif()
282
+	
283
+	    set(VERILATOR_FOUND ${VERILATOR_FOUND} PARENT_SCOPE)
284
+	    set(VERILATOR_EXECUTABLE "${VERILATOR_EXECUTABLE}" PARENT_SCOPE)
285
+	    set(VERILATOR_INCLUDE_DIR "${VERILATOR_INCLUDE_DIR}" PARENT_SCOPE)
286
+	    set(VERILATOR_COVERAGE_EXECUTABLE "${VERILATOR_COVERAGE_EXECUTABLE}" PARENT_SCOPE)
190 287
 
191
-    find_path(VERILATOR_INCLUDE_DIR verilated.h
192
-        HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_EXECUTABLE_DIR}/.. /usr/local
193
-        PATH_SUFFIXES include share/verilator/include
194
-        DOC "Path to the Verilator headers"
195
-    )
196
-   	if(VERILATOR_INCLUDE_DIR STREQUAL VERILATOR_INCLUDE_DIR-NOTFOUND)
197
-    	message( FATAL_ERROR "verilator include files not found." )
198 288
 	endif()
199
-
200
-    mark_as_advanced(VERILATOR_EXECUTABLE)
201
-    mark_as_advanced(VERILATOR_COVERAGE_EXECUTABLE)
202
-    mark_as_advanced(VERILATOR_INCLUDE_DIR)
203
-
204
-    find_package_handle_standard_args(Verilator REQUIRED_VARS
205
-        VERILATOR_EXECUTABLE VERILATOR_COVERAGE_EXECUTABLE VERILATOR_INCLUDE_DIR)
206
-
207
-    if (WIN32)
208
-        set(library_policy STATIC)
209
-    else()
210
-        set(library_policy SHARED)
211
-    endif()
212
-
213
-    add_library(verilated ${library_policy}
214
-        ${VERILATOR_INCLUDE_DIR}/verilated.cpp
215
-        ${VERILATOR_INCLUDE_DIR}/verilated_cov.cpp
216
-        ${VERILATOR_INCLUDE_DIR}/verilated_dpi.cpp
217
-        ${VERILATOR_INCLUDE_DIR}/verilated_vcd_c.cpp
218
-        ${VERILATOR_INCLUDE_DIR}/verilated_vcd_sc.cpp
219
-        ${CMAKE_CURRENT_LIST_DIR}/../src/verilator_callbacks.cpp
220
-    )
221
-
222
-    set_target_properties(verilated PROPERTIES
223
-        ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
224
-        LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
225
-        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
226
-    )
227
-
228
-    set_source_files_properties(
229
-        ${VERILATOR_INCLUDE_DIR}/verilated.cpp
230
-        PROPERTIES
231
-            COMPILE_DEFINITIONS "VL_USER_STOP;VL_USER_FINISH"
232
-    )
233
-
234
-    set_source_files_properties(
235
-        ${VERILATOR_INCLUDE_DIR}/verilated_cov.cpp
236
-        PROPERTIES
237
-            COMPILE_DEFINITIONS "VM_COVERAGE=1"
238
-    )
239
-
240
-    target_link_libraries(verilated PRIVATE systemc)
241
-
242
-    set_target_properties(verilated PROPERTIES
243
-        ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
244
-        LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
245
-    )
246
-
247
-    target_include_directories(verilated SYSTEM PRIVATE
248
-        ${VERILATOR_INCLUDE_DIR}
249
-        ${VERILATOR_INCLUDE_DIR}/vltstd
250
-        ${SYSTEMC_INCLUDE_DIRS}
251
-    )
252
-
253
-    if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
254
-        verilator_target_compile_options(verilated PRIVATE
255
-            -Wno-attributes
256
-            -Wno-cast-qual
257
-            -Wno-float-equal
258
-            -Wno-suggest-override
259
-            -Wno-conversion
260
-            -Wno-unused-parameter
261
-            -Wno-effc++
262
-            -Wno-format
263
-            -Wno-format-nonliteral
264
-            -Wno-missing-declarations
265
-            -Wno-old-style-cast
266
-            -Wno-shadow
267
-            -Wno-sign-conversion
268
-            -Wno-strict-overflow
269
-            -Wno-suggest-attribute=noreturn
270
-            -Wno-suggest-final-methods
271
-            -Wno-suggest-final-types
272
-            -Wno-switch-default
273
-            -Wno-switch-enum
274
-            -Wno-undef
275
-            -Wno-inline
276
-            -Wno-variadic-macros
277
-            -Wno-suggest-attribute=format
278
-            -Wno-zero-as-null-pointer-constant
279
-        )
280
-    elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
281
-        verilator_target_compile_options(verilated PRIVATE -Wno-everything)
282
-    endif()
283
-
284
-    set(VERILATOR_FOUND ${VERILATOR_FOUND} PARENT_SCOPE)
285
-    set(VERILATOR_EXECUTABLE "${VERILATOR_EXECUTABLE}" PARENT_SCOPE)
286
-    set(VERILATOR_INCLUDE_DIR "${VERILATOR_INCLUDE_DIR}" PARENT_SCOPE)
287
-    set(VERILATOR_COVERAGE_EXECUTABLE "${VERILATOR_COVERAGE_EXECUTABLE}"
288
-        PARENT_SCOPE)
289
+        
289 290
 endfunction()
290 291
 
291 292
 _find_verilator()