Michael IV
Michael IV

Reputation: 11446

Cmake:build YASM source files

I am using CMake 3.4.1 to generate and build Visual Studio 2013 64bit C++ solution.One of the project also contains .asm files which we compile in VisualStudio with yasm assembler as lib.How do I configure CMake to use yasm for those files?I haven't found any documentation with example of how to set it up.

Upvotes: 1

Views: 2037

Answers (1)

David Marquant
David Marquant

Reputation: 2237

Have a look a the following example:

cmake_minimum_required(VERSION 3.0)
project(YasmCmake)

find_program(YASM_EXE NAMES yasm)

add_custom_command(OUTPUT hello.o COMMAND ${YASM_EXE}
                   ARGS -f elf64 -o hello.o ${CMAKE_CURRENT_SOURCE_DIR}/hello.asm)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_library(Hello hello.o)
set_target_properties(Hello PROPERTIES LINKER_LANGUAGE CXX)

Of course you need to specify the flags for yasm depending on your platform.

Upvotes: 2

Related Questions