I need to add a variable (a list) to the compiler flags. But that variable is modified when the compiler is invoked.
cmake_minimum_required(VERSION 3.16)
project(test LANGUAGES C)
set(ISYSTEM_FLAGS -isystem path1 -isystem path2)
message("ISYSTEM_FLAGS is ${ISYSTEM_FLAGS}")
add_executable(${PROJECT_NAME} a.c)
target_compile_options(${PROJECT_NAME}
PRIVATE
-Wall ${ISYSTEM_FLAGS} -Wextra)
The message shows as “ISYSTEM_FLAGS is -isystem;path1;-isystem;path2”
The compiler is invoked like cc -Wall -isystem path1 path2 -Wextra ...
. The third item in the ISYSTEM_FLAGS is omitted.
What I need is cc -Wall -isystem path1 -isystem path2 -Wextra ...
. Where does it go wrong? Thanks.
CMake version 3.27.4. Platform: MinGW.