Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Improved building on Windows #4925

Merged
merged 6 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ if (${CLANG_VERSION_MAJOR} VERSION_GREATER ${CLANG_HIGHEST_VERSION})
unset(CLANG_EXECUTABLE)
find_program(CLANG_EXECUTABLE NAMES clang-10 clang-11 clang-9 clang-8 clang-7)
if (NOT CLANG_EXECUTABLE)
message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Condider passing -DCLANG_PATH=/path/to/clang to cmake to use a specific clang.")
message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Consider passing -DCLANG_EXECUTABLE=/path/to/clang to cmake to use a specific clang.")
else()
check_clang_version()
if (${CLANG_VERSION_MAJOR} VERSION_GREATER ${CLANG_HIGHEST_VERSION})
message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Condider passing -DCLANG_PATH=/path/to/clang to cmake to use a specific clang.")
message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Consider passing -DCLANG_EXECUTABLE=/path/to/clang to cmake to use a specific clang.")
endif()
endif()
endif()
Expand Down
3 changes: 2 additions & 1 deletion cmake/TaichiExportCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ set(TAICHI_EXPORT_CORE_NAME taichi_export_core)
add_library(${TAICHI_EXPORT_CORE_NAME} SHARED)
target_link_libraries(${TAICHI_EXPORT_CORE_NAME} PRIVATE taichi_isolated_core)
set_target_properties(${TAICHI_EXPORT_CORE_NAME} PROPERTIES
CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
37 changes: 18 additions & 19 deletions taichi/gui/win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void GUI::process_event() {
}

void GUI::create_window() {
auto CLASS_NAME = L"Taichi Win32 Window";
const char *CLASS_NAME = "Taichi Win32 Window";

DWORD dwVersion = 0;
DWORD dwMajorVersion = 0;
Expand All @@ -164,13 +164,13 @@ void GUI::create_window() {
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

WNDCLASS wc = {};
WNDCLASSA wc = {};

wc.lpfnWndProc = WindowProc;
wc.hInstance = GetModuleHandle(0);
wc.hInstance = GetModuleHandleA(0);
wc.lpszClassName = CLASS_NAME;

RegisterClass(&wc);
RegisterClassA(&wc);

RECT window_rect;
window_rect.left = 0;
Expand All @@ -180,19 +180,18 @@ void GUI::create_window() {

AdjustWindowRect(&window_rect, WS_OVERLAPPEDWINDOW, false);

hwnd = CreateWindowEx(0, // Optional window styles.
CLASS_NAME, // Window class
std::wstring(window_name.begin(), window_name.end())
.data(), // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT,
window_rect.right - window_rect.left,
window_rect.bottom - window_rect.top,
NULL, // Parent window
NULL, // Menu
GetModuleHandle(0), // Instance handle
NULL // Additional application data
hwnd = CreateWindowExA(0, // Optional window styles.
CLASS_NAME, // Window class
window_name.c_str(), // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT,
window_rect.right - window_rect.left,
window_rect.bottom - window_rect.top,
NULL, // Parent window
NULL, // Menu
GetModuleHandleA(0), // Instance handle
NULL // Additional application data
);
TI_ERROR_IF(hwnd == NULL, "Window creation failed");
gui_from_hwnd[hwnd] = this;
Expand All @@ -201,7 +200,7 @@ void GUI::create_window() {
// https://www.cnblogs.com/lidabo/archive/2012/07/17/2595452.html
LONG style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_CAPTION & ~WS_SIZEBOX;
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowLongA(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, NULL, 0, 0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN), SWP_NOZORDER);
}
Expand Down Expand Up @@ -235,7 +234,7 @@ void GUI::redraw() {
}

void GUI::set_title(std::string title) {
SetWindowText(hwnd, std::wstring(title.begin(), title.end()).data());
SetWindowTextA(hwnd, title.c_str());
}

GUI::~GUI() {
Expand Down