Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Add crtmode=static option to CMakeLists.txt
Browse files Browse the repository at this point in the history
Gets rid of dependencies on MSVC runtime redistributable files,
by building with /MT instead of /MD. This also requires curl and zlib
to be built with /MT as well, which are included for x64 only.
curl: 7.64.1
zlib: 1.2.11
  • Loading branch information
morlad committed May 27, 2019
1 parent 280523d commit 5d5a310
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,38 @@ ENDIF()

IF (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(modio ws2_32.lib wldap32.lib advapi32.lib kernel32.lib comdlg32.lib crypt32.lib normaliz.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/libcurl_a.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/zlib.lib )
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(modio ws2_32.lib wldap32.lib advapi32.lib kernel32.lib comdlg32.lib crypt32.lib normaliz.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/libcurl_a.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/zlib.lib )
endif()
target_link_libraries(modio ws2_32.lib wldap32.lib advapi32.lib kernel32.lib comdlg32.lib crypt32.lib normaliz.lib )

IF (crtmode AND crtmode STREQUAL "static")
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)

foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/static/libcurl_a.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/static/zlib.lib )
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/static/libcurl_a.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/static/zlib.lib )
endif()

ELSE()

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/libcurl_a.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x64/zlib.lib )
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/libcurl_a.lib ${CMAKE_SOURCE_DIR}/lib/MSVC/x86/zlib.lib )
endif()

ENDIF()

ENDIF()

IF( test AND test STREQUAL "on" )
Expand Down
Binary file added lib/MSVC/x64/static/libcurl_a.lib
Binary file not shown.
Binary file added lib/MSVC/x64/static/zlib.lib
Binary file not shown.

0 comments on commit 5d5a310

Please sign in to comment.