Home > Back-end >  CMake project with CPP and ASM
CMake project with CPP and ASM

Time:11-05

Try to make hello world project with external ASM function in CPP.

CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

project(TestProject VERSION 0.1 LANGUAGES CXX ASM)

set_property(SOURCE foo.s APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

add_executable(TestProject main.cpp foo.s)

target_include_directories(TestProject PUBLIC
              "${PROJECT_BINARY_DIR}"
              )

foo.s

.text
.globl _foo
_foo:
add %esi,            
  • Related