Skip to content

Commit

Permalink
feat(windows): add pragma.com executable for launching pragma within …
Browse files Browse the repository at this point in the history
…console
  • Loading branch information
Silverlan committed Jun 11, 2024
1 parent 76d4346 commit 592fb71
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ add_dependencies(pragma_updater sharedutils-static)

add_dependencies(pragma_server server)
add_dependencies(pragma client server)
add_dependencies(pragma pragma_server)
add_dependencies(pragma pragma_updater)

set_property(TARGET pragma PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
Expand Down Expand Up @@ -1167,6 +1166,9 @@ endfunction(pragma_install)

pragma_install(pragma ".")
pragma_install(pragma_server ".")
if(WIN32)
pragma_install(pragma_console ".")
endif()
pragma_install(alsoundsystem "${BINARY_OUTPUT_DIR}")

pragma_install(client "${BINARY_OUTPUT_DIR}")
Expand Down Expand Up @@ -1194,8 +1196,12 @@ pragma_install(wgui "${BINARY_OUTPUT_DIR}")
pragma_install(util_unicode "${BINARY_OUTPUT_DIR}")

message("Custom install targets: ${PRAGMA_INSTALL_CUSTOM_TARGETS}")
set(PRAGMA_INSTALL_DEPENDENCIES pragma pragma_server iclient iserver udm_convert ${PRAGMA_INSTALL_CUSTOM_TARGETS})
if(WIN32)
list(APPEND PRAGMA_INSTALL_DEPENDENCIES pragma_console)
endif()
add_custom_target(pragma-install
DEPENDS pragma iclient iserver udm_convert ${PRAGMA_INSTALL_CUSTOM_TARGETS}
DEPENDS ${PRAGMA_DEPENDENCIES}
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=${PRAGMA_INSTALL_COMPONENT}
-DBUILD_TYPE=${CONFIG_BUILD_TYPE}
Expand Down
3 changes: 3 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ set_target_properties(client PROPERTIES FOLDER core)
set_target_properties(pragma PROPERTIES FOLDER core)
set_target_properties(pragma_server PROPERTIES FOLDER core)
set_target_properties(wms_shared PROPERTIES FOLDER core)
if(WIN32)
set_target_properties(pragma_console PROPERTIES FOLDER core)
endif()

set(CMAKE_CXX_STANDARD 20)
10 changes: 10 additions & 0 deletions core/pragma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@ else()
set_target_properties(pragma PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "-console -luaext")
endif()

if(WIN32)
def_project(pragma_console exe ${APP_ICON_RESOURCE_WINDOWS})

set_target_properties(pragma_console PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "-console -luaext")

# This is required so that the executable can be launched from within a Windows terminal
set_target_properties(pragma_console PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")

set_target_properties(pragma_console PROPERTIES OUTPUT_NAME "pragma" SUFFIX ".com")
target_sources(pragma_console PRIVATE ${APP_ICON_RESOURCE_WINDOWS})
endif()
1 change: 1 addition & 0 deletions core/pragma/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ try {
"materials/logo/pragma_window_icon.png",
"-title_bar_color",
"#262626",
"-console",
};
auto cargs = pragma::merge_arguments(argc, argv, extraArgs);
auto hModule = pragma::launch_pragma(cargs.size(), cargs.data());
Expand Down

0 comments on commit 592fb71

Please sign in to comment.