CMake: don't override the rest of CMAKE_CXX_FLAGS_*
Same as
I wanted to pass custom/have righter control over
O/-g/-UNDEBUG flags, but that is not possible currently,
since the per-build-type flags are still being overrided.
Unless that is intentional of course?
The alternative, is [for me] to specify custom CMAKE_BUILD_TYPE.
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -10,15 +10,15 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if (MSVC)
set(CMAKE_CXX_FLAGS "/GL /EHsc /W2 ${CMAKE_CXX_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi")
- set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Oi /Oy /Zc:inline")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Oi /Zi")
+ set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi ${CMAKE_CXX_FLAGS_DEBUG}")
+ set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Oi /Oy /Zc:inline ${CMAKE_CXX_FLAGS_RELEASE}")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Oi /Zi ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_EXE_LINKER_FLAGS "/LTCG:INCREMENTAL ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "-Wall -march=native -fPIC ${CMAKE_CXX_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "-Werror -g -Og")
- set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
+ set(CMAKE_CXX_FLAGS_DEBUG "-Werror -g -Og ${CMAKE_CXX_FLAGS_DEBUG}")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${CMAKE_CXX_FLAGS_RELEASE}")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
set(CMAKE_CXX_STANDARD 17)

CMake: don't override the rest of CMAKE_CXX_FLAGS_*

Same as https://github.com/AliveToolkit/alive2/pull/6
I wanted to pass custom/have righter control over
-O/-g/-UNDEBUG flags, but that is not possible currently,
since the per-build-type flags are still being overrided.

Unless that is intentional of course?

The alternative, is [for me] to specify custom CMAKE_BUILD_TYPE.