MantisBT - CMake
View Issue Details
0008170CMakeCMakepublic2008-11-25 10:442015-04-06 09:07
Thorsten Köster 
 
normalmajoralways
closedfixed 
CMake-2-6 
CMake 3.1CMake 3.1 
0008170: Visual Studio 9 generator does not output Custom Build Tool command line for assembler sources
I basically have the following CMakeLists.txt (reduced for clarity) which I would like to use for building a static library consisting of both C++ and assembler sources:


PROJECT(${lib_name} CXX ASM-ATT)
ADD_LIBRARY(${lib_name} STATIC ${CXX_SRCS} ${ASM_SRCS})
# I'm paranoid right now, so try to force CMake...
SET_SOURCE_FILES_PROPERTIES(${ASM_SRCS} PROPERTIES LANGUAGE ASM-ATT)
SET_SOURCE_FILES_PROPERTIES(${CXX_SRCS} PROPERTIES LANGUAGE CXX)


The assembler (MinGW as) seems to be detected correctly, and when I generate an Eclipse project with Unix makefiles, the command line shows up correctly. When I try the same in Visual Studio, the configuration for the ${ASM_SRCS}-files will be set to "Custom Build Tool", but no command line will be issued (verified in .vcproj file).
asm, masm, msvc, studio, visual, visual studio
has duplicate 0014984closed  Assembler config not working (in VS2005, with partial solution,with zlib-1.2.8) 
related to 0009905closed  Support for .asm files in the Visual Studio generators 
related to 0011536closed Patrick R. Gansterer Can't use assembler files with Visual Studio 10 generator 
related to 0010848closed Kitware Robot Issue with space in paths used for <OBJECT> and <SOURCE> in CMAKE_ASM 
diff vs_asm.diff (15,413) 2010-02-23 13:04
https://public.kitware.com/Bug/file/2895/vs_asm.diff
zip custom-build.zip (965) 2010-03-14 08:00
https://public.kitware.com/Bug/file/2969/custom-build.zip
diff cmLocalGenerator.diff (1,624) 2010-04-13 07:35
https://public.kitware.com/Bug/file/3023/cmLocalGenerator.diff
patch 0001-generator-expression.patch (3,386) 2012-08-20 13:09
https://public.kitware.com/Bug/file/4428/0001-generator-expression.patch
patch 0002-visual-studio-assembly-files.patch (8,112) 2012-08-20 13:09
https://public.kitware.com/Bug/file/4429/0002-visual-studio-assembly-files.patch
patch 0001-asm_file_support_vs2010_vs2012.patch (2,556) 2012-10-25 17:54
https://public.kitware.com/Bug/file/4541/0001-asm_file_support_vs2010_vs2012.patch
patch 0001-new_asm_file_support_vs2010_vs2012.patch (2,566) 2013-06-05 10:04
https://public.kitware.com/Bug/file/4779/0001-new_asm_file_support_vs2010_vs2012.patch
Issue History
2008-11-25 10:44Thorsten KösterNew Issue
2008-11-25 11:02Thorsten KösterNote Added: 0014180
2009-02-12 12:27Bill HoffmanNote Added: 0014915
2009-02-12 12:27Bill HoffmanStatusnew => assigned
2009-02-12 12:27Bill HoffmanAssigned To => Bill Hoffman
2010-02-23 13:04Brian BassettNote Added: 0019597
2010-02-23 13:04Brian BassettFile Added: vs_asm.diff
2010-02-23 16:11Brian BassettNote Edited: 0019597
2010-03-14 08:00dbNote Added: 0019873
2010-03-14 08:00dbFile Added: custom-build.zip
2010-04-13 07:35Maxim KizubFile Added: cmLocalGenerator.diff
2010-04-13 07:38Maxim KizubNote Added: 0020150
2010-10-18 20:37viktor11111Note Added: 0022529
2010-10-18 20:52viktor11111Tag Attached: msvc
2010-10-18 20:52viktor11111Tag Attached: studio
2010-10-18 20:52viktor11111Tag Attached: visual
2010-10-18 20:52viktor11111Tag Attached: visual studio
2010-10-18 20:52viktor11111Tag Attached: asm
2010-10-18 20:52viktor11111Tag Attached: masm
2010-12-15 09:04David ColeRelationship addedrelated to 0009905
2011-03-10 15:05Alex NeundorfRelationship addedrelated to 0011536
2011-03-10 15:11Alex NeundorfRelationship addedrelated to 0010848
2011-04-14 14:17David ColeTarget Version => CMake 2.8.5
2011-05-25 16:58David ColeNote Added: 0026592
2011-05-25 16:58David ColeTarget VersionCMake 2.8.5 =>
2012-02-09 11:52Amine KhaldiNote Added: 0028545
2012-08-06 21:10Amine KhaldiNote Added: 0030179
2012-08-20 11:48David ColeAssigned ToBill Hoffman =>
2012-08-20 11:48David ColeStatusassigned => new
2012-08-20 11:48David ColeTarget Version => CMake 2.8.10
2012-08-20 13:09Brian BassettNote Added: 0030710
2012-08-20 13:09Brian BassettFile Added: 0001-generator-expression.patch
2012-08-20 13:09Brian BassettFile Added: 0002-visual-studio-assembly-files.patch
2012-08-20 15:42Amine KhaldiNote Added: 0030711
2012-08-20 15:54David ColeNote Added: 0030712
2012-08-20 16:48Brian BassettNote Added: 0030713
2012-08-20 17:08Amine KhaldiNote Added: 0030714
2012-10-18 11:16David ColeTarget VersionCMake 2.8.10 => CMake 2.8.11
2012-10-18 11:17David ColeNote Added: 0031259
2012-10-25 17:54viktor11111File Added: 0001-asm_file_support_vs2010_vs2012.patch
2012-10-25 18:12viktor11111Note Added: 0031337
2012-10-25 18:21viktor11111Note Edited: 0031337bug_revision_view_page.php?bugnote_id=31337#r875
2012-10-25 18:24viktor11111Note Edited: 0031337bug_revision_view_page.php?bugnote_id=31337#r876
2012-10-25 18:28viktor11111Note Edited: 0031337bug_revision_view_page.php?bugnote_id=31337#r877
2013-02-12 16:41viktor11111Note Added: 0032252
2013-05-17 09:33Robert MaynardTarget VersionCMake 2.8.11 => CMake 2.8.12
2013-05-31 07:50BudNote Added: 0033159
2013-06-05 10:04viktor11111File Added: 0001-new_asm_file_support_vs2010_vs2012.patch
2013-06-05 10:06viktor11111Note Added: 0033244
2013-07-29 02:38dbNote Added: 0033624
2013-08-06 17:39Amine KhaldiNote Added: 0033674
2013-08-08 01:22dbNote Added: 0033680
2014-06-24 14:55Brad KingRelationship addedhas duplicate 0014984
2014-08-22 10:40Brad KingNote Added: 0036668
2014-08-22 10:40Brad KingTarget VersionCMake 2.8.12 => CMake 3.1
2014-10-03 09:19Brad KingStatusnew => resolved
2014-10-03 09:19Brad KingResolutionopen => fixed
2014-10-03 09:19Brad KingFixed in Version => CMake 3.1
2015-04-06 09:07Robert MaynardNote Added: 0038413
2015-04-06 09:07Robert MaynardStatusresolved => closed

Notes
(0014180)
Thorsten Köster   
2008-11-25 11:02   
I even added

   SET_TARGET_PROPERTIES(${lib_name} PROPERTIES LINKER_LANGUAGE CXX)

but that didn't help, either. When I added

   SET_TARGET_PROPERTIES(${lib_name} PROPERTIES LINKER_LANGUAGE ASM-ATT)

though, each and every file would suddenly have been compiled using the assembler.
(0014915)
Bill Hoffman   
2009-02-12 12:27   
Right now the asm stuff is not really supported in the vs generators...
(0019597)
Brian Bassett   
2010-02-23 13:04   
(edited on: 2010-02-23 16:11)
I've put together a patch that fixes this issue for those Visual Studio generators that use the Visual Studio 7 local generator (we're using CMake for an internal project, and only needed to support VS2008). The patch adds the concept of a "multi-config custom command" (which is basically a map of configurations to custom commands). This is not exposed to the user, and only used internally to the generator.

This patch also happens to have the benefit of being general (i.e. it isn't limited to assembler), but handles any generating objects for any language that the generator doesn't already know about (i.e. C, CXX, IDL, RC, DEF, and Fortran).

(0019873)
db   
2010-03-14 08:00   
Good job! That's what I'm waiting for a long time. Unfortunately it does not work entirely correctly with generated sources. In the attached example test2.asm is initially filled with "Artificial dependency for a custom command." and is not re-generated during Visual Studio build. With nmake generator it's generated as expected.
(0020150)
Maxim Kizub   
2010-04-13 07:38   
We have the same issue, and to compile our project I've make a quick fix in file cmLocalGenerator.cxx
We use "yasm.exe" assembler and ASM language.
Maybe this patch, used as example, will help the fix the bug.
(0022529)
viktor11111   
2010-10-18 20:37   
Please apply this patch "cmLocalGenerator.diff" in main branche, because that bug is still reproduced.
(0026592)
David Cole   
2011-05-25 16:58   
Not for 2.8.5 - postponing until a future release
(0028545)
Amine Khaldi   
2012-02-09 11:52   
Please note that this bug is blocking us (ReactOS) from using the VS generators, and msbuild specifically, so our only option right now is the one core nmake builds where asm files are handled correctly.
(0030179)
Amine Khaldi   
2012-08-06 21:10   
Ping ?
(0030710)
Brian Bassett   
2012-08-20 13:09   
I've updated my patch to move away from my (admittedly funky) multi-config custom command concept to use a new generator expression ($<CONFIG_SPECIFIC:...>) to expand the correct flags. (The patch is now in two chunks, one that implements the new generator expression, and the other that updates the generators.)
(0030711)
Amine Khaldi   
2012-08-20 15:42   
Hi,

First of all thank you for working on this.

Did you perhaps miss <DEFINES> expansion ? I didn't see it mentioned anywhere, when I (superficially) looked at the patch.
(0030712)
David Cole   
2012-08-20 15:54   
We just merged a branch into 'master' that contains new generator expressions. See the commits here (FYI for anybody working on generator expression type stuff):

  Add boolean generator expressions:
    http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ebf05abda15967f8f50dcf132f7bf84472ca6337 [^]

  Add $<CONFIG:...> boolean query generator expression
    http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d9f616792ee07a460af9f0a6dc036d81b852e66 [^]

There are also several other bug tracker issues that are related to configuration-specific behaviors, for add_custom_command and others, ... If I can find them, I'll link them to this as related issues.
(0030713)
Brian Bassett   
2012-08-20 16:48   
@Amine: Yes and no. I didn't expand <DEFINES>, but that was because none of the three supported assemblers (MASM, NASM, or ATT) use <DEFINES> in their CMAKE_ASM*_COMPILE_OBJECT declaration.
(0030714)
Amine Khaldi   
2012-08-20 17:08   
@Brian: Ah I see. We do use them (ReactOS) so I would appreciate adding the expansion here. I'll test the patch as soon as you upload it, and report back. Thank you in advance ;)
(0031259)
David Cole   
2012-10-18 11:17   
These bugs were deferred from target version 2.8.10 to 2.8.11 based on the responses to this email thread on the CMake developer's mailing list:

  http://public.kitware.com/pipermail/cmake-developers/2012-October/005434.html [^]
(0031337)
viktor11111   
2012-10-25 18:12   
(edited on: 2012-10-25 18:28)
find more simple solution based on this article

http://connect.microsoft.com/VisualStudio/feedback/details/538379/adding-macro-assembler-files-to-a-c-project [^]

please check patch "0001-asm_file_support_vs2010_vs2012.patch" and commit it in main branch

used:

   project(${MODULE_LIBRARY_NAME} ASM_MASM)

(0032252)
viktor11111   
2013-02-12 16:41   
Ping ?
(0033159)
Bud   
2013-05-31 07:50   
+1; I'm hoping this patch is in 2.8.12, it's been holding me up for months.
(0033244)
viktor11111   
2013-06-05 10:06   
update patch for last revision

"0001-new_asm_file_support_vs2010_vs2012.patch"

please check and commit it in main branch
(0033624)
db   
2013-07-29 02:38   
viktor11111, your solution is only partial because it does not support anything different from MASM. There are other assemblers in the world (e.g. yasm, jwasm etc.) So I would prefer Maxim Kizub's way (cmLocalGenerator.diff). Maxim, can you update your patch for the latest CMake/Visual studio 2012?
(0033674)
Amine Khaldi   
2013-08-06 17:39   
Please note, the patch mentioned here and in http://www.cmake.org/Bug/view.php?id=11536 [^] doesn't solve the preprocessed asm source files case. The work started by Brian Bassett is the closest thing to having proper handling of the most widely used form of asm source files (you rarely add asm source files without preprocessing). It would be great to have that picked up so that we (ReactOS at least) can finally compile with VS. Thanks.
(0033680)
db   
2013-08-08 01:22   
@Amine: indeed, Brian Bassett's patch seems to be the most universal one. Has anyone updated it for CMake 2.8.11?
(0036668)
Brad King   
2014-08-22 10:40   
This has now been implemented:

 VS: Add MASM support to VS 8 and 9
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f8522a6 [^]
(0038413)
Robert Maynard   
2015-04-06 09:07   
Closing resolved issues that have not been updated in more than 4 months.