fix visual studio build (#1722)

* fix visual studio build
add natural share path after build on visual studio

* fix cmake syntax

---------

Co-authored-by: MiO <mio@synogate.com>
This commit is contained in:
Michael Offel 2026-05-15 10:27:07 +02:00 committed by GitHub
parent 2669f0d932
commit 2894e53934
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 31 additions and 44 deletions

View File

@ -39,7 +39,9 @@ add_library(${TARGET_NAME} STATIC
${_QRC_SRCS}
)
target_compile_options(${TARGET_NAME} PRIVATE -Wno-deprecated-declarations)
if (NOT MSVC)
target_compile_options(${TARGET_NAME} PRIVATE -Wno-deprecated-declarations)
endif()
if (MSVC)
target_compile_options(${TARGET_NAME} PRIVATE /wd4457 /wd4718)

View File

@ -5,6 +5,10 @@ endif()
cmake_minimum_required(VERSION 3.25)
project(nextpnr CXX)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
include(CheckCXXCompilerFlag)

View File

@ -191,36 +191,21 @@ void init_share_dirname() { npnr_share_dirname = "/share/"; }
void init_share_dirname()
{
std::string proc_self_path = proc_self_dirname();
#if defined(_WIN32) && !defined(nextpnr_WIN32_UNIX_DIR)
std::string proc_share_path = proc_self_path + "share\\";
if (check_file_exists(proc_share_path, true)) {
npnr_share_dirname = proc_share_path;
return;
}
proc_share_path = proc_self_path + "..\\share\\" + "nextpnr\\";
if (check_file_exists(proc_share_path, true)) {
npnr_share_dirname = proc_share_path;
return;
}
#else
std::string proc_share_path = proc_self_path + "share/";
if (check_file_exists(proc_share_path, true)) {
npnr_share_dirname = proc_share_path;
return;
}
proc_share_path = proc_self_path + "../share/" + "nextpnr/";
if (check_file_exists(proc_share_path, true)) {
npnr_share_dirname = proc_share_path;
return;
}
for (const std::string &proc_share_path : {
proc_self_path + "share/",
proc_self_path + "../share/nextpnr/",
proc_self_path + "../share/",
#ifdef nextpnr_DATDIR
proc_share_path = nextpnr_DATDIR "/";
if (check_file_exists(proc_share_path, true)) {
npnr_share_dirname = proc_share_path;
return;
nextpnr_DATDIR "/",
#endif
})
{
if (check_file_exists(proc_share_path, true)) {
npnr_share_dirname = proc_share_path;
return;
}
}
#endif
#endif
}
#endif

View File

@ -59,6 +59,7 @@ target_include_directories(nextpnr-${target}-gui PRIVATE
${CMAKE_SOURCE_DIR}/3rdparty/QtPropertyBrowser/src
${CMAKE_SOURCE_DIR}/3rdparty/imgui
${CMAKE_SOURCE_DIR}/3rdparty/qtimgui
Boost::headers
)
if (Qt6_FOUND)
@ -74,6 +75,7 @@ target_link_libraries(nextpnr-${target}-gui PRIVATE
nextpnr_version
QtPropertyBrowser
pybind11::headers
${Boost_LIBRARIES}
)
# Currently always the case when the GUI is built.

View File

@ -88,26 +88,19 @@ uint8_t GateMatePacker::ram_clk_signal(CellInfo *cell, IdString port)
int width_to_config(int width)
{
switch (width) {
case 0:
return 0;
case 1:
return 1;
case 2:
return 2;
case 3 ... 5:
if (width < 3)
return width;
if (width < 6)
return 3;
case 6 ... 10:
if (width < 11)
return 4;
case 11 ... 20:
if (width < 21)
return 5;
case 21 ... 40:
if (width < 41)
return 6;
case 41 ... 80:
if (width < 81)
return 7;
default:
log_error("Unsupported width '%d'.\n", width);
}
log_error("Unsupported width '%d'.\n", width);
}
static void rename_or_move(CellInfo *main, CellInfo *other, IdString port, IdString other_port)

View File

@ -19,6 +19,7 @@
#include <functional>
#include <queue>
#include <chrono>
#include "gatemate.h"
#include "log.h"