Skip to content

Commit

Permalink
[Build] Improved building on Windows (taichi-dev#4925)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PENGUINLIONG and pre-commit-ci[bot] authored May 10, 2022
1 parent fbed595 commit 6d538e1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
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

0 comments on commit 6d538e1

Please sign in to comment.