From 658a1806a75eff74fd7fb5349c46814f36f2169d Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 31 Oct 2025 01:45:32 +0100 Subject: [PATCH] No optimization flags to remill_settings and default CMAKE_BUILD_TYPE=Debug --- CMakeLists.txt | 8 +------- cmake/settings.cmake | 6 ++++++ tests/X86/CMakeLists.txt | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5067afb..fa8f65d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,22 +190,16 @@ else() # debug symbols if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") target_compile_options(remill_settings INTERFACE - -gdwarf-2 -g3 + -g3 ) endif() # optimization flags and definitions if(CMAKE_BUILD_TYPE STREQUAL "Debug") - target_compile_options(remill_settings INTERFACE - -O0 - ) target_compile_definitions(remill_settings INTERFACE "DEBUG" ) else() - target_compile_options(remill_settings INTERFACE - -O2 - ) target_compile_definitions(remill_settings INTERFACE "NDEBUG" ) diff --git a/cmake/settings.cmake b/cmake/settings.cmake index 6c87070a..8a7d65bb 100644 --- a/cmake/settings.cmake +++ b/cmake/settings.cmake @@ -1,6 +1,12 @@ # This is only executed once; use a macro (and not a function) so that # everything defined here does not end up in a separate namespace macro(main) + # Set default build type to Debug for single-config generators + if(NOT CMAKE_BUILD_TYPE AND NOT GENERATOR_IS_MULTI_CONFIG) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) + message(STATUS "CMAKE_BUILD_TYPE not specified, defaulting to Debug") + endif() + # overwrite the default install prefix if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) if(DEFINED WIN32) diff --git a/tests/X86/CMakeLists.txt b/tests/X86/CMakeLists.txt index 198bdc67..cd90e752 100644 --- a/tests/X86/CMakeLists.txt +++ b/tests/X86/CMakeLists.txt @@ -62,6 +62,9 @@ function(COMPILE_X86_TESTS name address_size has_avx has_avx512) target_link_libraries(run-${name}-tests PUBLIC remill GTest::gtest) target_compile_definitions(run-${name}-tests PUBLIC ${PROJECT_DEFINITIONS}) + # Without optimizations the tests take infinitely long + target_compile_options(run-${name}-tests PRIVATE $<$:-O2>) + target_compile_options(run-${name}-tests PRIVATE ${X86_TEST_FLAGS} )