Commits


Sutou Kouhei authored and GitHub committed 474b1a5eee0
ARROW-18231: [C++][CMake] Add support for overriding optimization level (#15022) We can overriding optimization level by `-DCMAKE_CXX_FLAGS_${CONFIG}=-OX` such as `-DCMAKE_CXX_FLAGS_RELEASE=-O0` with this change. Note that we can't use CXXFLAGS environment variable because CMake uses `${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CONFIG}}` order and optimization flags are specified in `CMAKE_CXX_FLAGS_${CONFIG}` not `CMAKE_CXX_FLAGS`. (CMAKE_CXX_FLAGS CMake variable is initialized by CXXFLAGS environment variable.) See also: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html > The flags in this variable will be passed to the compiler before > those in the per-configuration `CMAKE_<LANG>_FLAGS_<CONFIG>` variant, > and before flags added by the `add_compile_options()` or > `target_compile_options()` commands. This change also cleans up the followings: * C/CXX flags related codes * Use `CMAKE_C_FLAGS_${BUILD_TYPE}`/`CMAKE_CXX_FLAGS_${BUILD_TYPE}` instead of putting all flags to `CMAKE_C_FLAGS`/`CMAKE_CXX_FLAGS` * `externalproject_add()` related codes * Extract common options as `EP_XXX` * Use `string(APPEND)`/`list(APPEND)` as much as possible instead of `set(XXX "${XXX} ...")`/`set(XXX ${XXX} ...)` Authored-by: Sutou Kouhei <kou@clear-code.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>