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

[Config] POC: enable assertions even in release mode #4496

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
37 changes: 32 additions & 5 deletions Sofa/framework/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/lib/cmake")

if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /Ob2" CACHE STRING
"Flags used by the C++ compiler during maintainer builds."
FORCE)
set(CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2" CACHE STRING
"Flags used by the C compiler during maintainer builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"/INCREMENTAL:NO" CACHE STRING
"Flags used for linking binaries during maintainer builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE
"/INCREMENTAL:NO" CACHE STRING
"Flags used by the shared libraries linker during maintainer builds."
FORCE)
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE STRING
"Flags used by the C++ compiler during maintainer builds."
FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O3" CACHE STRING
"Flags used by the C compiler during maintainer builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"" CACHE STRING
"Flags used for linking binaries during maintainer builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE
"" CACHE STRING
"Flags used by the shared libraries linker during maintainer builds."
FORCE)
endif()

include(SofaMacros)

# Clear internal target list (set by the macro sofa_add_generic() )
Expand Down Expand Up @@ -261,11 +293,6 @@ if(SOFA_ENABLE_BUILTIN_TIMER)
set(SOFA_ENABLE_SCOPED_ADVANCED_TIMER 1)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
target_compile_definitions(${PROJECT_NAME} PUBLIC "NDEBUG")
# On Windows and MacOS, NDEBUG and _DEBUG are automatically
# set in the default c/cxx flags of the right configurations
endif()
if(MSVC)
# Increase Number of Sections in .Obj file
list(APPEND SOFACONFIG_COMPILE_OPTIONS "/bigobj")
Expand Down
1 change: 1 addition & 0 deletions Sofa/framework/Helper/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_subdirectory(system/FailingPlugin)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} Sofa.Testing Sofa.Helper)
target_compile_definitions(${PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:NDEBUG>")

add_definitions("-DSTBIMAGETEST_RESOURCES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/io/images\"")

Expand Down
Loading