diff --git a/CMakeLists.txt b/CMakeLists.txt index 8796992b5e2..ac31959a410 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,16 @@ else() set(WINARCH ${ARCH}) endif() +# set CMAKE_BUILD_TYPE if not set +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to Debug as none was specified.") + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + # Versioning include(sdk/include/reactos/version.cmake) diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake index 43a2c8a7fdc..aad75ebcc4d 100644 --- a/sdk/cmake/msvc.cmake +++ b/sdk/cmake/msvc.cmake @@ -1,9 +1,5 @@ -#if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - # no optimization - add_compile_options(/Ob0 /Od) -elseif(CMAKE_BUILD_TYPE STREQUAL "Release") +if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(/Ox /Ob2 /Ot /Oy /GT) elseif(OPTIMIZE STREQUAL "1") add_compile_options(/O1) @@ -12,7 +8,7 @@ elseif(OPTIMIZE STREQUAL "2") elseif(OPTIMIZE STREQUAL "3") add_compile_options(/Ot /Ox /GS-) elseif(OPTIMIZE STREQUAL "4") - add_compile_options(/Os /Ox /GS-) + add_compile_options(/Ob0 /Od) elseif(OPTIMIZE STREQUAL "5") add_compile_options(/Gy /Ob2 /Os /Ox /GS-) endif() @@ -116,8 +112,8 @@ add_compile_options(/wd4018) add_compile_options(/we4013 /we4020 /we4022 /we4028 /we4047 /we4098 /we4101 /we4113 /we4129 /we4133 /we4163 /we4229 /we4311 /we4312 /we4313 /we4477 /we4603 /we4700 /we4715 /we4716) # - C4189: local variable initialized but not referenced -# Not in Release mode -if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") +# Not in Release mode, msbuild generator doesn't like CMAKE_BUILD_TYPE +if(MSVC_IDE OR CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_options(/we4189) endif() @@ -130,13 +126,10 @@ if(USE_CLANG_CL) endif() # Debugging -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - if(NOT (_PREFAST_ OR _VS_ANALYZE_)) - add_compile_options(/Zi) - endif() -elseif(CMAKE_BUILD_TYPE STREQUAL "Release") - add_definitions("/D NDEBUG") +if(NOT (_PREFAST_ OR _VS_ANALYZE_)) + add_compile_options($<$:/Zi>) endif() +add_compile_definitions($<$:NDEBUG>) # Hotpatchable images if(ARCH STREQUAL "i386") diff --git a/toolchain-gcc.cmake b/toolchain-gcc.cmake index 9d2a51899ee..f6ca04a8000 100644 --- a/toolchain-gcc.cmake +++ b/toolchain-gcc.cmake @@ -1,10 +1,4 @@ -# Default to Debug for the build type -if(NOT DEFINED CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING - "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -endif() - # pass variables necessary for the toolchain (needed for try_compile) set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH) diff --git a/toolchain-msvc.cmake b/toolchain-msvc.cmake index 9de8fca31e9..97921b216f7 100644 --- a/toolchain-msvc.cmake +++ b/toolchain-msvc.cmake @@ -1,10 +1,4 @@ -# Default to Debug for the build type -if(NOT DEFINED CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING - "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -endif() - # pass variables necessary for the toolchain (needed for try_compile) set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH USE_CLANG_CL)