Re: [CMake] Assembly language support using gcc or gas

2011-08-07 Thread Glenn Coombs
Hi Alex,

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:

add_definitions(-DFOO)

to this:

add_definitions(-DFOO -DBAR)

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 ?

--
Glenn


2011/8/3 Alexander Neundorf a.neundorf-w...@gmx.net

 Hi,

 On Wednesday 03 August 2011, Glenn Coombs wrote:
  I tried changing from ASM to ASM-ATT and that fails like this:
 
  /usr/bin/as  -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src
  -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/kernel
  -DNOMINMAX -DUSE_SIM_NAMESPACE -o
  CMakeFiles/systemc.dir/src/sysc/qt/md/i386.s.o
 
 /user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/qt/md/i386.
  s /usr/bin/as: unrecognized option `-NOMINMAX'
 
  I really don't think the -I and -D options should be passed through for
  assembler files.  They only make sense for C/C++ files.  There should be
 a
  separate variable like CMAKE_ASM_FLAGS that is used instead of
  CMAKE_C_FLAGS or CMAKE_CXX_FLAGS.  And maybe there needs to be a change
 to
  the
  add_definitions() command to allow an optional LANG argument ?  Do
  assembers even support preprocessor definitions ?
 
  I was able to get it to work for both 2.8.4 and 2.8.5 with the following
  code:
 
  if(UNIX)
  list(APPEND sources src/sysc/qt/qt.c)
 
  # see if we are building 32-bit or 64-bit executables
  file(WRITE ${CMAKE_BINARY_DIR}/check_32or64bit.cpp int main(int
 argc,
  char *argv[]) { return 8 * sizeof(char *); }\n)
 
  try_run(
  run_result
  compile_result
  ${CMAKE_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/check_32or64bit.cpp
  )
 
  if (${run_result} EQUAL 32)
  list(APPEND sources src/sysc/qt/md/i386.s)
  if(APPLE)
  set(ASM_SYS_FLAGS -arch i386)
  else()
  set(ASM_SYS_FLAGS -32)
  endif()
  else()
  list(APPEND sources src/sysc/qt/md/iX86_64.s)
  if(APPLE)
  set(ASM_SYS_FLAGS -arch x86_64)
  else()
  set(ASM_SYS_FLAGS -64)
  endif()
  endif()
 
  enable_language(ASM-ATT)
 
  set(CMAKE_ASM-ATT_COMPILE_OBJECT CMAKE_ASM-ATT_COMPILER
  ${ASM_SYS_FLAGS} -o OBJECT SOURCE)
  endif()
 
  I'm not sure if this is the recommended way to do this though.  I thought
  the documentation said to override CMAKE_ASM-ATT_COMPILE_OBJECT before
 the
  enable_language() command.

 You should not have to override it.
 To set flags, there are for every enabled language CMAKE_LANGUAGE_FLAGS
 in
 the cmake cache, i.e. CMAKE_ASM-ATT_FLAGS in this case.

 I tried to reproduce the problem with the attached tiny project, and I
 don't
 get the problem you describe. This is the output:

 as-test/b$ /opt/cmake-HEAD/bin/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
 -- The ASM-ATT compiler identification is GNU
 -- Found assembler: /usr/bin/as
 -- Configuring done
 -- Generating done
 -- Build files have been written to: /home/alex/src/CMake/build dir/CMake-
 git/Tests/Assembler/as-test/b
 as-test/b$ make VERBOSE=1
 ...
 Scanning dependencies of target hello
 make[2]: Leaving directory `/home/alex/src/CMake/build dir/CMake-
 git/Tests/Assembler/as-test/b'
 make -f CMakeFiles/hello.dir/build.make CMakeFiles/hello.dir/build
 make[2]: Entering directory `/home/alex/src/CMake/build dir/CMake-
 git/Tests/Assembler/as-test/b'
 /opt/cmake-HEAD/bin/cmake -E cmake_progress_report
 /home/alex/src/CMake/build
 dir/CMake-git/Tests/Assembler/as-test/b/CMakeFiles 1

 [ 50%] Building C object CMakeFiles/hello.dir/main.c.o
 /usr/bin/gcc  -DFOO -DBLUB=blub -DBAR=bar -I/opt/include-o
 CMakeFiles/hello.dir/main.c.o   -c /home/alex/src/CMake/build dir/CMake-
 git/Tests/Assembler/as-test/main.c
 /opt/cmake-HEAD/bin/cmake -E cmake_progress_report
 /home/alex/src/CMake/build
 dir/CMake-git/Tests/Assembler/as-test/b/CMakeFiles 2

 [100%] Building ASM-ATT object CMakeFiles/hello.dir/foo.s.o
 /usr/bin/as  -I/opt/include-o CMakeFiles/hello.dir/foo.s.o
 /home/alex/src/CMake/build 

Re: [CMake] Assembly language support using gcc or gas

2011-08-03 Thread Glenn Coombs
I tried changing from ASM to ASM-ATT and that fails like this:

/usr/bin/as  -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src
-I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/kernel
-DNOMINMAX -DUSE_SIM_NAMESPACE -o
CMakeFiles/systemc.dir/src/sysc/qt/md/i386.s.o
/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/qt/md/i386.s
/usr/bin/as: unrecognized option `-NOMINMAX'

I really don't think the -I and -D options should be passed through for
assembler files.  They only make sense for C/C++ files.  There should be a
separate variable like CMAKE_ASM_FLAGS that is used instead of CMAKE_C_FLAGS
or CMAKE_CXX_FLAGS.  And maybe there needs to be a change to the
add_definitions() command to allow an optional LANG argument ?  Do assembers
even support preprocessor definitions ?

I was able to get it to work for both 2.8.4 and 2.8.5 with the following
code:

if(UNIX)
list(APPEND sources src/sysc/qt/qt.c)

# see if we are building 32-bit or 64-bit executables
file(WRITE ${CMAKE_BINARY_DIR}/check_32or64bit.cpp int main(int argc,
char *argv[]) { return 8 * sizeof(char *); }\n)

try_run(
run_result
compile_result
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/check_32or64bit.cpp
)

if (${run_result} EQUAL 32)
list(APPEND sources src/sysc/qt/md/i386.s)
if(APPLE)
set(ASM_SYS_FLAGS -arch i386)
else()
set(ASM_SYS_FLAGS -32)
endif()
else()
list(APPEND sources src/sysc/qt/md/iX86_64.s)
if(APPLE)
set(ASM_SYS_FLAGS -arch x86_64)
else()
set(ASM_SYS_FLAGS -64)
endif()
endif()

enable_language(ASM-ATT)

set(CMAKE_ASM-ATT_COMPILE_OBJECT CMAKE_ASM-ATT_COMPILER
${ASM_SYS_FLAGS} -o OBJECT SOURCE)
endif()

I'm not sure if this is the recommended way to do this though.  I thought
the documentation said to override CMAKE_ASM-ATT_COMPILE_OBJECT before the
enable_language() command.  If I do that then I get the -I and -D flags back
and my ASM_SYS_FLAGS variable is ignored.  Is there a cleaner way to do this
or is my current solution okay ?


2011/8/2 Alexander Neundorf a.neundorf-w...@gmx.net

 Hi,

 On Tuesday 02 August 2011, Glenn Coombs wrote:
  Previously with cmake 2.8.4 we were using these lines to compile an

 with 2.8.5 there was a major rework of the assembler support (and now it
 finally does not say Assembler support is experimental anymore).
 Sorry that this causes inconvenience for you.

 If you enable ASM, you get support for assembler via your C/C++ compiler.
 That's why you get gcc now instead of as.
 If the C/C++ compiler does not support processing assembler files, this
 language can't be enabled.

 If you need a real assembler, you have to enable the respective assembler
 dialect. E.g. to get as/gas, you need to enable ASM-ATT.
 This should work with both versions.

 Let me know if this doesn't work for you.

 Alex

___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Assembly language support using gcc or gas

2011-08-03 Thread Alexander Neundorf
Hi,

On Wednesday 03 August 2011, Glenn Coombs wrote:
 I tried changing from ASM to ASM-ATT and that fails like this:
 
 /usr/bin/as  -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src
 -I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/kernel
 -DNOMINMAX -DUSE_SIM_NAMESPACE -o
 CMakeFiles/systemc.dir/src/sysc/qt/md/i386.s.o
 /user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/qt/md/i386.
 s /usr/bin/as: unrecognized option `-NOMINMAX'
 
 I really don't think the -I and -D options should be passed through for
 assembler files.  They only make sense for C/C++ files.  There should be a
 separate variable like CMAKE_ASM_FLAGS that is used instead of
 CMAKE_C_FLAGS or CMAKE_CXX_FLAGS.  And maybe there needs to be a change to
 the
 add_definitions() command to allow an optional LANG argument ?  Do
 assembers even support preprocessor definitions ?
 
 I was able to get it to work for both 2.8.4 and 2.8.5 with the following
 code:
 
 if(UNIX)
 list(APPEND sources src/sysc/qt/qt.c)
 
 # see if we are building 32-bit or 64-bit executables
 file(WRITE ${CMAKE_BINARY_DIR}/check_32or64bit.cpp int main(int argc,
 char *argv[]) { return 8 * sizeof(char *); }\n)
 
 try_run(
 run_result
 compile_result
 ${CMAKE_BINARY_DIR}
 ${CMAKE_BINARY_DIR}/check_32or64bit.cpp
 )
 
 if (${run_result} EQUAL 32)
 list(APPEND sources src/sysc/qt/md/i386.s)
 if(APPLE)
 set(ASM_SYS_FLAGS -arch i386)
 else()
 set(ASM_SYS_FLAGS -32)
 endif()
 else()
 list(APPEND sources src/sysc/qt/md/iX86_64.s)
 if(APPLE)
 set(ASM_SYS_FLAGS -arch x86_64)
 else()
 set(ASM_SYS_FLAGS -64)
 endif()
 endif()
 
 enable_language(ASM-ATT)
 
 set(CMAKE_ASM-ATT_COMPILE_OBJECT CMAKE_ASM-ATT_COMPILER
 ${ASM_SYS_FLAGS} -o OBJECT SOURCE)
 endif()
 
 I'm not sure if this is the recommended way to do this though.  I thought
 the documentation said to override CMAKE_ASM-ATT_COMPILE_OBJECT before the
 enable_language() command.  

You should not have to override it.
To set flags, there are for every enabled language CMAKE_LANGUAGE_FLAGS in 
the cmake cache, i.e. CMAKE_ASM-ATT_FLAGS in this case.

I tried to reproduce the problem with the attached tiny project, and I don't 
get the problem you describe. This is the output:

as-test/b$ /opt/cmake-HEAD/bin/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
-- The ASM-ATT compiler identification is GNU
-- Found assembler: /usr/bin/as
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/src/CMake/build dir/CMake-
git/Tests/Assembler/as-test/b
as-test/b$ make VERBOSE=1
...
Scanning dependencies of target hello
make[2]: Leaving directory `/home/alex/src/CMake/build dir/CMake-
git/Tests/Assembler/as-test/b'  
 
make -f CMakeFiles/hello.dir/build.make CMakeFiles/hello.dir/build
make[2]: Entering directory `/home/alex/src/CMake/build dir/CMake-
git/Tests/Assembler/as-test/b'
/opt/cmake-HEAD/bin/cmake -E cmake_progress_report /home/alex/src/CMake/build 
dir/CMake-git/Tests/Assembler/as-test/b/CMakeFiles 1

[ 50%] Building C object CMakeFiles/hello.dir/main.c.o
/usr/bin/gcc  -DFOO -DBLUB=blub -DBAR=bar -I/opt/include-o 
CMakeFiles/hello.dir/main.c.o   -c /home/alex/src/CMake/build dir/CMake-
git/Tests/Assembler/as-test/main.c
/opt/cmake-HEAD/bin/cmake -E cmake_progress_report /home/alex/src/CMake/build 
dir/CMake-git/Tests/Assembler/as-test/b/CMakeFiles 2

[100%] Building ASM-ATT object CMakeFiles/hello.dir/foo.s.o
/usr/bin/as  -I/opt/include-o CMakeFiles/hello.dir/foo.s.o 
/home/alex/src/CMake/build dir/CMake-git/Tests/Assembler/as-test/foo.s
   
Linking C executable hello
...


So, here main.c gets all the -D's, and foo.s gets the -I, but not the -D's.
Is that different for you ?

Alex


as-test.tar.gz
Description: application/compressed-tar
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Assembly language support using gcc or gas

2011-08-02 Thread Glenn Coombs
Previously with cmake 2.8.4 we were using these lines to compile an assembly
language file in our project:

if(UNIX)
enable_language(ASM)

# see if we are building 32-bit or 64-bit executables
file(WRITE ${CMAKE_BINARY_DIR}/check_32or64bit.cpp int main(int argc,
char *argv[]) { return 8 * sizeof(char *); }\n)

try_run(
run_result
compile_result
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/check_32or64bit.cpp
)

if (${run_result} EQUAL 32)
list(APPEND sources src/sysc/qt/md/i386.s)
if(APPLE)
set(ASM_SYS_FLAGS -arch i386)
else()
set(ASM_SYS_FLAGS -32)
endif()
else()
list(APPEND sources src/sysc/qt/md/iX86_64.s)
if(APPLE)
set(ASM_SYS_FLAGS -arch x86_64)
else()
set(ASM_SYS_FLAGS -64)
endif()
endif()

set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
CMAKE_ASM${ASM_DIALECT}_COMPILER ${ASM_SYS_FLAGS} -o OBJECT SOURCE)
endif()

And this resulted in the appropriate 32-bit or 64-bit assembler file being
compiled like so:

/usr/bin/as  -32 -o path snipped/i386.s.o  path-snipped/i386.s
/usr/bin/as  -64 -o path snipped/iX86_64.s.o path-snipped/iX86_64.s

Now with cmake 2.8.5 it fails when compiling that assembler file as it uses
/usr/bin/gcc rather than /usr/bin/as and gcc wants -m32 and -c instead of
-32.  When I tried commenting out the line that overrides the default
setting of CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT it fails differently:

/usr/bin/gcc  -DEXTERNAL_BUS_WIDTH=128 -DLINUX -DHIDEBUG -O3 -DNDEBUG
-I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src
-I/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/kernel
-DNOMINMAX -DUSE_SIM_NAMESPACE -o
CMakeFiles/systemc.dir/src/sysc/qt/md/i386.s.o -c
/user/grc/msvdx-cvsfiles/sim/msvdx-cmake-2.8.5/systemC/src/sysc/qt/md/i386.s

i386.s:69: Error: suffix or operands invalid for `push'

This line works if I add the -m32 option using set(CMAKE_ASM_FLAGS -m32)
but should all the preprocessor defines (-DXXX) and include directory
arguments (-IXXX) be present ?  I was thinking they were only for C/C++
files, no ?

And what is the recommended way to compile an assembly language file that
will work on both 2.8.4 and 2.8.5 ?

--
Glenn
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Assembly language support using gcc or gas

2011-08-02 Thread Alexander Neundorf
Hi,

On Tuesday 02 August 2011, Glenn Coombs wrote:
 Previously with cmake 2.8.4 we were using these lines to compile an

with 2.8.5 there was a major rework of the assembler support (and now it 
finally does not say Assembler support is experimental anymore).
Sorry that this causes inconvenience for you.

If you enable ASM, you get support for assembler via your C/C++ compiler.
That's why you get gcc now instead of as.
If the C/C++ compiler does not support processing assembler files, this 
language can't be enabled.

If you need a real assembler, you have to enable the respective assembler 
dialect. E.g. to get as/gas, you need to enable ASM-ATT.
This should work with both versions.

Let me know if this doesn't work for you.

Alex
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake