[CMake] Problem with ASM and COMPILE_DEFINITIONS

Marcel Loose loose at astron.nl
Mon May 25 06:13:13 EDT 2009


Hi all,

I have a problem compiling assembly files. I followed the directions on
the Wiki http://www.cmake.org/Wiki/CMake/Assembler to create the
required CMake files.

I get compilation errors, because CMake passes -D<def> definitions to
the assembler, but the assembler doesn't accept preprocessor
definitions. These definitions were set a number of directory levels
higher, using add_definitions(). How can I avoid that these definitions
are put on the command line to the assembler?

Here is a simple example CMakeLists.txt file that exhibits the same
behavior.

$ cat ../CMakeLists.txt
project(MyProject)
cmake_minimum_required(VERSION 2.6)
add_definitions("-DMYDEF -DMYOTHERDEF")
enable_language(ASM-ATT)
add_executable(myexec myexec.S)

$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found assembler: /usr/bin/as
-- Loaded CMakeASM-ATTInformation - ASM-ATT support is still
experimental, please report issues
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/loose/LOFAR/build

$ make VERBOSE=1
/usr/bin/cmake -H/tmp/loose/LOFAR -B/tmp/loose/LOFAR/build
--check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E
cmake_progress_start /tmp/loose/LOFAR/build/CMakeFiles /tmp/loose/LOFAR/build/CMakeFiles/progress.make
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/tmp/loose/LOFAR/build'
make -f CMakeFiles/myexec.dir/build.make CMakeFiles/myexec.dir/depend
make[2]: Entering directory `/tmp/loose/LOFAR/build'
cd /tmp/loose/LOFAR/build && /usr/bin/cmake -E cmake_depends "Unix
Makefiles" /tmp/loose/LOFAR /tmp/loose/LOFAR /tmp/loose/LOFAR/build /tmp/loose/LOFAR/build /tmp/loose/LOFAR/build/CMakeFiles/myexec.dir/DependInfo.cmake --color=
Dependee "/tmp/loose/LOFAR/build/CMakeFiles/myexec.dir/DependInfo.cmake"
is newer than depender
"/tmp/loose/LOFAR/build/CMakeFiles/myexec.dir/depend.internal".
Scanning dependencies of target myexec
make[2]: Leaving directory `/tmp/loose/LOFAR/build'
make -f CMakeFiles/myexec.dir/build.make CMakeFiles/myexec.dir/build
make[2]: Entering directory `/tmp/loose/LOFAR/build'
/usr/bin/cmake -E
cmake_progress_report /tmp/loose/LOFAR/build/CMakeFiles 1
[100%] Building ASM-ATT object CMakeFiles/myexec.dir/myexec.S.o
/usr/bin/as  -DMYDEF -DMYOTHERDEF -o
CMakeFiles/myexec.dir/myexec.S.o /tmp/loose/LOFAR/myexec.S
/usr/bin/as: unrecognized option '-YDEF'
make[2]: *** [CMakeFiles/myexec.dir/myexec.S.o] Error 1
make[2]: Leaving directory `/tmp/loose/LOFAR/build'
make[1]: *** [CMakeFiles/myexec.dir/all] Error 2
make[1]: Leaving directory `/tmp/loose/LOFAR/build'
make: *** [all] Error 2


Best regards,
Marcel Loose.




More information about the CMake mailing list