English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 29 November 2019, 09:55   #1
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
CMake and vasm

Are there any examples on how to write a cmake script to assemble a bunch of files into a binary?
Not sure if it is very different to create a project which consists only of assembler sources, versus a project which mixes gcc and also links assembler files.
Using gcc is simple enough, but I haven't found any info on how to build vasm sources, so I'm currently looking into how to write my own modules for cmake and it would be nice if there already exists something like that.
sparhawk is offline  
Old 29 November 2019, 10:06   #2
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,774
What exactly do you want to accomplish?
Tigerskunk is online now  
Old 29 November 2019, 11:41   #3
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
Szenario 1:
Multiple asm files, built into an executable or library
Szenario 2:
gcc sources files mixed with asm source files.

If I can build a library, then szenario 2 is probably obsolete, because then one could always build a library anyway. Also I guess, if I can build asm files I should also be able to integrate it into a gcc project as well.

I wrote a small assembler source, and ocmpiled it manually, but I don't want to use this approach all the time.
sparhawk is offline  
Old 29 November 2019, 11:45   #4
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
It has to be CMake? I do this with gnu make fairly easily.
deimos is offline  
Old 29 November 2019, 11:56   #5
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
I can also do it with makefile, but I would prefer cmake, as I also use this for gcc builds.
sparhawk is offline  
Old 29 November 2019, 13:50   #6
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Here is my CMakeLists.txt for a small project that mixes gcc and asm which assembles with vasm

Code:
cmake_minimum_required(VERSION 3.13)
project(make C ASM)

set(CMAKE_C_FLAGS_MINSIZEREL "-Os")

if (CMAKE_C_COMPILER STREQUAL "/opt/amiga/gcc6/bin/m68k-amigaos-gcc")
    #add_compile_options(-mcrt=nix13 -D_AMIGA -fbaserel -fomit-frame-pointer -msmall-code -Wall)
    #set(CMAKE_EXE_LINKER_FLAGS "-s -mcrt=nix13 -fbaserel -msmall-code" CACHE INTERNAL "" FORCE)
    add_compile_options(-mcrt=nix13 -fomit-frame-pointer -Wall)
    set(CMAKE_EXE_LINKER_FLAGS "-s -mcrt=nix13" CACHE INTERNAL "" FORCE)
    set(SRC_FILES file.c gomake.c make.c make.h reader.c mysystem.c system0.asm)
    set(XTRA_LIBS /opt/amiga/gcc6/m68k-amigaos/lib/libdebug.a)
    set(CMAKE_ASM_COMPILER /opt/amiga/gcc6/bin/vasmm68k_mot)
    set(CMAKE_ASM_FLAGS "-esc -nosym -kick1hunks -Fhunk")
    set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${CMAKE_ASM_FLAGS} -o <OBJECT> <SOURCE>")
    FIND_PROGRAM(CRANKER cranker_generic PATHS "/usr/local/bin")
    IF(CRANKER)
        SET(CRANKER_COMMAND ${CRANKER} -f ${CMAKE_CURRENT_BINARY_DIR}/make -o ${CMAKE_CURRENT_BINARY_DIR}/makec)
        SET(CRANKER_LS ls -l makec)
    ENDIF(CRANKER)
ELSE()
    set(SRC_FILES file.c gomake.c make.c make.h reader.c mysystem.c)
endif(CMAKE_C_COMPILER STREQUAL "/opt/amiga/gcc6/bin/m68k-amigaos-gcc")

set(CMAKE_C_STANDARD 11)

add_executable(make ${SRC_FILES})
target_link_libraries(make ${XTRA_LIBS})
include_directories(.)
#add_custom_command(TARGET make POST_BUILD COMMAND ls -l make)
add_custom_command(TARGET make
        POST_BUILD
        COMMAND ${CRANKER_COMMAND}
        COMMAND ls -l make
        COMMAND ${CRANKER_LS}
        )
#set(CMAKE_VERBOSE_MAKEFILE ON)
alkis is offline  
Old 29 November 2019, 13:55   #7
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
Thanks! Doesn't look so bad then.

Is your system0.asm a kind of crt0 startup code?
sparhawk is offline  
Old 29 November 2019, 14:01   #8
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Quote:
Originally Posted by sparhawk View Post
Is your system0.asm a kind of crt0 startup code?
Nope, it's http://eab.abime.net/showpost.php?p=1360471&postcount=8
alkis is offline  
Old 29 November 2019, 23:06   #9
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
Thanks to your help, I finally managed to create cmake project with two source files.
I attached it, in case someting might find this usefull. This project is for pure asm, and wouldn't work with gcc, as it doesn't link the required libraries, so it's pretty bare bone.
Attached Files
File Type: zip VAsmCMake.zip (1.7 KB, 74 views)
sparhawk is offline  
Old 30 November 2019, 21:04   #10
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
I uploaded the project now in github.

It includes the above sample project which uses vasm only files, and another which contains an example of gcc C++ mingling with a vasm module.

https://github.com/skeetor/Amiga-programming-examples
sparhawk is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
If statements with Vasm LaBodilsen Coders. Asm / Hardware 5 24 September 2019 17:55
Trying out vlink and vasm cla Coders. General 2 30 September 2016 20:30
vasm and comments xxxxx Coders. Asm / Hardware 10 03 February 2015 12:59
vasm question marduk_kurios Coders. Asm / Hardware 7 14 February 2014 20:06
CMake for WinUAE gilgamesh request.UAE Wishlist 1 08 February 2010 00:28

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:28.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12877 seconds with 14 queries