From 9a65ed4ce283beea8128f5c49aa7e0ff4051ceed Mon Sep 17 00:00:00 2001 From: David Ledger <68693576+seppeon@users.noreply.github.com> Date: Wed, 8 Nov 2023 22:27:56 +1100 Subject: [PATCH] Fix Mingw Compilation (#4675) --- CMakeLists.txt | 2 +- docs/CONTRIBUTORS | 1 + src/CMakeLists.txt | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 642355907..f21ee2782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ if (NOT WIN32) message(WARNING "CMake support on Linux/OSX is experimental.") endif() -if (MSVC) +if (WIN32) if (DEFINED ENV{WIN_FLEX_BISON}) set(WIN_FLEX_BISON "$ENV{WIN_FLEX_BISON}") endif() diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 44dfd678c..5159b11f5 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -26,6 +26,7 @@ Conor McCullough Dan Petrisko Daniel Bates David Horton +David Ledger David Metz David Stanford David Turner diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdf215082..654419d86 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -466,7 +466,7 @@ set_target_properties(${verilator} PROPERTIES #UNITY_BUILD $,FALSE,${CMAKE_UNITY_BUILD}> MSVC_RUNTIME_LIBRARY MultiThreaded$,,DebugDLL> #JOB_POOL_LINK one_job # Linking takes lots of resources - INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE + INTERPROCEDURAL_OPTIMIZATION_RELEASE $ ) add_dependencies(${verilator} @@ -501,13 +501,19 @@ target_include_directories(${verilator} ) if (WIN32) - target_compile_options(${verilator} PRIVATE /bigobj) + if(MINGW) + target_compile_options(${verilator} PRIVATE -Wa,-mbig-obj) + target_link_options(${verilator} PRIVATE -Wl,--stack,10000000 -mconsole -lcomctl32 -DWIN_32_LEAN_AND_MEAN) + else() + target_compile_options(${verilator} PRIVATE /bigobj) + target_link_options(${verilator} PRIVATE /STACK:10000000) + endif() + target_compile_definitions(${verilator} PRIVATE YY_NO_UNISTD_H ) target_include_directories(${verilator} PRIVATE ../platform/win32) target_link_libraries(${verilator} PRIVATE bcrypt psapi) - target_link_options(${verilator} PRIVATE /STACK:10000000) endif() install(TARGETS ${verilator})