Clash between ASM and ASM_NASM languages
Hi there,
I'm working on a project that includes some external dependencies with add_subdirectory(). One of them uses enable_language(ASM). An other one uses enable_language(ASM_NASM). I then get this obscure error message when configuring the project:
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_ASM_COMPILE_OBJECT
I spent quite some time trying to understand what happens here but it's quite difficult because the external dependencies being included are pretty complex. So I tried to reproduce the issue with the simplest code possible, that I put on GitHub here
I added two options to enable/disable the use of the ASM language and the ASM_NASM language. Here are the results (all commands being run in a 'build' directory:
Without enabling any of the ASM and ASM_NASM languages:
$ cmake .. && cmake --build .
-- The C compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ghislain/projects/cmake_asm/build
[ 50%] Building C object CMakeFiles/cmake-asm.dir/dummy.c.o
[100%] Linking C static library libcmake-asm.a
[100%] Built target cmake-asm
Enabling only the ASM language:
$ cmake .. -DENABLE_ASM_PROJECT=ON && cmake --build .
-- The C compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ghislain/projects/cmake_asm/build
Scanning dependencies of target asm
[ 33%] Building ASM object asm-project/CMakeFiles/asm.dir/hello.S.o
[ 33%] Built target asm
[ 66%] Building C object CMakeFiles/cmake-asm.dir/dummy.c.o
[100%] Linking C static library libcmake-asm.a
[100%] Built target cmake-asm
Enabling only the ASM_NASM language:
$ cmake .. -DENABLE_ASM_NASM_PROJECT=ON && cmake --build .
-- The C compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/bin/nasm
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ghislain/projects/cmake_asm/build
[ 33%] Building ASM_NASM object asm-nasm-project/CMakeFiles/asm-nasm.dir/hello.asm.o
[ 33%] Built target asm-nasm
[ 66%] Building C object CMakeFiles/cmake-asm.dir/dummy.c.o
[100%] Linking C static library libcmake-asm.a
[100%] Built target cmake-asm
Enabling both ASM and ASM_NASM languages:
$ cmake .. -DENABLE_ASM_PROJECT=ON -DENABLE_ASM_NASM_PROJECT=ON && cmake --build .
-- The C compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/bin/nasm
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_ASM_COMPILE_OBJECT
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
I am working with CMake 3.22 but also tried this with CMake 3.27.0-rc3 and could reproduce the same behaviour.
Am I doing something wrong here, or is there some kind of clash happening between the ASM and the ASM_NASM languages?