-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Description
and causes following warning to appear(in the MRE):
clang: warning: '-x c' after last input file has no effect [-Wunused-command-line-argument]
This is observable inside the build.make file.
MRE:
/path/to/MyProject/CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(MyProject)
add_executable(${PROJECT_NAME} main.c)
target_compile_options(${PROJECT_NAME} PRIVATE -x c)
/path/to/MyProject/main.c
int main(){}
build emcc
mkdir build-emcc &&
cd build-emcc &&
emcmake cmake .. &&
cmake --build .
build clang
mkdir build-clang &&
cd build-clang &&
export CC="$(which clang)" &&
cmake .. &&
cmake --build .
In the file build.make, (here in the last line),
for emcc, main.c is prepended before the compiler flags
but for clang, main.c comes after the flags:
/path/to/MyProject/build-emcc/CMakeFiles/MyProject.dir/build.make
CMakeFiles/MyProject.dir/codegen:
.PHONY : CMakeFiles/MyProject.dir/codegen
CMakeFiles/MyProject.dir/main.c.o: CMakeFiles/MyProject.dir/flags.make
CMakeFiles/MyProject.dir/main.c.o: /path/to/MyProject/main.c
CMakeFiles/MyProject.dir/main.c.o: CMakeFiles/MyProject.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/path/to/MyProject/build-emcc/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building C object CMakeFiles/MyProject.dir/main.c.o"
/path/to/emsdk/upstream/emscripten/emcc -c /path/to/MyProject/main.c $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -MD -MT CMakeFiles/MyProject.dir/main.c.o -MF CMakeFiles/MyProject.dir/main.c.o.d -o CMakeFiles/MyProject.dir/main.c.o -fPIC
/path/to/MyProject/build-clang/CMakeFiles/MyProject.dir/build.make
CMakeFiles/MyProject.dir/codegen:
.PHONY : CMakeFiles/MyProject.dir/codegen
CMakeFiles/MyProject.dir/main.c.o: CMakeFiles/MyProject.dir/flags.make
CMakeFiles/MyProject.dir/main.c.o: /path/to/MyProject/main.c
CMakeFiles/MyProject.dir/main.c.o: CMakeFiles/MyProject.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/path/to/MyProject/build-clang/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building C object CMakeFiles/MyProject.dir/main.c.o"
/usr/bin/clang $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -MD -MT CMakeFiles/MyProject.dir/main.c.o -MF CMakeFiles/MyProject.dir/main.c.o.d -o CMakeFiles/MyProject.dir/main.c.o -c /path/to/MyProject/main.c
artyomd
Metadata
Metadata
Assignees
Labels
No labels