How to use target_link_libraries() with RelWithDebInfo?

Manda Rajo 141 Reputation points
2023-04-21T12:27:02.9166667+00:00

The following code causes an error, and is it possible to simplify my code such as only 'debug' and 'optimized' are used even if I compile my project with "RelWithDebInfo"?

The error I want to fix, please fix it:
LINK : fatal error LNK1104: cannot open file 'relwithdebinfo.lib'

target_link_libraries(test_draft_opengl
    debug ${THIRDPARTY_DIR}/bullet-3.25/lib/Debug/BulletSoftBody_Debug.lib
    debug ${THIRDPARTY_DIR}/bullet-3.25/lib/Debug/BulletCollision_Debug.lib
    debug ${THIRDPARTY_DIR}/bullet-3.25/lib/Debug/BulletDynamics_Debug.lib
    debug ${THIRDPARTY_DIR}/bullet-3.25/lib/Debug/LinearMath_Debug.lib

    optimized ${THIRDPARTY_DIR}/bullet-3.25/lib/Release/BulletSoftBody.lib
    optimized ${THIRDPARTY_DIR}/bullet-3.25/lib/Release/BulletCollision.lib
    optimized ${THIRDPARTY_DIR}/bullet-3.25/lib/Release/BulletDynamics.lib
    optimized ${THIRDPARTY_DIR}/bullet-3.25/lib/Release/LinearMath.lib

    # minsizerel ${THIRDPARTY_DIR}/bullet-3.25/lib/MinSizeRel/BulletSoftBody_MinSizeRel.lib
    # minsizerel ${THIRDPARTY_DIR}/bullet-3.25/lib/MinSizeRel/BulletCollision_MinSizeRel.lib
    # minsizerel ${THIRDPARTY_DIR}/bullet-3.25/lib/MinSizeRel/BulletDynamics_MinSizeRel.lib
    # minsizerel ${THIRDPARTY_DIR}/bullet-3.25/lib/MinSizeRel/LinearMath_MinSizeRel.lib

    relwithdebinfo ${THIRDPARTY_DIR}/bullet-3.25/lib/RelWithDebInfo/BulletSoftBody_RelWithDebugInfo.lib
    relwithdebinfo ${THIRDPARTY_DIR}/bullet-3.25/lib/RelWithDebInfo/BulletCollision_RelWithDebugInfo.lib
    relwithdebinfo ${THIRDPARTY_DIR}/bullet-3.25/lib/RelWithDebInfo/BulletDynamics_RelWithDebugInfo.lib
    relwithdebinfo ${THIRDPARTY_DIR}/bullet-3.25/lib/RelWithDebInfo/LinearMath_RelWithDebugInfo.lib
)

# https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
#     Fix this error: [build] BulletCollision.lib(btOverlappingPairCache.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in draft.obj 
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")

Is it possible to make minsizerel & relwithdebinfo to use the same .lib files with Debug or Release because they cause my project file to be bigger because my project uses .lib files instead of compiling the library from its source code, and my project becomes bigger but I prefer smaller project size by not using folder "MinSizeRel" or "RelWithDebInfo" if possible? The total size of compressed .lib of Bullet Physics:

Debug.zip          10.5 MB
MinSizeRel.zip     2.8 MB
Release.zip        3.2 MB
RelWithDebInfo.zip 7.5 MB
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,553 questions
{count} votes