Skip to content

Commit

Permalink
Bump cmake version
Browse files Browse the repository at this point in the history
Compatibility with macos 10.15+
  • Loading branch information
andystanton committed Dec 1, 2019
1 parent 7f2bcc0 commit 1e6760b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
23 changes: 10 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
cmake_minimum_required(VERSION 3.7)
set(project_name "nasm-test")
project(${project_name} ASM_NASM)

set(CMAKE_NASM_LINK_EXECUTABLE "ld <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CAN_USE_ASSEMBLER TRUE)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (APPLE)
set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -macosx_version_min 10.13")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_ASM_NASM_FLAGS "-DMACOS")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -macosx_version_min 10.13 -no_pie")
endif (APPLE)

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (UNIX AND NOT APPLE)
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif (UNIX AND NOT APPLE)

enable_language(ASM_NASM)
project(${project_name} ASM_NASM)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_ASM_NASM_FLAGS "-DMACOS")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
enable_language(ASM_NASM)

set(SOURCE_FILES src/asm/helloworld.asm)

add_executable(${project_name} ${SOURCE_FILES})
set_target_properties(${project_name} PROPERTIES LINKER_LANGUAGE NASM)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (APPLE)
target_link_libraries(${project_name} System)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif (APPLE)
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# build container
FROM debian
FROM debian:stable-slim

RUN apt-get -q update && apt-get -qy upgrade && apt-get -qy install clang make curl python

ARG cmake_version=3.13
ARG cmake_revision=4
ARG cmake_version=3.16
ARG cmake_revision=0
WORKDIR /root
RUN curl -OJ https://cmake.org/files/v${cmake_version}/cmake-${cmake_version}.${cmake_revision}-Linux-x86_64.tar.gz
RUN tar -xzf cmake-${cmake_version}.${cmake_revision}-Linux-x86_64.tar.gz
Expand Down
18 changes: 9 additions & 9 deletions src/asm/helloworld.asm
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
%ifdef MACOS
%define entrypoint _main
%define syscall_write 0x2000004
%define syscall_exit 0x2000001
%define ENTRYPOINT _main
%define SYSCALL_WRITE 0x2000004
%define SYSCALL_EXIT 0x2000001
%else
%define entrypoint _start
%define syscall_write 1
%define syscall_exit 60
%define ENTRYPOINT start
%define SYSCALL_WRITE 1
%define SYSCALL_EXIT 60
%endif

section .text
global entrypoint
global ENTRYPOINT

entrypoint: mov rax, syscall_write ; write
ENTRYPOINT: mov rax, SYSCALL_WRITE ; write
mov rdi, 1 ; stdout
mov rsi, msg
mov rdx, msg.len
syscall
mov rax, syscall_exit ; exit
mov rax, SYSCALL_EXIT ; exit
mov rdi, 0 ; return 0
syscall

Expand Down

0 comments on commit 1e6760b

Please sign in to comment.