[CMake] JWASM support

Dmitry Bely dmitry.bely at gmail.com
Tue Feb 3 07:59:21 EST 2009


On Tue, Feb 3, 2009 at 1:09 AM, Alexander Neundorf
<a.neundorf-work at gmx.net> wrote:
> On Saturday 31 January 2009, Dmitry Bely wrote:
>> I am trying to use JWASM (http://www.japheth.de/JWasm.html) with CMake
>> 2.6.2 to do rather unusual thing: cross-compile a C++ project with
>> MASM-syntax .asm files for Linux under Windows.
>
> Hmm, if it is able to build masm files I think it should be added as an
> additional compiler name in CMakeDetermineASM_MASMCompiler.cmake, I think a
> separate ASM "dialect" shouldn't be necessary here.

OK, but then how to select which assembler should be used: masm or
jwasm? Both can be present.

>> JWASM itself emulates
>> MASM excellently and has no problem generating COFF or ELF files but
>> now CMake comes into play.
>>
>> First of all, I added JWASM config files into CMake:
>>
>> *** CMakeASM_JWASMInformation.cmake
>> SET(ASM_DIALECT "_JWASM")
>> SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm)
>> IF(CMAKE_HOST_WIN32)
>>   SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
>> "<CMAKE_ASM${ASM_DIALECT}_COMPILER> -nologo -coff <FLAGS> -Fo<OBJECT>
>> <SOURCE>")
>> ELSE(CMAKE_HOST_WIN32)
>>   SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
>> "<CMAKE_ASM${ASM_DIALECT}_COMPILER> -nologo -elf <FLAGS> -Fo<OBJECT>
>> <SOURCE>")
>> ENDIF(CMAKE_HOST_WIN32)
>> INCLUDE(CMakeASMInformation)
>> SET(ASM_DIALECT)
>>
>> *** CMakeDetermineASM_JWASMCompiler.cmake
>> # determine the compiler to use for ASM using Intel syntax
>>
>> SET(ASM_DIALECT "_JWASM")
>> SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT jwasm)
>> INCLUDE(CMakeDetermineASMCompiler)
>> SET(ASM_DIALECT)
>>
>> *** CMakeTestASM_JWASMCompiler.cmake
>>
>> # This file is used by EnableLanguage in cmGlobalGenerator to
>> # determine that that selected ASM_JWASM compiler can actually compile
>> # and link the most basic of programs.   If not, a fatal error
>> # is set and cmake stops processing commands and will not generate
>> # any makefiles or projects.
>> SET(ASM_DIALECT "_JWASM")
>> INCLUDE(CMakeTestASMCompiler)
>> SET(ASM_DIALECT)
>>
>> and created a project CMakeLists.txt (omitting irrelevant detais):
>> ...
>> project (TestProject CXX ASM_JWASM)
>> ...
>> include_directories (
>>   c:/some/include/dir
>> )
>> ...
>> add_library (${CMAKE_PROJECT_NAME} SHARED
>>     test.cpp
>>     test.asm
>> )
>>
>> To build a project I used cygwin-compiled cmake as the gcc cross
>> compiler is also cygwin-compiled (but jwasm is a plain Win32 app).
>> Now there is a problem. During the build JWASM is invoked (and fails)
>> the following way:
>>
>> /cygdrive/c/Util/jwasm.exe  -nologo -elf -DTestProject_EXPORTS
>> -I/cygdrive/c/some/include/dir -Fo`cygpath -w
>> CMakeFiles/TestProject.dir/test.asm.o` `cygpath -w
>> /cygdrive/c/Work/TestProject/test.asm`
>> Unknown option /cygdrive/c/some/include/dir
>> -FoCMakeFiles\TestProject.dir\test.asm.o c:\Work\TestProject\test.asm.
>> Use /? for list of options.
>>
>> So there are some questions:
>> 1. Why source and target parameters are wrapped with cygpath, but -I
>> options do not? What part of CMake is responsible for adding these
>> cygpaths?
>
> Did you try whether the cygwin-compiled gcc also works with windows-paths,
> i.e. not with cygwin paths ?
> It's a slightly unusualy mixture you have there.

How to get rid of cygwin paths? gcc cross-compiler and GNU make are
both cygwin-built. I need "Unix makefile" generator and I have to use
cygwin cmake as Win32 cmake expands vars like ${PROJECT_SOURCE_DIR} to
C:/Work/... (with colon) in the generated build.make:

CMakeFiles/PObjects.dir/C_/Work/Test/Test.cpp.o: C:/Work/Test/Test.cpp
(...)

This yields syntax error during the build phase.

Cygwin-built jwasm could be a solution, but unfortunately it doesn't exist.

>> 2. Does include_directories always affect all compilers?
>
> Yes.
>
>> Is it possible to ignore them for some specific ones?
>
> Not that I know of.

Where is specified that -I flag should be used for include
directories? Maybe I could work around this temporarily setting the
include flag to -Ddummy= ?

- Dmitry Bely


More information about the CMake mailing list