1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032545: Configuration, CMake - add BUILD_FORCE_RelWithDebInfo option for generating VS project files with Debug info in Release mode

This commit is contained in:
kgv 2021-08-28 01:42:10 +03:00 committed by smoskvin
parent 7e187d6b22
commit 19691a22fd
7 changed files with 38 additions and 4 deletions

View File

@ -91,6 +91,16 @@ if (NOT DEFINED BUILD_RELEASE_DISABLE_EXCEPTIONS)
set (BUILD_RELEASE_DISABLE_EXCEPTIONS ON CACHE BOOL "${BUILD_RELEASE_DISABLE_EXCEPTIONS_DESCR}")
endif()
if (MSVC)
set (BUILD_FORCE_RelWithDebInfo OFF CACHE BOOL "${BUILD_FORCE_RelWithDebInfo_DESCR}")
else()
set (BUILD_FORCE_RelWithDebInfo OFF)
endif()
if (BUILD_FORCE_RelWithDebInfo)
set (CMAKE_CONFIGURATION_TYPES Release Debug CACHE INTERNAL "" FORCE)
endif()
# option to enable or disable use of precompiled headers
if (NOT DEFINED BUILD_USE_PCH)
set (BUILD_USE_PCH OFF CACHE BOOL "${BUILD_USE_PCH_DESCR}")

View File

@ -191,13 +191,13 @@ foreach (LIBRARY_NAME ${CSF_FFmpeg})
else()
install (FILES "${3RDPARTY_FFMPEG_DLL_${LIBRARY_NAME}}"
CONFIGURATIONS Release
DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${INSTALL_DIR_BIN}")
install (FILES "${3RDPARTY_FFMPEG_DLL_${LIBRARY_NAME}}"
CONFIGURATIONS RelWithDebInfo
DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${INSTALL_DIR_BIN}i")
install (FILES "${3RDPARTY_FFMPEG_DLL_${LIBRARY_NAME}}"
CONFIGURATIONS Debug
DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${INSTALL_DIR_BIN}d")
endif()
else()
get_filename_component(3RDPARTY_FFMPEG_LIBRARY_ABS ${3RDPARTY_FFMPEG_LIBRARY_${LIBRARY_NAME}} REALPATH)

View File

@ -40,6 +40,19 @@ elseif (MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
endif()
if (MSVC)
# string pooling (GF), function-level linking (Gy)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GF /Gy")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GF /Gy")
if (BUILD_FORCE_RelWithDebInfo)
# generate debug info (Zi), inline expansion level (Ob1)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /Ob1")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi /Ob1")
# generate debug info (debug), OptimizeReferences=true (OPT:REF), EnableCOMDATFolding=true (OPT:ICF)
set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /debug /OPT:REF /OPT:ICF")
endif()
endif()
# remove _WINDOWS flag if it exists
string (REGEX MATCH "/D_WINDOWS" IS_WINDOWSFLAG "${CMAKE_CXX_FLAGS}")
if (IS_WINDOWSFLAG)

View File

@ -236,8 +236,13 @@ else()
add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
if (MSVC)
if (BUILD_FORCE_RelWithDebInfo)
set (aReleasePdbConf "Release")
else()
set (aReleasePdbConf)
endif()
install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
CONFIGURATIONS Debug RelWithDebInfo
CONFIGURATIONS Debug ${aReleasePdbConf} RelWithDebInfo
DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
endif()

View File

@ -38,6 +38,9 @@ set (BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR
Corresponding environment variable (CSF_FPE) can be changed manually
in custom.bat/sh scripts without regeneration by CMake.")
set (BUILD_FORCE_RelWithDebInfo_DESCR
"Generate PDB files within normal Release build.")
set (BUILD_USE_PCH_DESCR
"Use precompiled headers to accelerate the build.
Precompiled headers are generated automatically by Cotire tool.")

View File

@ -22,6 +22,7 @@ rem set BUILD_RELEASE_DISABLE_EXCEPTIONS=ON
rem set BUILD_WITH_DEBUG=OFF
rem set BUILD_ENABLE_FPE_SIGNAL_HANDLER=ON
rem set BUILD_USE_PCH=OFF
rem set BUILD_FORCE_RelWithDebInfo=OFF
rem Use semicolon-separated list of toolkits if you want to disable all modules
rem and build only some toolkits.

View File

@ -24,6 +24,7 @@ set BUILD_RELEASE_DISABLE_EXCEPTIONS=ON
set BUILD_WITH_DEBUG=OFF
set BUILD_ENABLE_FPE_SIGNAL_HANDLER=ON
set BUILD_USE_PCH=OFF
set BUILD_FORCE_RelWithDebInfo=OFF
set BUILD_MODULE_ApplicationFramework=ON
set BUILD_MODULE_DataExchange=ON
@ -71,6 +72,7 @@ cmake -G "%arch_compile%" ^
-D BUILD_WITH_DEBUG:BOOL=%BUILD_WITH_DEBUG% ^
-D BUILD_ENABLE_FPE_SIGNAL_HANDLER:BOOL=%BUILD_ENABLE_FPE_SIGNAL_HANDLER% ^
-D BUILD_USE_PCH:BOOL=%BUILD_USE_PCH% ^
-D BUILD_FORCE_RelWithDebInfo:BOOL=%BUILD_FORCE_RelWithDebInfo% ^
-D INSTALL_DIR:PATH="%INSTALL_DIR%" ^
-D USE_D3D:BOOL=%USE_D3D% ^
-D USE_FFMPEG:BOOL=%USE_FFMPEG% ^