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

在 windows 上开启 '/MT' 选项 #213

Merged
merged 2 commits into from
Jul 10, 2024
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
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ if (USE_LIBPNG_AND_ZLIB)
file(RENAME ${EGE_ZLIB_SOURCE_DIR}/zconf.h.included ${EGE_ZLIB_SOURCE_DIR}/zconf.h)
endif ()

if (MSVC)
target_compile_options(png_static PUBLIC
/MP
"$<$<CONFIG:DEBUG>:/MTd>"
"$<$<CONFIG:RELEASE>:/MT>")
target_compile_options(zlibstatic PUBLIC
/MP
"$<$<CONFIG:DEBUG>:/MTd>"
"$<$<CONFIG:RELEASE>:/MT>")
endif()

target_include_directories(xege
PRIVATE ${EGE_ZLIB_BINARY_DIR}
PRIVATE ${EGE_ZLIB_SOURCE_DIR}
Expand All @@ -77,6 +88,7 @@ if (USE_LIBPNG_AND_ZLIB)
PRIVATE ${EGE_LIBPNG_BINARY_DIR}
PRIVATE ${EGE_LIBPNG_SOURCE_DIR}
)

target_sources(xege
PRIVATE $<TARGET_OBJECTS:png_static>
PRIVATE $<TARGET_OBJECTS:zlibstatic>
Expand Down Expand Up @@ -111,6 +123,10 @@ endif ()
# 打印编译器信息
if (MSVC)
message(STATUS "${TARGET_BITS}bit MSVC target: MSVC ${MSVC_VERSION}")
target_compile_options(xege PUBLIC
/MP
"$<$<CONFIG:DEBUG>:/MTd>"
"$<$<CONFIG:RELEASE>:/MT>")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "${TARGET_BITS}bit GNU target: GCC ${CMAKE_C_COMPILER_VERSION}")
else ()
Expand Down
3 changes: 3 additions & 0 deletions tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ while [[ $# > 0 ]]; do
;;
--build)
echo "build"
if [[ ! -f "$CMAKE_VS_DIR/CMakeCache.txt" ]]; then
loadCMakeProject
fi
cmakeBuildAll
shift # past argument
;;
Expand Down
Loading