File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ if (MSVC_RELEASE_DEBUGGING)
7171 endif ()
7272endif ()
7373
74+ # This should be kept in sync with the corresponding IF() in fred2/CMakeLists.txt
7475IF (MSVC_USE_RUNTIME_DLL OR FSO_BUILD_QTFRED)
7576 set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<NOT :$<CONFIG :Release >>:Debug >DLL" )
7677 add_compile_definitions (_AFXDLL )
Original file line number Diff line number Diff line change @@ -164,11 +164,12 @@ set_source_files_properties(fred.rc PROPERTIES
164164 LANGUAGE RC
165165)
166166
167- IF (MSVC_USE_RUNTIME_DLL)
167+ # This should be kept in sync with the corresponding IF() in cmake/toolchain-msvc.cmake
168+ IF (MSVC_USE_RUNTIME_DLL OR FSO_BUILD_QTFRED)
168169 set (CMAKE_MFC_FLAG 2)
169- ELSE (MSVC_USE_RUNTIME_DLL )
170+ ELSE ()
170171 set (CMAKE_MFC_FLAG 1)
171- ENDIF (MSVC_USE_RUNTIME_DLL )
172+ ENDIF ()
172173
173174IF (MSVC60)
174175 link_directories (${STLPORT_INCLUDE_LIB_DIRS} )
@@ -197,8 +198,15 @@ FIND_PACKAGE(OpenGL REQUIRED)
197198target_link_libraries (FRED2 PUBLIC "${OPENGL_LIBRARY} " )
198199
199200TARGET_LINK_LIBRARIES (FRED2 PUBLIC code ) # This will also link all dependencies of code
200- TARGET_LINK_LIBRARIES (FRED2 PUBLIC "$<$<NOT :$<CONFIG :Release >>:nafxcwd .lib >" )
201- TARGET_LINK_LIBRARIES (FRED2 PUBLIC "$<$<CONFIG :Release >:nafxcw .lib >" )
201+
202+ # When CMAKE_MFC_FLAG=2 (DLL MFC) MSBuild already links the DLL MFC stub libs (mfcs*.lib);
203+ # explicitly adding the static MFC libs (nafxcw*) on top causes IsDerivedFrom to be resolved
204+ # from the static MFC copy while CRuntimeClass structs are initialized in the DLL form,
205+ # crashing CDocTemplate's ctor on startup.
206+ IF (NOT (MSVC_USE_RUNTIME_DLL OR FSO_BUILD_QTFRED))
207+ TARGET_LINK_LIBRARIES (FRED2 PUBLIC "$<$<NOT :$<CONFIG :Release >>:nafxcwd .lib >" )
208+ TARGET_LINK_LIBRARIES (FRED2 PUBLIC "$<$<CONFIG :Release >:nafxcw .lib >" )
209+ ENDIF ()
202210
203211target_link_libraries (FRED2 PUBLIC glad_wgl )
204212
You can’t perform that action at this time.
0 commit comments