Hi Alex,<br><br>I've tested your zip file example and it works as expected: the -I options are present but not the -D options. After some more testing of what is different in my setup I think I have isolated the cause. If I change this one line in your example from this:<br>
<br> add_definitions(-DFOO)<br><br>to this:<br><br> add_definitions("-DFOO -DBAR")<br><br>then I get the same behaviour I was seeing before: the -DFOO -DBAR options are passed through to the assembler command line. I see from the documentation that I should really be using add_definitions(-DFOO -DBAR) without the double quotes but they were harmless before. Should I file this as a bug - or will it just be marked as "not a bug", i.e. don't use double quotes like that with add_definitions ?<br>
<br>--<br>Glenn<br><br><br><div class="gmail_quote">2011/8/3 Alexander Neundorf <span dir="ltr"><<a href="mailto:a.neundorf-work@gmx.net">a.neundorf-work@gmx.net</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<div><div></div><div class="h5"><br>
On Wednesday 03 August 2011, Glenn Coombs wrote:<br>
> I tried changing from ASM to ASM-ATT and that fails like this:<br>
><br>
> /usr/bin/as -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src<br>
> -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/kernel<br>
> -DNOMINMAX -DUSE_SIM_NAMESPACE -o<br>
> CMakeFiles/systemc.dir/src/sysc/qt/md/i386.s.o<br>
> /user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/qt/md/i386.<br>
> s /usr/bin/as: unrecognized option `-NOMINMAX'<br>
><br>
> I really don't think the -I and -D options should be passed through for<br>
> assembler files. They only make sense for C/C++ files. There should be a<br>
> separate variable like CMAKE_ASM_FLAGS that is used instead of<br>
> CMAKE_C_FLAGS or CMAKE_CXX_FLAGS. And maybe there needs to be a change to<br>
> the<br>
> add_definitions() command to allow an optional LANG argument ? Do<br>
> assembers even support preprocessor definitions ?<br>
><br>
> I was able to get it to work for both 2.8.4 and 2.8.5 with the following<br>
> code:<br>
><br>
> if(UNIX)<br>
> list(APPEND sources "src/sysc/qt/qt.c")<br>
><br>
> # see if we are building 32-bit or 64-bit executables<br>
> file(WRITE ${CMAKE_BINARY_DIR}/check_32or64bit.cpp "int main(int argc,<br>
> char *argv[]) { return 8 * sizeof(char *); }\n")<br>
><br>
> try_run(<br>
> run_result<br>
> compile_result<br>
> ${CMAKE_BINARY_DIR}<br>
> ${CMAKE_BINARY_DIR}/check_32or64bit.cpp<br>
> )<br>
><br>
> if (${run_result} EQUAL 32)<br>
> list(APPEND sources "src/sysc/qt/md/i386.s")<br>
> if(APPLE)<br>
> set(ASM_SYS_FLAGS "-arch i386")<br>
> else()<br>
> set(ASM_SYS_FLAGS "-32")<br>
> endif()<br>
> else()<br>
> list(APPEND sources "src/sysc/qt/md/iX86_64.s")<br>
> if(APPLE)<br>
> set(ASM_SYS_FLAGS "-arch x86_64")<br>
> else()<br>
> set(ASM_SYS_FLAGS "-64")<br>
> endif()<br>
> endif()<br>
><br>
> enable_language(ASM-ATT)<br>
><br>
> set(CMAKE_ASM-ATT_COMPILE_OBJECT "<CMAKE_ASM-ATT_COMPILER><br>
> ${ASM_SYS_FLAGS} -o <OBJECT> <SOURCE>")<br>
> endif()<br>
><br>
> I'm not sure if this is the recommended way to do this though. I thought<br>
> the documentation said to override CMAKE_ASM-ATT_COMPILE_OBJECT before the<br>
> enable_language() command.<br>
<br>
</div></div>You should not have to override it.<br>
To set flags, there are for every enabled language CMAKE_<LANGUAGE>_FLAGS in<br>
the cmake cache, i.e. CMAKE_ASM-ATT_FLAGS in this case.<br>
<br>
I tried to reproduce the problem with the attached tiny project, and I don't<br>
get the problem you describe. This is the output:<br>
<br>
as-test/b$ /opt/cmake-HEAD/bin/cmake ..<br>
-- The C compiler identification is GNU<br>
-- The CXX compiler identification is GNU<br>
-- Check for working C compiler: /usr/bin/gcc<br>
-- Check for working C compiler: /usr/bin/gcc -- works<br>
-- Detecting C compiler ABI info<br>
-- Detecting C compiler ABI info - done<br>
-- Check for working CXX compiler: /usr/bin/c++<br>
-- Check for working CXX compiler: /usr/bin/c++ -- works<br>
-- Detecting CXX compiler ABI info<br>
-- Detecting CXX compiler ABI info - done<br>
-- The ASM-ATT compiler identification is GNU<br>
-- Found assembler: /usr/bin/as<br>
-- Configuring done<br>
-- Generating done<br>
-- Build files have been written to: /home/alex/src/CMake/build dir/CMake-<br>
git/Tests/Assembler/as-test/b<br>
as-test/b$ make VERBOSE=1<br>
...<br>
Scanning dependencies of target hello<br>
make[2]: Leaving directory `/home/alex/src/CMake/build dir/CMake-<br>
git/Tests/Assembler/as-test/b'<br>
make -f CMakeFiles/hello.dir/build.make CMakeFiles/hello.dir/build<br>
make[2]: Entering directory `/home/alex/src/CMake/build dir/CMake-<br>
git/Tests/Assembler/as-test/b'<br>
/opt/cmake-HEAD/bin/cmake -E cmake_progress_report "/home/alex/src/CMake/build<br>
dir/CMake-git/Tests/Assembler/as-test/b/CMakeFiles" 1<br>
<br>
[ 50%] Building C object CMakeFiles/hello.dir/main.c.o<br>
/usr/bin/gcc -DFOO -DBLUB=blub -DBAR=bar -I/opt/include -o<br>
CMakeFiles/hello.dir/main.c.o -c "/home/alex/src/CMake/build dir/CMake-<br>
git/Tests/Assembler/as-test/main.c"<br>
/opt/cmake-HEAD/bin/cmake -E cmake_progress_report "/home/alex/src/CMake/build<br>
dir/CMake-git/Tests/Assembler/as-test/b/CMakeFiles" 2<br>
<br>
[100%] Building ASM-ATT object CMakeFiles/hello.dir/foo.s.o<br>
/usr/bin/as -I/opt/include -o CMakeFiles/hello.dir/foo.s.o<br>
"/home/alex/src/CMake/build dir/CMake-git/Tests/Assembler/as-test/foo.s"<br>
Linking C executable hello<br>
...<br>
<br>
<br>
So, here main.c gets all the -D's, and foo.s gets the -I, but not the -D's.<br>
Is that different for you ?<br>
<br>
Alex<br>
</blockquote></div><br>